Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRWA, Tui] Try removing Babel and bundling minimally #8074

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ blog-test-project/*
.pnp.*
*.code-workspace
.nova

# For esbuild.
**/meta.json
1 change: 0 additions & 1 deletion packages/create-redwood-app/.babelrc.js

This file was deleted.

24 changes: 24 additions & 0 deletions packages/create-redwood-app/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from 'node:fs'

import * as esbuild from 'esbuild'

// There's minimal bundling going on here by design. Only "src/create-redwood-app.js" and "src/telemetry.js"
// are bundled into a single "dist/create-redwood-app.js" file.
// As we audit more of this package's dependencies, we'll remove them from a handcrafted "external" list,
// instead of using the catch-all `packages: 'external'` option.
const result = await esbuild.build({
entryPoints: ['src/create-redwood-app.js'],
bundle: true,
platform: 'node',
target: ['node18'],
// See https://esbuild.github.io/getting-started/#bundling-for-node.
packages: 'external',
outfile: 'dist/create-redwood-app.js',
minify: true,

// 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))
9 changes: 0 additions & 9 deletions packages/create-redwood-app/jest.config.js

This file was deleted.

13 changes: 3 additions & 10 deletions packages/create-redwood-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
"template"
],
"scripts": {
"build": "yarn build:js",
"build:js": "babel src -d dist",
"build": "yarn node ./build.mjs",
"build:watch": "nodemon --watch src --ignore dist,template --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"prepublishOnly": "NODE_ENV=production yarn build"
},
"dependencies": {
"@babel/runtime-corejs3": "7.21.0",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/exporter-trace-otlp-http": "0.37.0",
"@opentelemetry/resources": "1.11.0",
Expand All @@ -31,7 +27,6 @@
"chalk": "4.1.2",
"check-node-version": "4.2.1",
"ci-info": "3.8.0",
"core-js": "3.30.0",
"envinfo": "7.8.1",
"execa": "5.1.1",
"fs-extra": "11.1.1",
Expand All @@ -40,9 +35,7 @@
"yargs": "17.7.1"
},
"devDependencies": {
"@babel/cli": "7.21.0",
"@babel/node": "7.20.7",
"jest": "29.5.0"
"esbuild": "0.17.15"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
14 changes: 0 additions & 14 deletions packages/create-redwood-app/src/__tests__/web-template.test.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/tui/.babelrc.js

This file was deleted.

19 changes: 19 additions & 0 deletions packages/tui/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fs from 'node:fs'

import * as esbuild from 'esbuild'

// Since this is a library, there's no bundling going on here by design.
// Instead we plan for this library to be bundled by leaf packages so-to-speak like create-redwood-app.
const result = await esbuild.build({
entryPoints: ['src/index.ts'],
format: 'cjs',
platform: 'node',
target: ['node18'],
outfile: 'dist/index.js',

// 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))
8 changes: 2 additions & 6 deletions packages/tui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build": "yarn node ./build.mjs && yarn build:types",
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
Expand All @@ -28,16 +27,13 @@
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1",
"dependencies": {
"@babel/runtime-corejs3": "7.21.0",
"boxen": "5.1.2",
"chalk": "4.1.2",
"core-js": "3.30.0",
"enquirer": "2.3.6",
"stdout-update": "1.6.8"
},
"devDependencies": {
"@babel/cli": "7.21.0",
"@babel/core": "7.21.3",
"esbuild": "0.17.15",
"jest": "29.5.0",
"typescript": "5.0.3"
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/run-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const buildRedwoodFramework = () => {
const createRedwoodJSApp = ({ yarn1 }) => {
try {
execa.sync(
'yarn babel-node src/create-redwood-app.js',
'yarn node dist/create-redwood-app.js',
[
REDWOOD_PROJECT_DIRECTORY,
'--no-yarn-install',
Expand Down
11 changes: 2 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7319,13 +7319,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "@redwoodjs/tui@workspace:packages/tui"
dependencies:
"@babel/cli": 7.21.0
"@babel/core": 7.21.3
"@babel/runtime-corejs3": 7.21.0
boxen: 5.1.2
chalk: 4.1.2
core-js: 3.30.0
enquirer: 2.3.6
esbuild: 0.17.15
jest: 29.5.0
stdout-update: 1.6.8
typescript: 5.0.3
Expand Down Expand Up @@ -14430,9 +14427,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "create-redwood-app@workspace:packages/create-redwood-app"
dependencies:
"@babel/cli": 7.21.0
"@babel/node": 7.20.7
"@babel/runtime-corejs3": 7.21.0
"@opentelemetry/api": 1.4.1
"@opentelemetry/exporter-trace-otlp-http": 0.37.0
"@opentelemetry/resources": 1.11.0
Expand All @@ -14442,11 +14436,10 @@ __metadata:
chalk: 4.1.2
check-node-version: 4.2.1
ci-info: 3.8.0
core-js: 3.30.0
envinfo: 7.8.1
esbuild: 0.17.15
execa: 5.1.1
fs-extra: 11.1.1
jest: 29.5.0
systeminformation: 5.17.12
terminal-link: 2.1.1
yargs: 17.7.1
Expand Down