Skip to content

Commit

Permalink
Move esbuild configuration to build.mjs.
Browse files Browse the repository at this point in the history
In preparation for Surfer webview integration.
  • Loading branch information
whitequark committed Dec 2, 2024
1 parent 0b783ff commit fce5805
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as esbuild from 'esbuild';

const mode = (process.argv[2] ?? 'build');

const commonOptions = {
logLevel: 'info',
bundle: true,
target: 'es2021',
sourcemap: 'linked',
outdir: 'out/',
};

const extensionContext = await esbuild.context({
external: ['vscode'],
format: 'cjs',
platform: 'node',
entryPoints: {
'extension': './src/extension.ts',
},
...commonOptions
});

if (mode === 'build') {
await extensionContext.rebuild();
await extensionContext.dispose();
} else if (mode === 'watch') {
await extensionContext.watch();
} else {
console.error(`Usage: ${process.argv0} [build|watch]`);
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@
"lint": "eslint --fix",
"tsc": "tsc --project tsconfig.json",
"tsc:watch": "npm run tsc -- --watch",
"esbuild": "esbuild ./src/extension.ts --bundle --sourcemap --outdir=out/ --format=cjs --platform=node --external:vscode",
"esbuild:watch": "npm run esbuild -- --watch",
"esbuild": "node build.mjs build",
"esbuild:watch": "node build.mjs watch",
"vscode:prepublish": "npm run lint && npm run tsc && npm run esbuild",
"package": "vsce package"
},
Expand Down

0 comments on commit fce5805

Please sign in to comment.