From b305961fa9d26981fd2918f76ef4c39e9ec67388 Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Wed, 26 Apr 2023 13:59:10 -0700 Subject: [PATCH 1/3] chore: reduce project-config size by removing babel deps --- packages/project-config/build.mjs | 18 ++++++++++++++++++ packages/project-config/package.json | 7 +------ yarn.lock | 4 ---- 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 packages/project-config/build.mjs diff --git a/packages/project-config/build.mjs b/packages/project-config/build.mjs new file mode 100644 index 000000000000..aeaf95b7801a --- /dev/null +++ b/packages/project-config/build.mjs @@ -0,0 +1,18 @@ +import fs from 'node:fs' + +import * as esbuild from 'esbuild' + +const result = await esbuild.build({ + entryPoints: ['src/index.ts'], + bundle: true, + platform: 'node', + target: ['node18'], + outfile: 'dist/index.js', + packages: 'external', + + // For visualizing the bundle. + // See https://esbuild.github.io/api/#metafile and https://esbuild.github.io/analyze/. + metafile: true, +}) + +fs.writeFileSync('meta.json', JSON.stringify(result.metafile)) diff --git a/packages/project-config/package.json b/packages/project-config/package.json index 2a032a7f9d3a..dd04f181e03e 100644 --- a/packages/project-config/package.json +++ b/packages/project-config/package.json @@ -15,9 +15,8 @@ "dist" ], "scripts": { - "build": "run build:js && run build:types", + "build": "yarn node ./build.mjs && run build:types", "build:clean-dist": "rimraf 'dist/**/__tests__' --glob", - "build:js": "babel src -d dist --extensions \".js,.ts,.tsx\" --copy-files --no-copy-ignored && run build:clean-dist", "build:types": "tsc --build --verbose", "build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", "deps:dist": "depcruise dist --config --output-type dot | dot -T svg > dependency-graph-dist.svg", @@ -27,17 +26,13 @@ "test:watch": "run test --watch" }, "dependencies": { - "@babel/runtime-corejs3": "7.21.0", "@iarna/toml": "2.2.5", - "core-js": "3.30.1", "deepmerge": "4.3.1", "fast-glob": "3.2.12", "findup-sync": "5.0.0", "string-env-interpolation": "1.0.1" }, "devDependencies": { - "@babel/cli": "7.21.0", - "@babel/core": "7.21.4", "@types/findup-sync": "4.0.2", "dependency-cruiser": "12.11.3", "jest": "29.5.0", diff --git a/yarn.lock b/yarn.lock index 7fbbd53bd6e0..460bef88aab0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7133,12 +7133,8 @@ __metadata: version: 0.0.0-use.local resolution: "@redwoodjs/project-config@workspace:packages/project-config" dependencies: - "@babel/cli": 7.21.0 - "@babel/core": 7.21.4 - "@babel/runtime-corejs3": 7.21.0 "@iarna/toml": 2.2.5 "@types/findup-sync": 4.0.2 - core-js: 3.30.1 deepmerge: 4.3.1 dependency-cruiser: 12.11.3 fast-glob: 3.2.12 From 75764552da92bbac423455a6ee26559d9691784b Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Mon, 8 May 2023 09:48:41 -0700 Subject: [PATCH 2/3] reorganize build file --- packages/project-config/build.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/project-config/build.mjs b/packages/project-config/build.mjs index aeaf95b7801a..9da4a7c46176 100644 --- a/packages/project-config/build.mjs +++ b/packages/project-config/build.mjs @@ -4,10 +4,12 @@ import * as esbuild from 'esbuild' const result = await esbuild.build({ entryPoints: ['src/index.ts'], + outdir: 'dist', + bundle: true, + platform: 'node', target: ['node18'], - outfile: 'dist/index.js', packages: 'external', // For visualizing the bundle. From 0846a670e0fcaf96469b1a6352c835cde2de216b Mon Sep 17 00:00:00 2001 From: Dominic Saadi Date: Mon, 8 May 2023 09:51:24 -0700 Subject: [PATCH 3/3] add logging --- packages/project-config/build.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/project-config/build.mjs b/packages/project-config/build.mjs index 9da4a7c46176..ffe56393a3d3 100644 --- a/packages/project-config/build.mjs +++ b/packages/project-config/build.mjs @@ -12,6 +12,8 @@ const result = await esbuild.build({ target: ['node18'], packages: 'external', + logLevel: 'info', + // For visualizing the bundle. // See https://esbuild.github.io/api/#metafile and https://esbuild.github.io/analyze/. metafile: true,