Skip to content

Commit

Permalink
[teraslice-cli] Fix build:watch command (#3877)
Browse files Browse the repository at this point in the history
This PR makes the following changes:

- Fixes an issue introduced in #3851 that breaks `build:watch` 
- This now properly compiles/bundles `teraslice-cli` on watch mode when
a change is made
  • Loading branch information
sotojn authored Dec 17, 2024
1 parent 46e19b8 commit cda74ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
],
"scripts": {
"prebuild": "./packages/xlucene-parser/scripts/generate-engine.js",
"build": "tsc --build --verbose && yarn workspace teraslice-cli build --verbose",
"build": "tsc --build --verbose",
"postbuild": "yarn workspace teraslice-cli postbuild",
"build:cleanup": "./scripts/build-cleanup.sh",
"build:doctor": "./scripts/build-doctor.sh",
"build:fix": "echo '[DEPRECATED], use yarn run build:doctor instead'",
"build:pkg": "./scripts/build-pkg.sh",
"build:watch": "yarn run build --watch",
"build:watch": "yarn run build --watch & yarn workspace teraslice-cli node build.js --watch",
"bump": "ts-scripts bump",
"docker:limit": "./scripts/docker-limit-check.sh",
"docker:listImages": "ts-scripts images list",
Expand Down
11 changes: 9 additions & 2 deletions packages/teraslice-cli/build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import esbuild from 'esbuild';

esbuild.build({
const ctx = await esbuild.context({
entryPoints: ['src/command.ts'],
outfile: 'dist/src/ts-cli.js', // Output file path
bundle: true,
Expand All @@ -9,4 +9,11 @@ esbuild.build({
sourcemap: false,
inject: ['cjs-to-esm.js'],
external: ['esbuild']
}).catch(() => process.exit(1));
});

if (process.argv.includes('--watch')) {
await ctx.watch();
} else {
await ctx.rebuild();
ctx.dispose();
}
5 changes: 3 additions & 2 deletions packages/teraslice-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
"dist/src/helpers/esm-shims.js"
],
"scripts": {
"build": "tsc --build && node build.js",
"build:watch": "tsc --build --watch",
"build": "tsc --build",
"postbuild": "node build.js",
"build:watch": "tsc --build --watch & node build.js --watch",
"test": "ts-scripts test . --",
"test:debug": "ts-scripts test --debug . --",
"test:watch": "ts-scripts test --watch . --"
Expand Down

0 comments on commit cda74ec

Please sign in to comment.