Skip to content

Commit a583836

Browse files
committed
feat: Switch to esbuild
Remove rollup and webpack dependencies Gordon Smith<[email protected]>
1 parent d88d3e9 commit a583836

16 files changed

+7403
-10568
lines changed

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
{
5757
"name": "Launch Web Extension",
58-
"type": "pwa-extensionHost",
58+
"type": "extensionHost",
5959
"debugWebWorkerHost": true,
6060
"request": "launch",
6161
"args": [
@@ -83,7 +83,7 @@
8383
},
8484
{
8585
"name": "webview-test",
86-
"type": "pwa-msedge",
86+
"type": "msedge",
8787
"request": "launch",
8888
"url": "file:///${workspaceRoot}/webview-test.html",
8989
"runtimeArgs": [
@@ -93,7 +93,7 @@
9393
},
9494
{
9595
"name": "index",
96-
"type": "pwa-msedge",
96+
"type": "msedge",
9797
"request": "launch",
9898
"url": "file:///${workspaceRoot}/index.html",
9999
"runtimeArgs": [
@@ -108,7 +108,7 @@
108108
"skipFiles": [
109109
"<node_internals>/**"
110110
],
111-
"type": "pwa-node"
111+
"type": "node"
112112
},
113113
{
114114
"name": "NLS Merge",
@@ -117,7 +117,7 @@
117117
"skipFiles": [
118118
"<node_internals>/**"
119119
],
120-
"type": "pwa-node"
120+
"type": "node"
121121
}
122122
]
123123
}

.vscode/tasks.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"type": "npm",
88
"label": "compile watch",
9-
"script": "compile-es6-watch",
9+
"script": "compile-esbuild-watch",
1010
"problemMatcher": [
1111
"$tsc-watch"
1212
],
@@ -16,8 +16,8 @@
1616
},
1717
{
1818
"type": "npm",
19-
"label": "bundle-ext watch",
20-
"script": "bundle-ext-watch",
19+
"label": "bundle-esbuild-dev watch",
20+
"script": "bundle-esbuild-dev-watch",
2121
"problemMatcher": [],
2222
"presentation": {
2323
"group": "group-build"
@@ -27,7 +27,7 @@
2727
"label": "build",
2828
"dependsOn": [
2929
"compile watch",
30-
"bundle-ext watch"
30+
"bundle-esbuild-dev watch"
3131
],
3232
"group": {
3333
"kind": "build",

esbuild.mjs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { context } from "esbuild";
2+
import process from "process";
3+
4+
const production = process.argv.includes("--production");
5+
const watch = process.argv.includes("--watch");
6+
7+
/**
8+
* @type {import('esbuild').Plugin}
9+
*/
10+
const esbuildProblemMatcherPlugin = {
11+
name: "esbuild-problem-matcher",
12+
13+
setup(build) {
14+
build.onStart(() => {
15+
console.log("[watch] build started");
16+
});
17+
build.onEnd((result) => {
18+
result.errors.forEach(({ text, location }) => {
19+
console.error(`✘ [ERROR] ${text}`);
20+
console.error(` ${location.file}:${location.line}:${location.column}:`);
21+
});
22+
console.log("[watch] build finished");
23+
});
24+
},
25+
};
26+
27+
async function extension() {
28+
const ctx = await context({
29+
entryPoints: [
30+
"src/extension.ts",
31+
"src/debugger.ts"
32+
],
33+
bundle: true,
34+
format: "cjs",
35+
minify: production,
36+
sourcemap: !production,
37+
sourcesContent: false,
38+
platform: "node",
39+
outdir: "dist",
40+
external: ["vscode"],
41+
// logLevel: "silent",
42+
plugins: [
43+
/* add to the end of plugins array */
44+
esbuildProblemMatcherPlugin,
45+
],
46+
});
47+
if (watch) {
48+
await ctx.watch();
49+
} else {
50+
await ctx.rebuild();
51+
await ctx.dispose();
52+
}
53+
}
54+
55+
async function notebook() {
56+
const ctx = await context({
57+
entryPoints: [
58+
"src/eclwatch.tsx",
59+
"src/notebook/renderers/wuRenderer.tsx",
60+
"src/notebook/renderers/ojsRenderer.ts"
61+
],
62+
bundle: true,
63+
format: "esm",
64+
minify: true,
65+
sourcemap: !production,
66+
sourcesContent: false,
67+
platform: "browser",
68+
outdir: "dist",
69+
external: ["vscode", "fs", "path", "os"],
70+
// logLevel: "silent",
71+
plugins: [
72+
/* add to the end of plugins array */
73+
esbuildProblemMatcherPlugin,
74+
],
75+
});
76+
if (watch) {
77+
await ctx.watch();
78+
} else {
79+
await ctx.rebuild();
80+
await ctx.dispose();
81+
}
82+
}
83+
84+
async function web_extension() {
85+
const ctx = await context({
86+
entryPoints: [
87+
"src/web-extension.ts"
88+
],
89+
bundle: true,
90+
format: "esm",
91+
minify: production,
92+
sourcemap: !production,
93+
sourcesContent: false,
94+
platform: "browser",
95+
outfile: "dist-web/extension.js",
96+
external: ["vscode", "fs", "path", "os"],
97+
// logLevel: "silent",
98+
plugins: [
99+
/* add to the end of plugins array */
100+
esbuildProblemMatcherPlugin,
101+
],
102+
});
103+
if (watch) {
104+
await ctx.watch();
105+
} else {
106+
await ctx.rebuild();
107+
await ctx.dispose();
108+
}
109+
}
110+
111+
Promise.all([extension(), notebook(), web_extension()])
112+
.then(() => {
113+
}).catch(e => {
114+
console.error(e);
115+
process.exit(1);
116+
});

0 commit comments

Comments
 (0)