Skip to content

Commit

Permalink
feat: Switch to esbuild and bump versions
Browse files Browse the repository at this point in the history
Remove rollup and webpack dependencies
Bump ANTLR version
Bump versions of dependencies
Fix lint issues

Gordon Smith<[email protected]>
  • Loading branch information
GordonSmith committed Aug 21, 2024
1 parent d88d3e9 commit 2cc9503
Show file tree
Hide file tree
Showing 47 changed files with 9,058 additions and 11,191 deletions.
10 changes: 6 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
"@typescript-eslint"
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],
env: {
"browser": true,
Expand All @@ -20,7 +21,7 @@ module.exports = {
"debugConfig": "readonly",
"Promise": "readonly"
},
ignorePatterns: ["src/grammar"],
ignorePatterns: ["src/grammar/**/*"],
rules: {
"no-redeclare": "off",
"no-empty": "off",
Expand Down Expand Up @@ -92,6 +93,7 @@ module.exports = {
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-var-require": "off"
"@typescript-eslint/no-var-require": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
}
};
};
6 changes: 6 additions & 0 deletions .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check
if: ${{ github.repository_owner != 'hpcc-systems' }}
run: |
echo "Not hpcc-systems repository"
exit 1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pull-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20.x"
- run: git submodule update --init --recursive
- run: npm ci
- run: npm run lint
- run: npm run vsce-package;
- run: npm run vsce-package
26 changes: 21 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 All @@ -66,6 +66,15 @@
"${workspaceFolder}/dist/**/*.js"
]
},
{
"name": "Launch esbuild.mjs",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/esbuild.mjs",
"args": [
"--mode=development"
],
},
{
"name": "Launch Server Adapter",
"type": "node",
Expand All @@ -83,17 +92,24 @@
},
{
"name": "webview-test",
"type": "pwa-msedge",
"type": "msedge",
"request": "launch",
"url": "file:///${workspaceRoot}/webview-test.html",
"runtimeArgs": [
"--disable-web-security"
],
"webRoot": "${workspaceRoot}"
},
{
"name": "http://webview-test",
"type": "msedge",
"request": "launch",
"url": "http://localhost:8000/webview-test.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "index",
"type": "pwa-msedge",
"type": "msedge",
"request": "launch",
"url": "file:///${workspaceRoot}/index.html",
"runtimeArgs": [
Expand All @@ -108,7 +124,7 @@
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
"type": "node"
},
{
"name": "NLS Merge",
Expand All @@ -117,7 +133,7 @@
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
"type": "node"
}
]
}
24 changes: 18 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"tasks": [
{
"type": "npm",
"label": "compile watch",
"script": "compile-es6-watch",
"label": "gen-node-watch",
"script": "gen-node-watch",
"problemMatcher": [
"$tsc-watch"
],
Expand All @@ -16,8 +16,19 @@
},
{
"type": "npm",
"label": "bundle-ext watch",
"script": "bundle-ext-watch",
"label": "gen-webview-watch",
"script": "gen-webview-watch",
"problemMatcher": [
"$tsc-watch"
],
"presentation": {
"group": "group-build"
}
},
{
"type": "npm",
"label": "build-ts-watch",
"script": "build-ts-watch",
"problemMatcher": [],
"presentation": {
"group": "group-build"
Expand All @@ -26,8 +37,9 @@
{
"label": "build",
"dependsOn": [
"compile watch",
"bundle-ext watch"
"gen-node-watch",
"gen-webview-watch",
"build-ts-watch"
],
"group": {
"kind": "build",
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.28.0](https://github.com/hpcc-systems/vscode-ecl/compare/v2.27.0...v2.28.0) (2024-07-17)


### Features

* Switch to esbuild and bump versions ([406507d](https://github.com/hpcc-systems/vscode-ecl/commit/406507dc68bdf0ecd8eaf27c83216fd1887ad36e))

## [2.27.0](https://github.com/hpcc-systems/vscode-ecl/compare/v2.26.3...v2.27.0) (2024-04-23)


Expand Down
6 changes: 3 additions & 3 deletions ecl-sample/notebooks/test.eclnb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
{
"id": "330c54b6-328d-4c80-9f26-d856383a8a63",
"name": "",
"value": "x = 1;\r\nz = 2;\r\nx + z;",
"value": "x = 1;\r\nz = 2;\r\nx + z * 6;",
"mode": "js",
"shared": true,
"outputs": [
"eCA9IDE7DQp6ID0gMjsNCnggKyB6Ow=="
"eCA9IDE7DQp6ID0gMjsNCnggKyB6ICogNjs="
]
},
{
Expand Down Expand Up @@ -37,7 +37,7 @@
"mode": "ecl",
"shared": true,
"outputs": [
"UGFyZW50RXh0cmFjdGVkID0gW3sibmFtZWlkIjoxLCJuYW1lIjoiR2F2aW4gICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6MiwibmFtZSI6IkxpeiAgICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjMsIm5hbWUiOiJNciBOb2JvZHkgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJuYW1lIjoiQW55d2hlcmUgICAgICAgICAgICAifV07UGFyZW50RGF0YVJlYWR5ID0gW3sibmFtZWlkIjoxLCJuYW1lIjoiR2F2aW4gICAgICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX0seyJuYW1laWQiOjIsIm5hbWUiOiJMaXogICAgICAgICAgICAgICAgICIsIm51bXJvd3MiOjAsImNoaWxkcmVuIjp7IlJvdyI6W119fSx7Im5hbWVpZCI6MywibmFtZSI6Ik1yIE5vYm9keSAgICAgICAgICAgIiwibnVtcm93cyI6MCwiY2hpbGRyZW4iOnsiUm93IjpbXX19LHsibmFtZWlkIjo0LCJuYW1lIjoiQW55d2hlcmUgICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX1dO05lc3RlZENoaWxkRGF0YXNldCA9IFt7Im5hbWVpZCI6MSwibmFtZSI6IkdhdmluICAgICAgICAgICAgICAgIiwibnVtcm93cyI6MSwiY2hpbGRyZW4iOnsiUm93IjpbeyJuYW1laWQiOjEsImFkZHIiOiIxMCBNYWx0IExhbmUgICAgICAgICJ9XX19LHsibmFtZWlkIjoyLCJuYW1lIjoiTGl6ICAgICAgICAgICAgICAgICAiLCJudW1yb3dzIjoyLCJjaGlsZHJlbiI6eyJSb3ciOlt7Im5hbWVpZCI6MiwiYWRkciI6IjEwIE1hbHQgTGFuZSAgICAgICAgIn0seyJuYW1laWQiOjIsImFkZHIiOiIzIFRoZSBjb3R0YWdlcyAgICAgICJ9XX19LHsibmFtZWlkIjozLCJuYW1lIjoiTXIgTm9ib2R5ICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX0seyJuYW1laWQiOjQsIm5hbWUiOiJBbnl3aGVyZSAgICAgICAgICAgICIsIm51bXJvd3MiOjQsImNoaWxkcmVuIjp7IlJvdyI6W3sibmFtZWlkIjo0LCJhZGRyIjoiSGVyZSAgICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6NCwiYWRkciI6IlRoZXJlICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJOZWFyICAgICAgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJhZGRyIjoiRmFyICAgICAgICAgICAgICAgICAifV19fV07Q2hpbGRyZW5FeHRyYWN0ZWQgPSBbeyJuYW1laWQiOjEsImFkZHIiOiIxMCBNYWx0IExhbmUgICAgICAgICJ9LHsibmFtZWlkIjoyLCJhZGRyIjoiMTAgTWFsdCBMYW5lICAgICAgICAifSx7Im5hbWVpZCI6MiwiYWRkciI6IjMgVGhlIGNvdHRhZ2VzICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJIZXJlICAgICAgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJhZGRyIjoiVGhlcmUgICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6NCwiYWRkciI6Ik5lYXIgICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJGYXIgICAgICAgICAgICAgICAgICJ9XTs="
"UGFyZW50RGF0YVJlYWR5ID0gW3sibmFtZWlkIjoxLCJuYW1lIjoiR2F2aW4gICAgICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX0seyJuYW1laWQiOjIsIm5hbWUiOiJMaXogICAgICAgICAgICAgICAgICIsIm51bXJvd3MiOjAsImNoaWxkcmVuIjp7IlJvdyI6W119fSx7Im5hbWVpZCI6MywibmFtZSI6Ik1yIE5vYm9keSAgICAgICAgICAgIiwibnVtcm93cyI6MCwiY2hpbGRyZW4iOnsiUm93IjpbXX19LHsibmFtZWlkIjo0LCJuYW1lIjoiQW55d2hlcmUgICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX1dO05lc3RlZENoaWxkRGF0YXNldCA9IFt7Im5hbWVpZCI6MSwibmFtZSI6IkdhdmluICAgICAgICAgICAgICAgIiwibnVtcm93cyI6MSwiY2hpbGRyZW4iOnsiUm93IjpbeyJuYW1laWQiOjEsImFkZHIiOiIxMCBNYWx0IExhbmUgICAgICAgICJ9XX19LHsibmFtZWlkIjoyLCJuYW1lIjoiTGl6ICAgICAgICAgICAgICAgICAiLCJudW1yb3dzIjoyLCJjaGlsZHJlbiI6eyJSb3ciOlt7Im5hbWVpZCI6MiwiYWRkciI6IjEwIE1hbHQgTGFuZSAgICAgICAgIn0seyJuYW1laWQiOjIsImFkZHIiOiIzIFRoZSBjb3R0YWdlcyAgICAgICJ9XX19LHsibmFtZWlkIjozLCJuYW1lIjoiTXIgTm9ib2R5ICAgICAgICAgICAiLCJudW1yb3dzIjowLCJjaGlsZHJlbiI6eyJSb3ciOltdfX0seyJuYW1laWQiOjQsIm5hbWUiOiJBbnl3aGVyZSAgICAgICAgICAgICIsIm51bXJvd3MiOjQsImNoaWxkcmVuIjp7IlJvdyI6W3sibmFtZWlkIjo0LCJhZGRyIjoiSGVyZSAgICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6NCwiYWRkciI6IlRoZXJlICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJOZWFyICAgICAgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJhZGRyIjoiRmFyICAgICAgICAgICAgICAgICAifV19fV07UGFyZW50RXh0cmFjdGVkID0gW3sibmFtZWlkIjoxLCJuYW1lIjoiR2F2aW4gICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6MiwibmFtZSI6IkxpeiAgICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjMsIm5hbWUiOiJNciBOb2JvZHkgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJuYW1lIjoiQW55d2hlcmUgICAgICAgICAgICAifV07Q2hpbGRyZW5FeHRyYWN0ZWQgPSBbeyJuYW1laWQiOjEsImFkZHIiOiIxMCBNYWx0IExhbmUgICAgICAgICJ9LHsibmFtZWlkIjoyLCJhZGRyIjoiMTAgTWFsdCBMYW5lICAgICAgICAifSx7Im5hbWVpZCI6MiwiYWRkciI6IjMgVGhlIGNvdHRhZ2VzICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJIZXJlICAgICAgICAgICAgICAgICJ9LHsibmFtZWlkIjo0LCJhZGRyIjoiVGhlcmUgICAgICAgICAgICAgICAifSx7Im5hbWVpZCI6NCwiYWRkciI6Ik5lYXIgICAgICAgICAgICAgICAgIn0seyJuYW1laWQiOjQsImFkZHIiOiJGYXIgICAgICAgICAgICAgICAgICJ9XTs="
]
},
{
Expand Down
165 changes: 165 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import * as esbuild from "esbuild";
import copyStaticFiles from "esbuild-copy-static-files";
import process from "node:process";
import path from "node:path";
import { writeFileSync } from "node:fs";
import tsconfigNode from "./tsconfig.json" with {"type": "json"};
import tsconfigBrowser from "./tsconfig.webview.json" with {"type": "json"};

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

async function main(tsconfigRaw, entryPoint, platform, format, plugins = []) {
const ctx = await esbuild.context({
tsconfigRaw,
entryPoints: [entryPoint],
outdir: outputDirectory,
bundle: true,
format,
minify: production,
sourcemap: !production ? "linked" : false,
platform,
target: platform === "node" ? "node20" : "es2022",
external: ["vscode", "fs", "path", "os"],
// mainFields: platform === "node" ? ["main", "module"] : undefined, // https://github.com/microsoft/node-jsonc-parser/issues/57
logLevel: production ? "silent" : "info",
// write: !plugins.some(p => p.name === "replace-after-transform"),
plugins: [
...plugins,
esbuildProblemMatcherPlugin,
]
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

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");
});
},
};

function replaceAfterTransform() {
return {
name: "replace-after-transform",
setup(build) {
build.initialOptions.write = false;
build.onEnd((result) => {
result?.outputFiles?.forEach(file => {
if (file.path.endsWith(".js")) {
const contents = file.text.replace(/"use strict";/g, "");
if (contents.indexOf("use strict") >= 0) {
console.error("use strict: ", file.path);
}
writeFileSync(file.path, contents, { encoding: "utf8" });
} else {
writeFileSync(file.path, file.contents, { encoding: "binary" });
}
});
});
}
};
}

Promise.all([
main(tsconfigNode, "./src/extension.ts", "node", "cjs", [
copyStaticFiles({
src: "./node_modules/@hpcc-js/ddl-shim/schema/v2.json",
dest: path.join(outputDirectory, "v2.json"),
})
]),
main(tsconfigBrowser, "./src/notebook/renderers/wuRenderer.tsx", "browser", "esm"),
main(tsconfigBrowser, "./src/notebook/renderers/ojsRenderer.ts", "browser", "esm"),
main(tsconfigBrowser, "./src/eclwatch.tsx", "browser", "iife", [replaceAfterTransform()]),
main(tsconfigBrowser, "./src/web-extension.ts", "browser", "iife")
]).catch((e) => {
console.error(e);
process.exit(1);
});

// import { writeFileSync } from "fs";
// import { buildWatch, isProduction } from "@hpcc-js/esbuild-plugins";
// import { aliasPath } from "esbuild-plugin-alias-path";

// export function nodeTpl(input, output, format = "esm", external = []) {
// return buildWatch({
// entryPoints: [input],
// outfile: `${output}.js`,
// platform: "node",
// target: "node20",
// format,
// bundle: true,
// minify: isProduction,
// sourcemap: "linked",
// external
// });
// }

// function replaceAfterTransform() {
// return {
// name: "replace-after-transform",
// setup(build) {
// build.onEnd((result) => {
// result?.outputFiles?.forEach(file => {
// if (file.path.endsWith(".js")) {
// const contents = file.text.replace(/"use strict";/g, "");
// if (contents.indexOf("use strict") >= 0) {
// console.error("use strict: ", file.path);
// }
// writeFileSync(file.path, contents, { encoding: "utf8" });
// } else {
// writeFileSync(file.path, file.contents, { encoding: "binary" });
// }
// });
// });
// }
// };
// }

// export function browserTpl(input, output, format = "esm", globalName = undefined, external = []) {
// return buildWatch({
// entryPoints: [input],
// outfile: `${output}.js`,
// platform: "browser",
// target: "es2022",
// format,
// globalName,
// bundle: true,
// minify: isProduction,
// sourcemap: "linked",
// external,
// write: false,
// plugins: [replaceAfterTransform()],
// });
// }

// // config ---
// nodeTpl("src/extension.ts", "dist/extension", "cjs", ["vscode", "fs"]);
// nodeTpl("src/notebook/renderers/wuRenderer.tsx", "dist/notebook/renderers/wuRenderer", "cjs", ["vscode", "fs", "path", "os"]);
// nodeTpl("src/notebook/renderers/ojsRenderer.ts", "dist/notebook/renderers/ojsRenderer", "cjs", ["vscode", "fs", "path", "os"]);
// nodeTpl("src/debugger.ts", "dist/debugger", "cjs", ["vscode"]);

// const ctx = await browserTpl("src/eclwatch.tsx", "dist/eclwatch", "iife");
// // if (isServe) {
// // ctx.serve({ servedir: "." }).then(({ host, port }) => {
// // console.log(`http://localhost:${port}`);
// // });
// // }
// // browserTpl("src/web-extension.ts", "dist-web/extension", "esm", undefined, ["vscode", "fs", "path", "os"]);

Loading

0 comments on commit 2cc9503

Please sign in to comment.