-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Switch to esbuild and bump versions
Remove rollup and webpack dependencies Bump ANTLR version Bump versions of dependencies Fix lint issues Gordon Smith<[email protected]>
- Loading branch information
1 parent
d88d3e9
commit 2cc9503
Showing
47 changed files
with
9,058 additions
and
11,191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]); | ||
|
Oops, something went wrong.