Skip to content

Commit

Permalink
Merge pull request #428 from GordonSmith/ESBUILD
Browse files Browse the repository at this point in the history
feat:  Switch to esbuild and bump versions
  • Loading branch information
GordonSmith authored Jul 17, 2024
2 parents d88d3e9 + d839beb commit 88561b3
Show file tree
Hide file tree
Showing 16 changed files with 7,407 additions and 10,570 deletions.
10 changes: 5 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
{
"name": "Launch Web Extension",
"type": "pwa-extensionHost",
"type": "extensionHost",
"debugWebWorkerHost": true,
"request": "launch",
"args": [
Expand Down Expand Up @@ -83,7 +83,7 @@
},
{
"name": "webview-test",
"type": "pwa-msedge",
"type": "msedge",
"request": "launch",
"url": "file:///${workspaceRoot}/webview-test.html",
"runtimeArgs": [
Expand All @@ -93,7 +93,7 @@
},
{
"name": "index",
"type": "pwa-msedge",
"type": "msedge",
"request": "launch",
"url": "file:///${workspaceRoot}/index.html",
"runtimeArgs": [
Expand All @@ -108,7 +108,7 @@
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
"type": "node"
},
{
"name": "NLS Merge",
Expand All @@ -117,7 +117,7 @@
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
"type": "node"
}
]
}
8 changes: 4 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"type": "npm",
"label": "compile watch",
"script": "compile-es6-watch",
"script": "compile-esbuild-watch",
"problemMatcher": [
"$tsc-watch"
],
Expand All @@ -16,8 +16,8 @@
},
{
"type": "npm",
"label": "bundle-ext watch",
"script": "bundle-ext-watch",
"label": "bundle-esbuild-dev watch",
"script": "bundle-esbuild-dev-watch",
"problemMatcher": [],
"presentation": {
"group": "group-build"
Expand All @@ -27,7 +27,7 @@
"label": "build",
"dependsOn": [
"compile watch",
"bundle-ext watch"
"bundle-esbuild-dev watch"
],
"group": {
"kind": "build",
Expand Down
116 changes: 116 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import { context } from "esbuild";
import process from "process";

const production = process.argv.includes("--production");
const watch = process.argv.includes("--watch");

/**
* @type {import('esbuild').Plugin}
*/
const esbuildProblemMatcherPlugin = {
name: "esbuild-problem-matcher",

setup(build) {
build.onStart(() => {
console.log("[watch] build started");
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log("[watch] build finished");
});
},
};

async function extension() {
const ctx = await context({
entryPoints: [
"src/extension.ts",
"src/debugger.ts"
],
bundle: true,
format: "cjs",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "node",
outdir: "dist",
external: ["vscode"],
// logLevel: "silent",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

async function notebook() {
const ctx = await context({
entryPoints: [
"src/eclwatch.tsx",
"src/notebook/renderers/wuRenderer.tsx",
"src/notebook/renderers/ojsRenderer.ts"
],
bundle: true,
format: "esm",
minify: true,
sourcemap: !production,
sourcesContent: false,
platform: "browser",
outdir: "dist",
external: ["vscode", "fs", "path", "os"],
// logLevel: "silent",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

async function web_extension() {
const ctx = await context({
entryPoints: [
"src/web-extension.ts"
],
bundle: true,
format: "esm",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "browser",
outfile: "dist-web/extension.js",
external: ["vscode", "fs", "path", "os"],
// logLevel: "silent",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

Promise.all([extension(), notebook(), web_extension()])
.then(() => {
}).catch(e => {
console.error(e);
process.exit(1);
});
Loading

0 comments on commit 88561b3

Please sign in to comment.