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

[teraslice-cli] Fix build:watch command #3877

Merged
merged 5 commits into from
Dec 17, 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
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
Loading