Skip to content

Commit

Permalink
Stop esbuild in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoz committed Nov 26, 2022
1 parent 5153d5e commit 7f00c90
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 28 deletions.
Expand Up @@ -2,20 +2,30 @@

const { typecheckPlugin } = require('../../../lib');
const { build } = require('esbuild');
const path = require('path');

build({
absWorkingDir: __dirname,
entryPoints: ['./three.ts'],
bundle: true,
format: 'esm',
outdir: './dist',
platform: 'node',
plugins: [
typecheckPlugin({
buildMode: process.env.BUILD_MODE,
}),
],
watch: !!process.env.WATCH,
write: false,
}).catch(() => process.exit(1));
async function main() {
try {
const result = await build({
absWorkingDir: __dirname,
entryPoints: ['./three.ts'],
bundle: true,
format: 'esm',
outdir: './dist',
platform: 'node',
plugins: [
typecheckPlugin({
buildMode: process.env.BUILD_MODE,
}),
],
watch: !!process.env.WATCH,
write: false,
});
process.on('SIGTERM', () => {
result.stop();
});
} catch (error) {
process.exit(1);
}
}

main();
34 changes: 22 additions & 12 deletions packages/esbuild-plugin-typecheck/test/fixture/compile/build.js
Expand Up @@ -2,16 +2,26 @@

const { typecheckPlugin } = require('../../lib');
const { build } = require('esbuild');
const path = require('path');

build({
absWorkingDir: __dirname,
entryPoints: ['./src/index.ts'],
bundle: true,
format: 'esm',
outdir: './dist',
platform: 'node',
plugins: [typecheckPlugin()],
watch: !!process.env.WATCH,
write: false,
}).catch(() => process.exit(1));
async function main() {
try {
const result = await build({
absWorkingDir: __dirname,
entryPoints: ['./src/index.ts'],
bundle: true,
format: 'esm',
outdir: './dist',
platform: 'node',
plugins: [typecheckPlugin()],
watch: !!process.env.WATCH,
write: false,
});
process.on('SIGTERM', () => {
result.stop();
});
} catch (error) {
process.exit(1);
}
}

main();

0 comments on commit 7f00c90

Please sign in to comment.