Skip to content

Commit

Permalink
chore(deps): bump esbuild from v15/v16 to v17 (#4098)
Browse files Browse the repository at this point in the history
* chore(deps): bump esbuild from v15/v16 to v17

* fix: should call ctx.rebuild
  • Loading branch information
chenjiahan authored Jun 30, 2023
1 parent 9f78d0c commit 85366bc
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 327 deletions.
11 changes: 11 additions & 0 deletions .changeset/wise-tigers-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@modern-js/node-bundle-require': patch
'@modern-js/builder-plugin-esbuild': patch
'@modern-js/runtime': patch
'@modern-js/plugin-storybook': patch
'@modern-js/app-tools': patch
---

chore(deps): bump esbuild from v15/v16 to v17

chore(deps): 将 esbuild 从 v15/v16 升级到 v17
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"@vitest/ui": "^0.21.1",
"babel-plugin-module-resolver": "^4.1.0",
"cypress": "^10.1.0",
"esbuild": "0.15.7",
"esbuild": "0.17.19",
"execa": "^5.1.1",
"globby": "^11.0.4",
"husky": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/plugin-esbuild/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"test:watch": "vitest dev --no-coverage"
},
"dependencies": {
"esbuild": "0.16.17",
"esbuild": "0.17.19",
"@modern-js/builder-shared": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/plugin-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@storybook/manager-webpack5": "6.5.12",
"@storybook/react": "6.5.12",
"@swc/helpers": "0.5.1",
"esbuild": "0.15.7",
"esbuild": "0.17.19",
"findup-sync": "^4.0.0",
"fs-extra": "^10.0.0",
"process.argv": "^0.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/plugin-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"@types/react-helmet": "^6.1.2",
"@types/redux-logger": "^3.0.9",
"@types/styled-components": "^5.1.14",
"esbuild": "0.15.7",
"esbuild": "0.17.19",
"hoist-non-react-statics": "^3.3.2",
"invariant": "^2.2.4",
"react-helmet": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/solutions/app-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@modern-js/upgrade": "workspace:*",
"@modern-js/utils": "workspace:*",
"es-module-lexer": "^1.1.0",
"esbuild": "0.15.7",
"esbuild": "0.17.19",
"rspack-plugin-virtual-module": "0.1.0",
"@swc/helpers": "0.5.1"
},
Expand Down
6 changes: 1 addition & 5 deletions packages/solutions/app-tools/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ export const dev = async (
appDirectory,
distDirectory,
configFile: serverConfigFile,
options: {
esbuildOptions: {
watch: true,
},
},
watch: true,
});

await hookRunners.beforeDev();
Expand Down
3 changes: 3 additions & 0 deletions packages/solutions/app-tools/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ export const buildServerConfig = async ({
distDirectory,
configFile,
options,
watch,
}: {
appDirectory: string;
distDirectory: string;
configFile: string;
options?: Parameters<typeof bundle>[1];
watch?: boolean;
}) => {
const configFilePath = await getServerConfig(appDirectory, configFile);

Expand All @@ -46,6 +48,7 @@ export const buildServerConfig = async ({
await fs.writeFile(configHelperFilePath, helperCode);
await bundle(configFilePath, {
...options,
watch,
getOutputFile,
esbuildPlugins: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/node-bundle-require/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"@modern-js/utils": "workspace:*",
"esbuild": "0.15.7",
"esbuild": "0.17.19",
"@swc/helpers": "0.5.1"
},
"devDependencies": {
Expand Down
19 changes: 16 additions & 3 deletions packages/toolkit/node-bundle-require/src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CONFIG_CACHE_DIR,
createDebugger,
} from '@modern-js/utils';
import { build, Loader, Plugin, BuildOptions } from 'esbuild';
import { build, context, Loader, Plugin, BuildOptions } from 'esbuild';

const debug = createDebugger('node-bundle');

Expand Down Expand Up @@ -67,6 +67,11 @@ export interface Options {
* auto clear bundle file
*/
autoClear?: boolean;

/**
* Whether to enable watch mode
*/
watch?: boolean;
}

export const defaultGetOutputFile = async (filepath: string) =>
Expand All @@ -85,7 +90,7 @@ export async function bundle(filepath: string, options?: Options) {
const getOutputFile = options?.getOutputFile || defaultGetOutputFile;
const outfile = await getOutputFile(path.basename(filepath));

await build({
const esbuildOptions: BuildOptions = {
entryPoints: [filepath],
outfile,
format: 'cjs',
Expand Down Expand Up @@ -194,7 +199,15 @@ export async function bundle(filepath: string, options?: Options) {
},
},
],
});
};

if (options?.watch) {
const ctx = await context(esbuildOptions);
await ctx.rebuild();
await ctx.watch();
} else {
await build(esbuildOptions);
}

return outfile;
}
Loading

0 comments on commit 85366bc

Please sign in to comment.