Skip to content

Commit fce5805

Browse files
committed
Move esbuild configuration to build.mjs.
In preparation for Surfer webview integration.
1 parent 0b783ff commit fce5805

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

build.mjs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as esbuild from 'esbuild';
2+
3+
const mode = (process.argv[2] ?? 'build');
4+
5+
const commonOptions = {
6+
logLevel: 'info',
7+
bundle: true,
8+
target: 'es2021',
9+
sourcemap: 'linked',
10+
outdir: 'out/',
11+
};
12+
13+
const extensionContext = await esbuild.context({
14+
external: ['vscode'],
15+
format: 'cjs',
16+
platform: 'node',
17+
entryPoints: {
18+
'extension': './src/extension.ts',
19+
},
20+
...commonOptions
21+
});
22+
23+
if (mode === 'build') {
24+
await extensionContext.rebuild();
25+
await extensionContext.dispose();
26+
} else if (mode === 'watch') {
27+
await extensionContext.watch();
28+
} else {
29+
console.error(`Usage: ${process.argv0} [build|watch]`);
30+
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@
341341
"lint": "eslint --fix",
342342
"tsc": "tsc --project tsconfig.json",
343343
"tsc:watch": "npm run tsc -- --watch",
344-
"esbuild": "esbuild ./src/extension.ts --bundle --sourcemap --outdir=out/ --format=cjs --platform=node --external:vscode",
345-
"esbuild:watch": "npm run esbuild -- --watch",
344+
"esbuild": "node build.mjs build",
345+
"esbuild:watch": "node build.mjs watch",
346346
"vscode:prepublish": "npm run lint && npm run tsc && npm run esbuild",
347347
"package": "vsce package"
348348
},

0 commit comments

Comments
 (0)