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

Upgrade esbuild #680

Merged
merged 1 commit into from
Nov 4, 2024
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
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
"@types/node": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@vanilla-extract/esbuild-plugin": "^2.0.0",
"@vitest/coverage-istanbul": "^2.0.0",
"@vanilla-extract/esbuild-plugin": "^2.3.11",
"@vitest/coverage-istanbul": "^2.1.4",
"concurrently": "^7.1.0",
"del-cli": "^4.0.1",
"esbuild": "0.14.35",
"esbuild-node-externals": "^1.0.2",
"esbuild": "0.23.1",
"esbuild-node-externals": "^1.7.0",
"eslint": "^7.23.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
Expand Down Expand Up @@ -102,6 +102,7 @@
"@braintree/sanitize-url": "^6.0.0",
"@types/react": "^18.0.26",
"commander": "^9.4.0",
"esbuild": "0.23.1",
"json5": "^1.0.2"
},
"lint-staged": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:types": "tsc",
"build:cli": "node ./scripts/bundle.js",
"build:cli": "node ./scripts/bundle.mjs",
"clean": "rm -fr dist",
"docker:build": "docker build . --tag mosaic-fs:latest",
"docker:start": "docker run -it --rm --ipc=host -p 8080:8080 --mount source=docs,destination=/app/docs --network mosaic-net --name mosaic-fs mosaic-fs:latest",
Expand All @@ -39,7 +39,7 @@
},
"devDependencies": {
"@jpmorganchase/mosaic-types": "^0.1.0-beta.89",
"esbuild": "0.14.35",
"esbuild": "0.23.1",
"esbuild-node-externals": "^1.0.2",
"fast-glob": "^3.2.7",
"@types/ws": "^8.5.7"
Expand Down
48 changes: 0 additions & 48 deletions packages/cli/scripts/bundle.js

This file was deleted.

44 changes: 44 additions & 0 deletions packages/cli/scripts/bundle.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import glob from 'fast-glob';
import esbuild from 'esbuild';
import { nodeExternalsPlugin } from 'esbuild-node-externals';

const args = process.argv.slice(2);
const watchEnabled = args[0] === 'watch';
const packageName = process.env.npm_package_name;

try {
const context = await esbuild.context({
entryPoints: glob.sync(['src/**/*.ts?(x)', 'src/*.ts?(x)'], {
ignore: ['**/__tests__', 'src/labs']
}),
outdir: './dist',
outExtension: { '.js': '.mjs' },
bundle: true,
sourcemap: false,
splitting: true,
minify: true,
format: 'esm',
target: ['es2022', 'node18'],
platform: 'node',
plugins: [nodeExternalsPlugin()]
});
await context.rebuild();
if (watchEnabled) {
await context.watch();
}
await context.serve();
context.dispose();
} catch (e) {
if (e.errors && e.errors.length > 0) {
console.group(`!!!!!!! ${packageName} build errors !!!!!!!`);
console.error(e.errors);
console.groupEnd();
}

if (e.warnings && e.warnings.length > 0) {
console.group(`!!!!!!! ${packageName} build warnings !!!!!!!`);
console.error(e.warnings);
console.groupEnd();
}
process.exit(1);
}
6 changes: 3 additions & 3 deletions packages/components-labs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
],
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:components": "node ../../scripts/bundle.js",
"build:components": "node ../../scripts/bundle.mjs",
"build:types": "tsc",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"devDependencies": {
"@types/styled-components": "^5.1.26",
"@vanilla-extract/esbuild-plugin": "^2.0.2",
"@vanilla-extract/esbuild-plugin": "^2.3.11",
"del-cli": "^4.0.1",
"typescript": "^4.8.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:types": "tsc",
"build:components": "node ../../scripts/bundle.js",
"build:components": "node ../../scripts/bundle.mjs",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"doc": "node ../../scripts/updateDocs.js",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"devDependencies": {
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/content-editor-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
],
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ../../scripts/bundle.js",
"build:bundle": "node ../../scripts/bundle.mjs",
"build:types": "tsc",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"devDependencies": {
"typescript": "^4.8.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/create-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"main": "./dist/index.js",
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ./scripts/bundle.js",
"build:bundle": "node ./scripts/bundle.mjs",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"watch": "node ./scripts/bundle.js watch"
"watch": "node ./scripts/bundle.mjs watch"
},
"bin": {
"mosaic-create-site": "./bin/mosaic-create-site.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
const esbuild = require('esbuild');
import esbuild from 'esbuild';

const args = process.argv.slice(2);
const watchEnabled = args[0] === 'watch';
const packageName = process.env.npm_package_name;

const watchConfig = watchEnabled
? {
onRebuild(error, result) {
if (error) console.error(`watch build failed for ${packageName}:`, error);
else console.log(`watch build succeeded for ${packageName}:`, result);
}
}
: false;

try {
esbuild.build({
const context = await esbuild.context({
entryPoints: ['src/create.ts', 'src/init.ts'],
bundle: false,
outdir: 'dist',
outExtension: { '.js': '.mjs' },
platform: 'node',
format: 'esm',
watch: watchConfig
});
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: false,
outdir: 'dist',
platform: 'node',
format: 'cjs',
watch: watchConfig
plugins: [
{
name: 'on-end',
setup(build) {
build.onEnd(({ errors = [] }) => {
if (errors.length) {
console.error(`build failed for ${packageName}:`, errors);
} else {
console.log(`build succeeded for ${packageName}:`);
}
});
}
}
]
});
await context.rebuild();
if (watchEnabled) {
await context.watch();
}
await context.serve();
context.dispose();
} catch (e) {
if (e.errors && e.errors.length > 0) {
console.group(`!!!!!!! ${packageName} build errors !!!!!!!`);
Expand All @@ -43,6 +45,5 @@ try {
console.error(e.warnings);
console.groupEnd();
}

process.exit(1);
}
4 changes: 2 additions & 2 deletions packages/layouts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
],
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ../../scripts/bundle.js",
"build:bundle": "node ../../scripts/bundle.mjs",
"build:types": "tsc",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"devDependencies": {
"del-cli": "^4.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/open-api-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
],
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ../../scripts/bundle.js",
"build:bundle": "node ../../scripts/bundle.mjs",
"build:types": "tsc",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"devDependencies": {
"del-cli": "^4.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/site-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
},
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ../../scripts/bundle.js",
"build:bundle": "node ../../scripts/bundle.mjs",
"build:types": "tsc",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ../../scripts/bundle.js watch"
"dev": "node ../../scripts/bundle.mjs watch"
},
"files": [
"dist"
],
"devDependencies": {
"@types/styled-components": "^5.1.26",
"@vanilla-extract/esbuild-plugin": "^2.0.2",
"@vanilla-extract/esbuild-plugin": "^2.3.11",
"del-cli": "^4.0.1",
"next-router-mock": "^0.9.13",
"typescript": "^4.8.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/site-preset-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
],
"scripts": {
"build": "npm-run-all --parallel build:*",
"build:bundle": "node ./scripts/bundle.js",
"build:bundle": "node ./scripts/bundle.mjs",
"clean": "npx del-cli 'dist/**' && find . -type d -empty -delete",
"lint": "eslint --ignore-pattern \"**/__tests__/**\"",
"dev": "node ./scripts/bundle.js watch"
"dev": "node ./scripts/bundle.mjs watch"
},
"devDependencies": {
"del-cli": "^4.0.1",
"esbuild": "0.14.35",
"esbuild": "0.23.1",
"esbuild-node-externals": "^1.0.2"
},
"dependencies": {
Expand Down
44 changes: 0 additions & 44 deletions packages/site-preset-styles/scripts/bundle.js

This file was deleted.

Loading
Loading