Skip to content

Commit

Permalink
Using tsc to build instead of rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed May 26, 2023
1 parent e0a4be2 commit 945386a
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 223 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ coverage/
# Generated artifacts
/packages/realm/bindgen/vendor/bindgen-lib/generated/
/packages/realm/generated/
/packages/realm/src/generated/

# Build artifacts
/packages/realm/dist/
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/environments/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:main": {
"command": "mocha-remote --reporter @realm/mocha-reporter --id main tsx runner.ts main",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
Expand All @@ -34,7 +34,7 @@
"test:renderer": {
"command": "mocha-remote --reporter @realm/mocha-reporter --id renderer tsx runner.ts renderer",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/environments/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": {
"command": "mocha-remote --reporter @realm/mocha-reporter tsx index.mjs",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
Expand All @@ -22,7 +22,7 @@
"test:commonjs": {
"command": "mocha-remote --reporter @realm/mocha-reporter tsx index.cjs",
"dependencies": [
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/realm:build:node",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/environments/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"command": "npm run common",
"dependencies": [
"../../../packages/realm:build:android",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand All @@ -106,7 +106,7 @@
"command": "npm run common",
"dependencies": [
"pod-install:simulator",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand All @@ -119,7 +119,7 @@
"command": "npm run common",
"dependencies": [
"pod-install:catalyst",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand All @@ -132,7 +132,7 @@
"command": "npm run common",
"dependencies": [
"../../../packages/realm:build:android",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand All @@ -146,7 +146,7 @@
"dependencies": [
"pod-install:simulator",
"../../../packages/realm:build:ios:debug:simulator",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand All @@ -160,7 +160,7 @@
"dependencies": [
"pod-install:catalyst",
"../../../packages/realm:build:ios:debug:catalyst",
"../../../packages/realm:bundle",
"../../../packages/realm:build:ts",
"../../../packages/mocha-reporter:bundle",
"../../../packages/realm-network-transport:bundle"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"bundle": {
"dependencies": [
"./packages/realm:bundle",
"./packages/realm:build:ts",
"./packages/babel-plugin:bundle",
"./packages/mocha-reporter:bundle",
"./packages/realm-react:bundle",
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/bindgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ file(GLOB_RECURSE SDK_TS_FILES
list(FILTER SDK_TS_FILES EXCLUDE REGEX "templates/[^/]*\.ts$")

set(JS_SPEC_FILE ${SDK_DIR}/bindgen/js_spec.yml)
set(TYPESCRIPT_OUTPUT_DIR ${SDK_DIR}/generated/ts)
set(TYPESCRIPT_OUTPUT_DIR ${SDK_DIR}/generated)

set(GENERATED_TS_FILES
${TYPESCRIPT_OUTPUT_DIR}/native.d.mts
Expand Down
4 changes: 2 additions & 2 deletions packages/realm/bindgen/src/templates/node-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export function generate({ spec: rawSpec, file }: TemplateContext): void {

both(`
import { Long, ObjectId, UUID, Decimal128, EJSON } from "bson";
import { Float } from "./core";
import { Float } from "realm/binding/core";
export * from "./core";
export * from "realm/binding/core";
// Copied from lib/utils.js.
// TODO consider importing instead.
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/bindgen/src/templates/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export function generate({ spec: rawSpec, file }: TemplateContext): void {
}
`);

const out = file("native.d.mts", eslint);
const out = file("native.d.ts", eslint);
out("// This file is generated: Update the spec instead of editing this file directly");

out("declare module 'realm/binding' {");
Expand Down
45 changes: 21 additions & 24 deletions packages/realm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@
"email": "[email protected]",
"url": "https://realm.io"
},
"main": "./dist/bundle.node.js",
"module": "./dist/bundle.node.mjs",
"types": "./dist/bundle.d.ts",
"react-native": "./dist/bundle.react-native.mjs",
"types": "./dist/cjs.d.ts",
"main": "./dist/platform/node/index.cjs.js",
"react-native": "./dist/platform/react-native/index.cjs.js",
"exports": {
".": {
"types": "./dist/bundle.d.ts",
"require": "./dist/bundle.node.js",
"node": "./dist/bundle.node.mjs",
"react-native": "./dist/bundle.react-native.mjs"
"types": "./dist/cjs.d.ts",
"node": "./dist/platform/node/index.cjs.js",
"react-native": "./dist/platform/react-native/index.cjs.js"
},
"./binding": {
"node": "./generated/native-node.mjs",
"react-native": "./generated/native-react-native.mjs"
},
"./binding/core": "./dist/generated/core.js",
"./scripts/submit-analytics": "./scripts/submit-analytics.mjs",
"./react-native.config.js": "./react-native.config.js",
"./package.json": "./package.json"
Expand All @@ -52,13 +55,12 @@
"test:types": "tsc --project type-tests/tsconfig.json",
"lint": "eslint --ext .js,.mjs,.ts .",
"build": "echo 'Run bundle, build:node, build:ios or build:android or other scripts depending on these instead' && exit 1",
"bundle": "wireit",
"bundle:coverage": "ENABLE_TEST_COVERAGE_INSTRUMENTATION=true npm run bundle",
"bindgen:configure": "wireit",
"bindgen:build:node": "wireit",
"bindgen:generate:typescript": "wireit",
"bindgen:generate:wrappers": "wireit",
"bindgen:generate:spec-schema": "wireit",
"build:ts": "wireit",
"build:node": "wireit",
"build:node:prebuild": "wireit",
"build:node:prebuild:arm": "wireit",
Expand All @@ -83,13 +85,8 @@
"../realm-network-transport:bundle"
]
},
"bundle": {
"command": "rollup --config",
"env": {
"ENABLE_TEST_COVERAGE_INSTRUMENTATION": {
"external": true
}
},
"build:ts": {
"command": "tsc -b",
"dependencies": [
"../realm-network-transport:bundle",
"bindgen:generate:typescript",
Expand All @@ -115,7 +112,7 @@
]
},
"bindgen:generate:typescript": {
"command": "realm-bindgen --template bindgen/src/templates/typescript.ts --spec bindgen/vendor/realm-core/bindgen/spec.yml --spec bindgen/js_spec.yml --output ./generated/ts",
"command": "realm-bindgen --template bindgen/src/templates/typescript.ts --spec bindgen/vendor/realm-core/bindgen/spec.yml --spec bindgen/js_spec.yml --output ./src/generated",
"dependencies": [
"bindgen:generate:spec-schema"
],
Expand All @@ -128,12 +125,12 @@
"bindgen/src/templates/typescript.ts"
],
"output": [
"generated/ts/core.ts",
"generated/ts/native.d.mts"
"src/generated/core.ts",
"src/generated/native.d.ts"
]
},
"bindgen:generate:wrappers": {
"command": "realm-bindgen --template bindgen/src/templates/node-wrapper.ts --spec bindgen/vendor/realm-core/bindgen/spec.yml --spec bindgen/js_spec.yml --output ./generated/ts",
"command": "realm-bindgen --template bindgen/src/templates/node-wrapper.ts --spec bindgen/vendor/realm-core/bindgen/spec.yml --spec bindgen/js_spec.yml --output ./generated",
"dependencies": [
"bindgen:generate:spec-schema"
],
Expand All @@ -146,8 +143,8 @@
"bindgen/src/templates/node-wrapper.ts"
],
"output": [
"generated/ts/native-node.mjs",
"generated/ts/native-react-native.mjs"
"generated/native-node.mjs",
"generated/native-react-native.mjs"
]
},
"bindgen:generate:spec-schema": {
Expand Down Expand Up @@ -252,7 +249,7 @@
"docs": {
"command": "typedoc",
"dependencies": [
"bundle"
"build:ts"
]
}
},
Expand Down
123 changes: 0 additions & 123 deletions packages/realm/rollup.config.mjs

This file was deleted.

20 changes: 20 additions & 0 deletions packages/realm/src/cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2023 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

import { Realm } from "./index";
export = Realm;
Loading

0 comments on commit 945386a

Please sign in to comment.