Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch to esbuild and bump versions #428

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading