From 0bc7a647dfd278b5b5eb125c89e21eb604038932 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 18:42:39 +0300 Subject: [PATCH 01/12] Types via esbuild --- packages/types/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/package.json b/packages/types/package.json index 96ab8cb095..317342e760 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -14,7 +14,7 @@ "license": "GPL-3.0", "scripts": { "prebuild": "rimraf dist/", - "build": "tsc -p tsconfig.build.json", + "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "dev:builder": "yarn prebuild && tsc -p tsconfig.json --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null" From b882a64ad756fa9d39e25f7cafaed5578b33f653 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 18:45:02 +0300 Subject: [PATCH 02/12] Shared-core via esbuild --- packages/shared-core/package.json | 2 +- packages/shared-core/tsconfig.build.json | 5 ++++- packages/shared-core/tsconfig.json | 9 --------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 98ee89999b..61e97ddc76 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -14,7 +14,7 @@ "license": "GPL-3.0", "scripts": { "prebuild": "rimraf dist/", - "build": "tsc -p tsconfig.build.json", + "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "dev:builder": "yarn prebuild && tsc -p tsconfig.json --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null" diff --git a/packages/shared-core/tsconfig.build.json b/packages/shared-core/tsconfig.build.json index 6930e3cb99..804e86c270 100644 --- a/packages/shared-core/tsconfig.build.json +++ b/packages/shared-core/tsconfig.build.json @@ -12,7 +12,10 @@ "declaration": true, "types": ["node"], "outDir": "dist", - "skipLibCheck": true + "skipLibCheck": true, + "paths": { + "@budibase/types": ["../../types/src"] + } }, "include": ["**/*.js", "**/*.ts"], "exclude": [ diff --git a/packages/shared-core/tsconfig.json b/packages/shared-core/tsconfig.json index f72933ff9b..33e37179d7 100644 --- a/packages/shared-core/tsconfig.json +++ b/packages/shared-core/tsconfig.json @@ -1,13 +1,4 @@ { "extends": "./tsconfig.build.json", - "compilerOptions": { - "baseUrl": ".", - "rootDir": "./src", - "composite": true, - "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", - "paths": { - "@budibase/types": ["../../types/src"] - } - }, "exclude": ["node_modules", "dist"] } From bc5b4297a5e552db92dcd95e85aae7aec08c2da6 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 18:56:07 +0300 Subject: [PATCH 03/12] Backend-core via esbuild --- packages/backend-core/package.json | 2 +- packages/backend-core/plugins.ts | 1 - packages/backend-core/scripts/build.js | 8 ++++++++ 3 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 packages/backend-core/plugins.ts create mode 100644 packages/backend-core/scripts/build.js diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 4631b090fe..25baccbe53 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -14,7 +14,7 @@ "scripts": { "prebuild": "rimraf dist/", "prepack": "cp package.json dist", - "build": "tsc -p tsconfig.build.json", + "build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null", "test": "bash scripts/test.sh", diff --git a/packages/backend-core/plugins.ts b/packages/backend-core/plugins.ts deleted file mode 100644 index 33354eaf64..0000000000 --- a/packages/backend-core/plugins.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./src/plugin" diff --git a/packages/backend-core/scripts/build.js b/packages/backend-core/scripts/build.js new file mode 100644 index 0000000000..992513755a --- /dev/null +++ b/packages/backend-core/scripts/build.js @@ -0,0 +1,8 @@ +#!/usr/bin/node +const { join } = require("path") +const fs = require("fs") +const coreBuild = require("../../../scripts/build") + +coreBuild("./src/plugin/index.ts", "./dist/plugins.js") +coreBuild("./src/index.ts", "./dist/index.js") +coreBuild("./tests/index.ts", "./dist/tests.js") From 5ae100d4cc743fa2825f5d8b369ed2ea7f05a6da Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 18:58:50 +0300 Subject: [PATCH 04/12] Remove unneeded nx deps --- packages/cli/package.json | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 99771adbd3..a0c885657c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -63,20 +63,5 @@ "renamer": "^4.0.0", "ts-node": "^10.9.1", "typescript": "4.7.3" - }, - "nx": { - "targets": { - "build": { - "dependsOn": [ - { - "projects": [ - "@budibase/backend-core", - "@budibase/string-templates" - ], - "target": "build" - } - ] - } - } } } From 93654907c303768ddbe67307347fbf9878823a8f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 19:08:57 +0300 Subject: [PATCH 05/12] Bundle bb dependencies in backend-core --- packages/backend-core/tsconfig.build.json | 6 +++++- packages/backend-core/tsconfig.json | 8 -------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/backend-core/tsconfig.build.json b/packages/backend-core/tsconfig.build.json index bfbed31e23..c714f4d942 100644 --- a/packages/backend-core/tsconfig.build.json +++ b/packages/backend-core/tsconfig.build.json @@ -12,7 +12,11 @@ "declaration": true, "types": ["node", "jest"], "outDir": "dist", - "skipLibCheck": true + "skipLibCheck": true, + "paths": { + "@budibase/types": ["../types/src"], + "@budibase/shared-core": ["../shared-core/src"] + } }, "include": ["**/*.js", "**/*.ts"], "exclude": [ diff --git a/packages/backend-core/tsconfig.json b/packages/backend-core/tsconfig.json index 128814b955..33e37179d7 100644 --- a/packages/backend-core/tsconfig.json +++ b/packages/backend-core/tsconfig.json @@ -1,12 +1,4 @@ { "extends": "./tsconfig.build.json", - "compilerOptions": { - "composite": true, - "baseUrl": ".", - "paths": { - "@budibase/types": ["../types/src"], - "@budibase/shared-core": ["../shared-core/src"] - } - }, "exclude": ["node_modules", "dist"] } From b91677f0ceb234428f48e16c6bd453dd014019c7 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 19:33:57 +0300 Subject: [PATCH 06/12] Fix declarations --- packages/backend-core/package.json | 2 +- packages/shared-core/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 25baccbe53..65577cf4d8 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -14,7 +14,7 @@ "scripts": { "prebuild": "rimraf dist/", "prepack": "cp package.json dist", - "build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", + "build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null", "test": "bash scripts/test.sh", diff --git a/packages/shared-core/package.json b/packages/shared-core/package.json index 61e97ddc76..4e7d568fcb 100644 --- a/packages/shared-core/package.json +++ b/packages/shared-core/package.json @@ -14,7 +14,7 @@ "license": "GPL-3.0", "scripts": { "prebuild": "rimraf dist/", - "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly", + "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "dev:builder": "yarn prebuild && tsc -p tsconfig.json --watch --preserveWatchOutput", "check:types": "tsc -p tsconfig.json --noEmit --paths null" From a213475041722c66f5503f5e21a4d5ab3149f9a5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 19:34:20 +0300 Subject: [PATCH 07/12] Esbuild, build esm --- scripts/build.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/build.js b/scripts/build.js index b93ae1bbe6..966d5f158c 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -59,9 +59,16 @@ function runBuild(entry, outfile) { ], } + const { compilerOptions } = tsconfigPathPluginContent + const format = + compilerOptions.target === "es6" && compilerOptions.module !== "commonjs" + ? "esm" + : undefined + build({ ...sharedConfig, platform: "node", + format, outfile, }).then(result => { glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => { From 8e655dae6624d9d11cd40b63a18108b460fad317 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 19:36:36 +0300 Subject: [PATCH 08/12] Fix path --- packages/shared-core/tsconfig.build.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-core/tsconfig.build.json b/packages/shared-core/tsconfig.build.json index 804e86c270..31dc1afc10 100644 --- a/packages/shared-core/tsconfig.build.json +++ b/packages/shared-core/tsconfig.build.json @@ -14,7 +14,7 @@ "outDir": "dist", "skipLibCheck": true, "paths": { - "@budibase/types": ["../../types/src"] + "@budibase/types": ["../types/src"] } }, "include": ["**/*.js", "**/*.ts"], From da87b28155596dc54945dfadca09c72677f05405 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 8 Aug 2023 19:39:32 +0300 Subject: [PATCH 09/12] Clean nx deps --- packages/bbui/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 8a9318ba94..0b87960ab5 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -98,8 +98,7 @@ { "projects": [ "@budibase/string-templates", - "@budibase/shared-core", - "@budibase/types" + "@budibase/shared-core" ], "target": "build" } From c21da4fbd3a4529477e3993ce375dbd484f2d73b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Aug 2023 11:40:54 +0300 Subject: [PATCH 10/12] Consume packages from builder --- packages/builder/package.json | 12 +++--------- packages/builder/vite.config.js | 8 ++++++++ scripts/build.js | 5 ----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 56834f79dd..db8ef86086 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -133,9 +133,7 @@ "dependsOn": [ { "projects": [ - "@budibase/shared-core", - "@budibase/string-templates", - "@budibase/types" + "@budibase/string-templates" ], "target": "build" } @@ -145,9 +143,7 @@ "dependsOn": [ { "projects": [ - "@budibase/shared-core", - "@budibase/string-templates", - "@budibase/types" + "@budibase/string-templates" ], "target": "build" } @@ -157,9 +153,7 @@ "dependsOn": [ { "projects": [ - "@budibase/shared-core", - "@budibase/string-templates", - "@budibase/types" + "@budibase/string-templates" ], "target": "build" } diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 4a0ffca8d4..b7af647916 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -127,6 +127,14 @@ export default defineConfig(({ mode }) => { find: "helpers", replacement: path.resolve("./src/helpers"), }, + { + find: "@budibase/types", + replacement: path.resolve("../types/src"), + }, + { + find: "@budibase/shared-core", + replacement: path.resolve("../shared-core/src"), + }, ], }, } diff --git a/scripts/build.js b/scripts/build.js index 966d5f158c..86f3fb55b9 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -60,15 +60,10 @@ function runBuild(entry, outfile) { } const { compilerOptions } = tsconfigPathPluginContent - const format = - compilerOptions.target === "es6" && compilerOptions.module !== "commonjs" - ? "esm" - : undefined build({ ...sharedConfig, platform: "node", - format, outfile, }).then(result => { glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => { From 029b9d7b342b131af334d5fc4f1b7aa3c8f1890c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Aug 2023 11:46:23 +0300 Subject: [PATCH 11/12] Clean --- scripts/build.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 86f3fb55b9..b93ae1bbe6 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -59,8 +59,6 @@ function runBuild(entry, outfile) { ], } - const { compilerOptions } = tsconfigPathPluginContent - build({ ...sharedConfig, platform: "node", From 32e09cf131ece2eb67e3fb83f3bbb69660690e6a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 9 Aug 2023 12:13:38 +0300 Subject: [PATCH 12/12] Lint --- packages/backend-core/scripts/build.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/backend-core/scripts/build.js b/packages/backend-core/scripts/build.js index 992513755a..bd00cbc7ff 100644 --- a/packages/backend-core/scripts/build.js +++ b/packages/backend-core/scripts/build.js @@ -1,6 +1,4 @@ #!/usr/bin/node -const { join } = require("path") -const fs = require("fs") const coreBuild = require("../../../scripts/build") coreBuild("./src/plugin/index.ts", "./dist/plugins.js")