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 to 0.24.0 #1934

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
36 changes: 16 additions & 20 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const runEsbuild = async () => {
const startTime = performance.now();

const myArgs = process.argv.slice(2);
const isDev = myArgs.includes('--watch');
log(chalk.blue('Starting with args'), myArgs);

if (fs.existsSync(outDir)) {
Expand All @@ -99,44 +98,41 @@ const runEsbuild = async () => {
);

// Run build
await esbuild.build({
const context = await esbuild.context({
entryPoints,
format: 'cjs',
minify: false,
minifyWhitespace: true,
minifyIdentifiers: true,
keepNames: true,
outdir: outDir,
watch: isDev && {
onRebuild(error, result) {
if (error) {
log(chalk.red(`watch build failed: ${error}`));
} else {
log(chalk.blue('watch build success:'), result);
livereload.reload();
}
},
},
incremental: isDev,
plugins: [sassPlugin(), ...staticAssets()],
});

const isDev = myArgs.includes('--watch');
if (isDev) {
const serveResult = await esbuild.serve(
{
servedir: outDir,
port: 8080,
},
{},
);
const serveResult = await context.serve({
servedir: outDir,
port: 8080,
});
log(chalk.green(`Listening on ${serveResult.host}:${serveResult.port}`));
livereload.listen();
} else {
let exitCode = 0;
const result = await context.rebuild();
if (result.errors && result.errors.length > 0) {
log(chalk.red(`build errors: ${JSON.stringify(result.errors)}`));
exitCode = -1;
} else {
log(chalk.blue('✨ build success'));
}

const endTime = performance.now();
const duration = endTime - startTime;
log(
chalk.green(`Completed build in ${moment(duration).format('ss.m')}sec`),
);
process.exit(exitCode);
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"cross-env": "7.0.3",
"electron": "33.2.0",
"electron-builder": "24.13.3",
"esbuild": "0.16.17",
"esbuild": "0.24.0",
"esbuild-plugin-copy": "2.1.1",
"esbuild-runner": "2.2.2",
"esbuild-sass-plugin": "2.16.1",
Expand Down
Loading