Skip to content

Commit

Permalink
Upgrade esbuild to 0.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vraravam committed Oct 23, 2024
1 parent e9251bc commit d764c03
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 146 deletions.
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.0.2",
"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

0 comments on commit d764c03

Please sign in to comment.