@hpcc-js/esbuild-plugins 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/build.ts +10 -10
- package/types/build.d.ts +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as s from"process";import{readFileSync as E}from"fs";import*as f from"path";import*as l from"esbuild";import{umdWrapper as b}from"esbuild-plugin-umd-wrapper";import F from"yargs";import{hideBin as J}from"yargs/helpers";function c(e){return{name:"rebuild-logger",setup(t){t.onStart(()=>{console.log("[watch] build started")}),t.onEnd(()=>{console.log(`Rebuilt ${e.outfile??"Unknown"}`)})}}}import{readFile as $}from"fs/promises";import{existsSync as j}from"fs";import{Base91 as v}from"@hpcc-js/wasm-base91";import{Zstd as S}from"@hpcc-js/wasm-zstd";function O(e,t,r){let o=r.length+8192<=t.length,n=j(e);return`${o?'import { decompress } from "fzstd";':""}
|
|
2
2
|
${n?`import wrapper from "${e}";`:""}
|
|
3
3
|
|
|
4
4
|
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\`{|}~"';
|
|
@@ -60,6 +60,6 @@ export function reset() {
|
|
|
60
60
|
if (g_module) {
|
|
61
61
|
g_module = undefined;
|
|
62
62
|
}
|
|
63
|
-
} `.trim()}async function _(e){let t=await v.load(),r=await S.load(),o=await $(e);e=e.replace(/\.js$/,".xxx");let n=e.replace(/\.wasm$/,".js"),
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==`,loader:"default"}))}}}function oe(){return{name:"problem-matcher",setup(e){e.onStart(()=>{console.log("[watch] build started")}),e.onEnd(t=>{t.errors.forEach(({text:r,location:o})=>{console.error(`\u2718 [ERROR] ${r}`),console.error(` ${o?.file}:${o?.line}:${o?.column}:`)}),console.log("[watch] build finished")})}}}export{W as NODE_CJS,L as NODE_MJS,
|
|
63
|
+
} `.trim()}async function _(e){let t=await v.load(),r=await S.load(),o=await $(e);e=e.replace(/\.js$/,".xxx");let n=e.replace(/\.wasm$/,".js"),i=t.encode(o),P=r.compress(o),B=t.encode(P);return O(n,i,B)}function u(){return{name:"sfx-wasm",setup(e){e.onLoad({filter:/\.wasm$/},async t=>({contents:await _(t.path),loader:"ts"}))}}}var x=F(J(s.argv));x.usage("Usage: node esbuild.mjs [options]").demandCommand(0,0).example("node esbuild.mjs --watch","Bundle and watch for changes").option("mode",{alias:"m",describe:"Build mode",choices:["development","production"],default:"production"}).option("w",{alias:"watch",describe:"Watch for changes",type:"boolean"}).help("h").alias("h","help").epilog("https://github.com/hpcc-systems/hpcc-js-wasm");var y=JSON.parse(E(f.join(s.cwd(),"./package.json"),"utf8")),L=y.type==="module"?"js":"mjs",W=y.type==="module"?"cjs":"js",w=await x.argv,a=w.mode==="development",m=!a,A=w.watch;function h(e){return a&&Array.isArray(e.entryPoints)&&console.log("Start: ",e.entryPoints[0],e.outfile),l.build({sourcemap:"linked",...e,plugins:[...e.plugins??[],u()]}).finally(()=>{a&&Array.isArray(e.entryPoints)&&console.log("Stop: ",e.entryPoints[0],e.outfile)})}async function R(e){return await h(e),l.context({sourcemap:"external",...e,plugins:[...e.plugins??[],c(e),u()]}).then(t=>t.watch())}function d(e){return A?R(e):h(e)}function g(e,t,r="esm",o,n,i=[]){return d({entryPoints:[e],outfile:`${t}.${r==="esm"?"js":`${r}.js`}`,platform:"browser",target:"es2022",format:r,globalName:o,bundle:!0,minify:m,external:i,plugins:r==="umd"?[b({libraryName:n})]:[]})}function U(e,t,r,o,n=[]){return Promise.all([g(e,t,"esm",r,o,n),g(e,t,"umd",r,o,n)])}function p(e,t,r="esm",o=[]){return d({entryPoints:[e],outfile:`${t}.${r==="esm"?L:W}`,platform:"node",target:"node20",format:r,bundle:!0,minify:m,external:o})}function q(e,t,r="esm",o,n,i=[]){return d({entryPoints:[e],outfile:`${t}.${r==="esm"?"js":"umd.js"}`,platform:"neutral",target:"es2022",format:r,globalName:o,bundle:!0,minify:m,external:i,plugins:r==="umd"?[b({libraryName:n})]:[]})}function G(e,t,r=[]){return Promise.all([p(e,t,"esm",r),p(e,t,"cjs",r)])}function H(e,t,r,o,n=[]){return Promise.all([U(e,t,r,o,n),p(e,t,"cjs",n)])}import{readFile as z}from"fs/promises";function te(e){return{name:"exclude-sourcemap",setup(t){t.onLoad({filter:e.filter},async r=>({contents:await z(r.path,"utf8")+`
|
|
64
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==`,loader:"default"}))}}}function oe(){return{name:"problem-matcher",setup(e){e.onStart(()=>{console.log("[watch] build started")}),e.onEnd(t=>{t.errors.forEach(({text:r,location:o})=>{console.error(`\u2718 [ERROR] ${r}`),console.error(` ${o?.file}:${o?.line}:${o?.column}:`)}),console.log("[watch] build finished")})}}}export{W as NODE_CJS,L as NODE_MJS,w as argv,H as bothTpl,U as browserBoth,g as browserTpl,h as build,d as buildWatch,te as excludeSourcemap,a as isDevelopment,m as isProduction,A as isWatch,q as neutralTpl,G as nodeBoth,p as nodeTpl,y as pkg,oe as problemMatcher,c as rebuildLogger,u as sfxWasm,R as watch,_ as wrap};
|
|
65
65
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/build.ts", "../src/rebuild-logger.ts", "../src/sfx-wrapper.ts", "../src/exclude-sourcemap.ts", "../src/problem-matcher.ts"],
|
|
4
|
-
"sourcesContent": ["import * as process from \"process\";\r\nimport { readFileSync } from \"fs\";\r\nimport * as path from \"path\";\r\nimport * as esbuild from \"esbuild\";\r\nimport type { BuildOptions, Format } from \"esbuild\";\r\nimport { umdWrapper } from \"esbuild-plugin-umd-wrapper\";\r\nimport yargs from \"yargs\";\r\nimport { hideBin } from \"yargs/helpers\";\r\nimport { rebuildLogger } from \"./rebuild-logger.ts\";\r\nimport { sfxWasm } from \"./sfx-wrapper.ts\";\r\n\r\nconst myYargs = yargs(hideBin(process.argv));\r\nmyYargs\r\n .usage(\"Usage: node esbuild.mjs [options]\")\r\n .demandCommand(0, 0)\r\n .example(\"node esbuild.mjs --watch\", \"Bundle and watch for changes\")\r\n .option(\"mode\", {\r\n alias: \"m\",\r\n describe: \"Build mode\",\r\n choices: [\"development\", \"production\"],\r\n default: \"production\"\r\n })\r\n .option(\"w\", {\r\n alias: \"watch\",\r\n describe: \"Watch for changes\",\r\n type: \"boolean\"\r\n })\r\n .help(\"h\")\r\n .alias(\"h\", \"help\")\r\n .epilog(\"https://github.com/hpcc-systems/hpcc-js-wasm\")\r\n ;\r\n\r\nexport const pkg = JSON.parse(readFileSync(path.join(process.cwd(), \"./package.json\"), \"utf8\"));\r\nexport const NODE_MJS = pkg.type === \"module\" ? \"js\" : \"mjs\";\r\nexport const NODE_CJS = pkg.type === \"module\" ? \"cjs\" : \"js\";\r\n\r\nexport const argv = await myYargs.argv;\r\nexport const isDevelopment = argv.mode === \"development\";\r\nexport const isProduction = !isDevelopment;\r\nexport const isWatch = argv.watch;\r\n\r\nexport function build(config: BuildOptions) {\r\n if (isDevelopment && Array.isArray(config.entryPoints)) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"Start: \", config.entryPoints[0], config.outfile);\r\n }\r\n return esbuild.build({\r\n sourcemap: \"linked\",\r\n ...config,\r\n plugins: [\r\n ...(config.plugins ?? []),\r\n sfxWasm()\r\n ]\r\n }).finally(() => {\r\n if (isDevelopment && Array.isArray(config.entryPoints)) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"Stop: \", config.entryPoints[0], config.outfile);\r\n }\r\n });\r\n}\r\n\r\nexport async function watch(config: BuildOptions) {\r\n await build(config);\r\n return esbuild.context({\r\n sourcemap: \"external\",\r\n ...config,\r\n plugins: [\r\n ...(config.plugins ?? []),\r\n rebuildLogger(config),\r\n sfxWasm()\r\n ]\r\n }).then(ctx => {\r\n return ctx.watch();\r\n });\r\n}\r\n\r\nexport function buildWatch(config: BuildOptions) {\r\n return isWatch ? watch(config) : build(config);\r\n}\r\n\r\nexport function browserTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? \"js\" : `${format}.js`}`,\r\n platform: \"browser\",\r\n target: \"es2022\",\r\n format: format as Format,\r\n globalName: format === \"umd\" ? undefined : globalName,\r\n bundle: true,\r\n minify: isProduction,\r\n external,\r\n plugins: format === \"umd\" ? [umdWrapper({ libraryName: globalName })] : []\r\n });\r\n}\r\n\r\nexport function browserBoth(input: string, output: string, globalName?: string, external: string[] = []) {\r\n return Promise.all([\r\n browserTpl(input, output, \"esm\", globalName, external),\r\n browserTpl(input, output, \"umd\", globalName, external)\r\n ]);\r\n}\r\n\r\nexport function nodeTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? NODE_MJS : NODE_CJS}`,\r\n platform: \"node\",\r\n target: \"node20\",\r\n format: format as Format,\r\n bundle: true,\r\n minify: isProduction,\r\n external\r\n });\r\n}\r\n\r\nexport function neutralTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? \"js\" : \"umd.js\"}`,\r\n platform: \"neutral\",\r\n target: \"es2022\",\r\n format: format as Format,\r\n globalName,\r\n bundle: true,\r\n minify: isProduction,\r\n external,\r\n plugins: format === \"umd\" ? [umdWrapper()] : []\r\n });\r\n}\r\n\r\nexport function nodeBoth(input: string, output: string, external: string[] = []) {\r\n return Promise.all([\r\n nodeTpl(input, output, \"esm\", external),\r\n nodeTpl(input, output, \"cjs\", external)\r\n ]);\r\n}\r\n\r\nexport function bothTpl(input: string, output: string, globalName?: string, external: string[] = []) {\r\n return Promise.all([\r\n browserBoth(input, output, globalName, external),\r\n nodeTpl(input, output, \"cjs\", external)\r\n ]);\r\n}\r\n", "import type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport interface RebuildLoggerOptions {\r\n outfile?: string;\r\n}\r\n\r\nexport function rebuildLogger(opts: RebuildLoggerOptions): Plugin {\r\n return {\r\n name: \"rebuild-logger\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onStart(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build started\");\r\n });\r\n\r\n build.onEnd(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(`Rebuilt ${opts.outfile ?? \"Unknown\"}`);\r\n });\r\n }\r\n };\r\n}\r\n", "import { readFile } from \"fs/promises\";\r\nimport { existsSync } from \"fs\";\r\nimport { Base91 } from \"@hpcc-js/wasm-base91\";\r\nimport { Zstd } from \"@hpcc-js/wasm-zstd\";\r\nimport type { Plugin, PluginBuild } from \"esbuild\";\r\n\r\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\r\n\r\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\r\n const wasmJsExists = existsSync(wasmJsPath);\r\n\r\n return `\\\r\n${compressed ? 'import { decompress } from \"fzstd\";' : \"\"}\r\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : \"\"}\r\n\r\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\r\n\r\nfunction decode(raw: string): Uint8Array {\r\n const len = raw.length;\r\n const ret: number[] = [];\r\n\r\n let b = 0;\r\n let n = 0;\r\n let v = -1;\r\n\r\n for (let i = 0; i < len; i++) {\r\n const p = table.indexOf(raw[i]);\r\n /* istanbul ignore next */\r\n if (p === -1) continue;\r\n if (v < 0) {\r\n v = p;\r\n } else {\r\n v += p * 91;\r\n b |= v << n;\r\n n += (v & 8191) > 88 ? 13 : 14;\r\n do {\r\n ret.push(b & 0xff);\r\n b >>= 8;\r\n n -= 8;\r\n } while (n > 7);\r\n v = -1;\r\n }\r\n }\r\n\r\n if (v > -1) {\r\n ret.push((b | v << n) & 0xff);\r\n }\r\n\r\n return new Uint8Array(ret);\r\n}\r\n\r\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\r\n\r\nlet g_module: Uint8Array | undefined;\r\nlet g_wasmBinary: Uint8Array | undefined;\r\nexport default function() {\r\n if (!g_wasmBinary) {\r\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\r\n }\r\n${!wasmJsExists ? `\\\r\n return g_wasmBinary;\r\n`: `\\\r\n if (!g_module) {\r\n g_module = wrapper({\r\n wasmBinary: g_wasmBinary,\r\n locateFile: undefined\r\n });\r\n }\r\n return g_module;\r\n`}\r\n}\r\n\r\nexport function reset() {\r\n if (g_module) {\r\n g_module = undefined;\r\n }\r\n} `.trim();\r\n}\r\n\r\nexport async function wrap(path: string) {\r\n const base91 = await Base91.load();\r\n const zstd = await Zstd.load();\r\n\r\n const wasm = await readFile(path);\r\n path = path.replace(/\\.js$/, \".xxx\");\r\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\r\n const base91Wasm = base91.encode(wasm);\r\n const compressedWasm = zstd.compress(wasm);\r\n const base91CompressedWasm = base91.encode(compressedWasm);\r\n\r\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\r\n}\r\n\r\nexport function sfxWasm(): Plugin {\r\n return {\r\n name: \"sfx-wasm\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\r\n return {\r\n contents: await wrap(args.path),\r\n loader: \"ts\",\r\n };\r\n });\r\n }\r\n };\r\n}\r\n", "import { readFile } from \"fs/promises\";\r\nimport type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport interface ExcludeSourcemapOptions {\r\n filter: RegExp;\r\n}\r\nexport function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {\r\n return {\r\n name: \"exclude-sourcemap\",\r\n\r\n setup(build: PluginBuild) {\r\n build.onLoad({ filter: opts.filter }, async args => {\r\n return {\r\n contents: await readFile(args.path, \"utf8\") + \"\\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==\",\r\n loader: \"default\",\r\n };\r\n });\r\n },\r\n };\r\n}\r\n", "import type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport function problemMatcher(): Plugin {\r\n return {\r\n name: \"problem-matcher\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onStart(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build started\");\r\n });\r\n\r\n build.onEnd((result) => {\r\n result.errors.forEach(({ text, location }) => {\r\n console.error(`\u2718 [ERROR] ${text}`);\r\n console.error(` ${location?.file}:${location?.line}:${location?.column}:`);\r\n });\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build finished\");\r\n });\r\n }\r\n };\r\n}\r\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAa,UACzB,OAAS,gBAAAC,MAAoB,KAC7B,UAAYC,MAAU,OACtB,UAAYC,MAAa,UAEzB,OAAS,cAAAC,MAAkB,6BAC3B,OAAOC,MAAW,QAClB,OAAS,WAAAC,MAAe,gBCDjB,SAASC,EAAcC,EAAoC,CAC9D,MAAO,CACH,KAAM,iBAEN,MAAMC,EAAoB,CAEtBA,EAAM,QAAQ,IAAM,CAEhB,QAAQ,IAAI,uBAAuB,CACvC,CAAC,EAEDA,EAAM,MAAM,IAAM,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AMF,EAAsB,CAC9C,aAAMD,EAAMC,CAAM,EACH,UAAQ,CACnB,UAAW,WACX,GAAGA,EACH,QAAS,CACL,GAAIA,EAAO,SAAW,CAAC,EACvBG,EAAcH,CAAM,EACpBC,EAAQ,CACZ,CACJ,CAAC,EAAE,KAAKG,GACGA,EAAI,MAAM,CACpB,CACL,CAEO,SAASC,EAAWL,EAAsB,CAC7C,OAAOF,EAAUI,EAAMF,CAAM,EAAID,EAAMC,CAAM,CACjD,CAEO,SAASM,EAAWC,EAAeC,EAAgBC,EAAyB,MAAOC,EAAqBC,EAAqB,CAAC,EAAG,
|
|
6
|
-
"names": ["process", "readFileSync", "path", "esbuild", "umdWrapper", "yargs", "hideBin", "rebuildLogger", "opts", "build", "readFile", "existsSync", "Base91", "Zstd", "tpl", "wasmJsPath", "base91Wasm", "base91CompressedWasm", "compressed", "wasmJsExists", "wrap", "path", "base91", "zstd", "wasm", "compressedWasm", "sfxWasm", "build", "args", "myYargs", "yargs", "hideBin", "pkg", "readFileSync", "NODE_MJS", "NODE_CJS", "argv", "isDevelopment", "isProduction", "isWatch", "build", "config", "sfxWasm", "watch", "rebuildLogger", "ctx", "buildWatch", "browserTpl", "input", "output", "format", "globalName", "external", "umdWrapper", "browserBoth", "nodeTpl", "neutralTpl", "nodeBoth", "bothTpl", "readFile", "excludeSourcemap", "opts", "build", "args", "problemMatcher", "build", "result", "text", "location"]
|
|
4
|
+
"sourcesContent": ["import * as process from \"process\";\r\nimport { readFileSync } from \"fs\";\r\nimport * as path from \"path\";\r\nimport * as esbuild from \"esbuild\";\r\nimport type { BuildOptions, Format } from \"esbuild\";\r\nimport { umdWrapper } from \"esbuild-plugin-umd-wrapper\";\r\nimport yargs from \"yargs\";\r\nimport { hideBin } from \"yargs/helpers\";\r\nimport { rebuildLogger } from \"./rebuild-logger.ts\";\r\nimport { sfxWasm } from \"./sfx-wrapper.ts\";\r\n\r\nconst myYargs = yargs(hideBin(process.argv));\r\nmyYargs\r\n .usage(\"Usage: node esbuild.mjs [options]\")\r\n .demandCommand(0, 0)\r\n .example(\"node esbuild.mjs --watch\", \"Bundle and watch for changes\")\r\n .option(\"mode\", {\r\n alias: \"m\",\r\n describe: \"Build mode\",\r\n choices: [\"development\", \"production\"],\r\n default: \"production\"\r\n })\r\n .option(\"w\", {\r\n alias: \"watch\",\r\n describe: \"Watch for changes\",\r\n type: \"boolean\"\r\n })\r\n .help(\"h\")\r\n .alias(\"h\", \"help\")\r\n .epilog(\"https://github.com/hpcc-systems/hpcc-js-wasm\")\r\n ;\r\n\r\nexport const pkg = JSON.parse(readFileSync(path.join(process.cwd(), \"./package.json\"), \"utf8\"));\r\nexport const NODE_MJS = pkg.type === \"module\" ? \"js\" : \"mjs\";\r\nexport const NODE_CJS = pkg.type === \"module\" ? \"cjs\" : \"js\";\r\n\r\nexport const argv = await myYargs.argv;\r\nexport const isDevelopment = argv.mode === \"development\";\r\nexport const isProduction = !isDevelopment;\r\nexport const isWatch = argv.watch;\r\n\r\nexport function build(config: BuildOptions) {\r\n if (isDevelopment && Array.isArray(config.entryPoints)) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"Start: \", config.entryPoints[0], config.outfile);\r\n }\r\n return esbuild.build({\r\n sourcemap: \"linked\",\r\n ...config,\r\n plugins: [\r\n ...(config.plugins ?? []),\r\n sfxWasm()\r\n ]\r\n }).finally(() => {\r\n if (isDevelopment && Array.isArray(config.entryPoints)) {\r\n // eslint-disable-next-line no-console\r\n console.log(\"Stop: \", config.entryPoints[0], config.outfile);\r\n }\r\n });\r\n}\r\n\r\nexport async function watch(config: BuildOptions) {\r\n await build(config);\r\n return esbuild.context({\r\n sourcemap: \"external\",\r\n ...config,\r\n plugins: [\r\n ...(config.plugins ?? []),\r\n rebuildLogger(config),\r\n sfxWasm()\r\n ]\r\n }).then(ctx => {\r\n return ctx.watch();\r\n });\r\n}\r\n\r\nexport function buildWatch(config: BuildOptions) {\r\n return isWatch ? watch(config) : build(config);\r\n}\r\n\r\nexport function browserTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, libraryName?: string, external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? \"js\" : `${format}.js`}`,\r\n platform: \"browser\",\r\n target: \"es2022\",\r\n format: format as Format,\r\n globalName,\r\n bundle: true,\r\n minify: isProduction,\r\n external,\r\n plugins: format === \"umd\" ? [umdWrapper({ libraryName })] : []\r\n });\r\n}\r\n\r\nexport function browserBoth(input: string, output: string, globalName?: string, libraryName?: string, external: string[] = []) {\r\n return Promise.all([\r\n browserTpl(input, output, \"esm\", globalName, libraryName, external),\r\n browserTpl(input, output, \"umd\", globalName, libraryName, external)\r\n ]);\r\n}\r\n\r\nexport function nodeTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? NODE_MJS : NODE_CJS}`,\r\n platform: \"node\",\r\n target: \"node20\",\r\n format: format as Format,\r\n bundle: true,\r\n minify: isProduction,\r\n external\r\n });\r\n}\r\n\r\nexport function neutralTpl(input: string, output: string, format: Format | \"umd\" = \"esm\", globalName?: string, libraryName?: string, external: string[] = []) {\r\n return buildWatch({\r\n entryPoints: [input],\r\n outfile: `${output}.${format === \"esm\" ? \"js\" : \"umd.js\"}`,\r\n platform: \"neutral\",\r\n target: \"es2022\",\r\n format: format as Format,\r\n globalName,\r\n bundle: true,\r\n minify: isProduction,\r\n external,\r\n plugins: format === \"umd\" ? [umdWrapper({ libraryName })] : []\r\n });\r\n}\r\n\r\nexport function nodeBoth(input: string, output: string, external: string[] = []) {\r\n return Promise.all([\r\n nodeTpl(input, output, \"esm\", external),\r\n nodeTpl(input, output, \"cjs\", external)\r\n ]);\r\n}\r\n\r\nexport function bothTpl(input: string, output: string, globalName?: string, libraryName?: string, external: string[] = []) {\r\n return Promise.all([\r\n browserBoth(input, output, globalName, libraryName, external),\r\n nodeTpl(input, output, \"cjs\", external)\r\n ]);\r\n}\r\n", "import type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport interface RebuildLoggerOptions {\r\n outfile?: string;\r\n}\r\n\r\nexport function rebuildLogger(opts: RebuildLoggerOptions): Plugin {\r\n return {\r\n name: \"rebuild-logger\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onStart(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build started\");\r\n });\r\n\r\n build.onEnd(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(`Rebuilt ${opts.outfile ?? \"Unknown\"}`);\r\n });\r\n }\r\n };\r\n}\r\n", "import { readFile } from \"fs/promises\";\r\nimport { existsSync } from \"fs\";\r\nimport { Base91 } from \"@hpcc-js/wasm-base91\";\r\nimport { Zstd } from \"@hpcc-js/wasm-zstd\";\r\nimport type { Plugin, PluginBuild } from \"esbuild\";\r\n\r\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\r\n\r\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\r\n const wasmJsExists = existsSync(wasmJsPath);\r\n\r\n return `\\\r\n${compressed ? 'import { decompress } from \"fzstd\";' : \"\"}\r\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : \"\"}\r\n\r\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\r\n\r\nfunction decode(raw: string): Uint8Array {\r\n const len = raw.length;\r\n const ret: number[] = [];\r\n\r\n let b = 0;\r\n let n = 0;\r\n let v = -1;\r\n\r\n for (let i = 0; i < len; i++) {\r\n const p = table.indexOf(raw[i]);\r\n /* istanbul ignore next */\r\n if (p === -1) continue;\r\n if (v < 0) {\r\n v = p;\r\n } else {\r\n v += p * 91;\r\n b |= v << n;\r\n n += (v & 8191) > 88 ? 13 : 14;\r\n do {\r\n ret.push(b & 0xff);\r\n b >>= 8;\r\n n -= 8;\r\n } while (n > 7);\r\n v = -1;\r\n }\r\n }\r\n\r\n if (v > -1) {\r\n ret.push((b | v << n) & 0xff);\r\n }\r\n\r\n return new Uint8Array(ret);\r\n}\r\n\r\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\r\n\r\nlet g_module: Uint8Array | undefined;\r\nlet g_wasmBinary: Uint8Array | undefined;\r\nexport default function() {\r\n if (!g_wasmBinary) {\r\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\r\n }\r\n${!wasmJsExists ? `\\\r\n return g_wasmBinary;\r\n`: `\\\r\n if (!g_module) {\r\n g_module = wrapper({\r\n wasmBinary: g_wasmBinary,\r\n locateFile: undefined\r\n });\r\n }\r\n return g_module;\r\n`}\r\n}\r\n\r\nexport function reset() {\r\n if (g_module) {\r\n g_module = undefined;\r\n }\r\n} `.trim();\r\n}\r\n\r\nexport async function wrap(path: string) {\r\n const base91 = await Base91.load();\r\n const zstd = await Zstd.load();\r\n\r\n const wasm = await readFile(path);\r\n path = path.replace(/\\.js$/, \".xxx\");\r\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\r\n const base91Wasm = base91.encode(wasm);\r\n const compressedWasm = zstd.compress(wasm);\r\n const base91CompressedWasm = base91.encode(compressedWasm);\r\n\r\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\r\n}\r\n\r\nexport function sfxWasm(): Plugin {\r\n return {\r\n name: \"sfx-wasm\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\r\n return {\r\n contents: await wrap(args.path),\r\n loader: \"ts\",\r\n };\r\n });\r\n }\r\n };\r\n}\r\n", "import { readFile } from \"fs/promises\";\r\nimport type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport interface ExcludeSourcemapOptions {\r\n filter: RegExp;\r\n}\r\nexport function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {\r\n return {\r\n name: \"exclude-sourcemap\",\r\n\r\n setup(build: PluginBuild) {\r\n build.onLoad({ filter: opts.filter }, async args => {\r\n return {\r\n contents: await readFile(args.path, \"utf8\") + \"\\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==\",\r\n loader: \"default\",\r\n };\r\n });\r\n },\r\n };\r\n}\r\n", "import type { PluginBuild, Plugin } from \"esbuild\";\r\n\r\nexport function problemMatcher(): Plugin {\r\n return {\r\n name: \"problem-matcher\",\r\n\r\n setup(build: PluginBuild) {\r\n\r\n build.onStart(() => {\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build started\");\r\n });\r\n\r\n build.onEnd((result) => {\r\n result.errors.forEach(({ text, location }) => {\r\n console.error(`\u2718 [ERROR] ${text}`);\r\n console.error(` ${location?.file}:${location?.line}:${location?.column}:`);\r\n });\r\n // eslint-disable-next-line no-console\r\n console.log(\"[watch] build finished\");\r\n });\r\n }\r\n };\r\n}\r\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAa,UACzB,OAAS,gBAAAC,MAAoB,KAC7B,UAAYC,MAAU,OACtB,UAAYC,MAAa,UAEzB,OAAS,cAAAC,MAAkB,6BAC3B,OAAOC,MAAW,QAClB,OAAS,WAAAC,MAAe,gBCDjB,SAASC,EAAcC,EAAoC,CAC9D,MAAO,CACH,KAAM,iBAEN,MAAMC,EAAoB,CAEtBA,EAAM,QAAQ,IAAM,CAEhB,QAAQ,IAAI,uBAAuB,CACvC,CAAC,EAEDA,EAAM,MAAM,IAAM,CAEd,QAAQ,IAAI,WAAWD,EAAK,SAAW,SAAS,EAAE,CACtD,CAAC,CACL,CACJ,CACJ,CCvBA,OAAS,YAAAE,MAAgB,cACzB,OAAS,cAAAC,MAAkB,KAC3B,OAAS,UAAAC,MAAc,uBACvB,OAAS,QAAAC,MAAY,qBAGrB,SAASC,EAAIC,EAAoBC,EAAoBC,EAA8B,CAE/E,IAAMC,E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", "Base91", "Zstd", "tpl", "wasmJsPath", "base91Wasm", "base91CompressedWasm", "compressed", "wasmJsExists", "wrap", "path", "base91", "zstd", "wasm", "compressedWasm", "sfxWasm", "build", "args", "myYargs", "yargs", "hideBin", "pkg", "readFileSync", "NODE_MJS", "NODE_CJS", "argv", "isDevelopment", "isProduction", "isWatch", "build", "config", "sfxWasm", "watch", "rebuildLogger", "ctx", "buildWatch", "browserTpl", "input", "output", "format", "globalName", "libraryName", "external", "umdWrapper", "browserBoth", "nodeTpl", "neutralTpl", "nodeBoth", "bothTpl", "readFile", "excludeSourcemap", "opts", "build", "args", "problemMatcher", "build", "result", "text", "location"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -78,25 +78,25 @@ export function buildWatch(config: BuildOptions) {
|
|
|
78
78
|
return isWatch ? watch(config) : build(config);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export function browserTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, external: string[] = []) {
|
|
81
|
+
export function browserTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, libraryName?: string, external: string[] = []) {
|
|
82
82
|
return buildWatch({
|
|
83
83
|
entryPoints: [input],
|
|
84
84
|
outfile: `${output}.${format === "esm" ? "js" : `${format}.js`}`,
|
|
85
85
|
platform: "browser",
|
|
86
86
|
target: "es2022",
|
|
87
87
|
format: format as Format,
|
|
88
|
-
globalName
|
|
88
|
+
globalName,
|
|
89
89
|
bundle: true,
|
|
90
90
|
minify: isProduction,
|
|
91
91
|
external,
|
|
92
|
-
plugins: format === "umd" ? [umdWrapper({ libraryName
|
|
92
|
+
plugins: format === "umd" ? [umdWrapper({ libraryName })] : []
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
export function browserBoth(input: string, output: string, globalName?: string, external: string[] = []) {
|
|
96
|
+
export function browserBoth(input: string, output: string, globalName?: string, libraryName?: string, external: string[] = []) {
|
|
97
97
|
return Promise.all([
|
|
98
|
-
browserTpl(input, output, "esm", globalName, external),
|
|
99
|
-
browserTpl(input, output, "umd", globalName, external)
|
|
98
|
+
browserTpl(input, output, "esm", globalName, libraryName, external),
|
|
99
|
+
browserTpl(input, output, "umd", globalName, libraryName, external)
|
|
100
100
|
]);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -113,7 +113,7 @@ export function nodeTpl(input: string, output: string, format: Format | "umd" =
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export function neutralTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, external: string[] = []) {
|
|
116
|
+
export function neutralTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, libraryName?: string, external: string[] = []) {
|
|
117
117
|
return buildWatch({
|
|
118
118
|
entryPoints: [input],
|
|
119
119
|
outfile: `${output}.${format === "esm" ? "js" : "umd.js"}`,
|
|
@@ -124,7 +124,7 @@ export function neutralTpl(input: string, output: string, format: Format | "umd"
|
|
|
124
124
|
bundle: true,
|
|
125
125
|
minify: isProduction,
|
|
126
126
|
external,
|
|
127
|
-
plugins: format === "umd" ? [umdWrapper()] : []
|
|
127
|
+
plugins: format === "umd" ? [umdWrapper({ libraryName })] : []
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -135,9 +135,9 @@ export function nodeBoth(input: string, output: string, external: string[] = [])
|
|
|
135
135
|
]);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
export function bothTpl(input: string, output: string, globalName?: string, external: string[] = []) {
|
|
138
|
+
export function bothTpl(input: string, output: string, globalName?: string, libraryName?: string, external: string[] = []) {
|
|
139
139
|
return Promise.all([
|
|
140
|
-
browserBoth(input, output, globalName, external),
|
|
140
|
+
browserBoth(input, output, globalName, libraryName, external),
|
|
141
141
|
nodeTpl(input, output, "cjs", external)
|
|
142
142
|
]);
|
|
143
143
|
}
|
package/types/build.d.ts
CHANGED
|
@@ -180,7 +180,7 @@ export declare function buildWatch(config: BuildOptions): Promise<void> | Promis
|
|
|
180
180
|
logOverride?: Record<string, esbuild.LogLevel>;
|
|
181
181
|
tsconfigRaw?: string | esbuild.TsconfigRaw;
|
|
182
182
|
}>>;
|
|
183
|
-
export declare function browserTpl(input: string, output: string, format?: Format | "umd", globalName?: string, external?: string[]): Promise<void> | Promise<esbuild.BuildResult<{
|
|
183
|
+
export declare function browserTpl(input: string, output: string, format?: Format | "umd", globalName?: string, libraryName?: string, external?: string[]): Promise<void> | Promise<esbuild.BuildResult<{
|
|
184
184
|
plugins: esbuild.Plugin[];
|
|
185
185
|
bundle?: boolean;
|
|
186
186
|
splitting?: boolean;
|
|
@@ -262,7 +262,7 @@ export declare function browserTpl(input: string, output: string, format?: Forma
|
|
|
262
262
|
logOverride?: Record<string, esbuild.LogLevel>;
|
|
263
263
|
tsconfigRaw?: string | esbuild.TsconfigRaw;
|
|
264
264
|
}>>;
|
|
265
|
-
export declare function browserBoth(input: string, output: string, globalName?: string, external?: string[]): Promise<[void | esbuild.BuildResult<{
|
|
265
|
+
export declare function browserBoth(input: string, output: string, globalName?: string, libraryName?: string, external?: string[]): Promise<[void | esbuild.BuildResult<{
|
|
266
266
|
plugins: esbuild.Plugin[];
|
|
267
267
|
bundle?: boolean;
|
|
268
268
|
splitting?: boolean;
|
|
@@ -507,7 +507,7 @@ export declare function nodeTpl(input: string, output: string, format?: Format |
|
|
|
507
507
|
logOverride?: Record<string, esbuild.LogLevel>;
|
|
508
508
|
tsconfigRaw?: string | esbuild.TsconfigRaw;
|
|
509
509
|
}>>;
|
|
510
|
-
export declare function neutralTpl(input: string, output: string, format?: Format | "umd", globalName?: string, external?: string[]): Promise<void> | Promise<esbuild.BuildResult<{
|
|
510
|
+
export declare function neutralTpl(input: string, output: string, format?: Format | "umd", globalName?: string, libraryName?: string, external?: string[]): Promise<void> | Promise<esbuild.BuildResult<{
|
|
511
511
|
plugins: esbuild.Plugin[];
|
|
512
512
|
bundle?: boolean;
|
|
513
513
|
splitting?: boolean;
|
|
@@ -752,7 +752,7 @@ export declare function nodeBoth(input: string, output: string, external?: strin
|
|
|
752
752
|
logOverride?: Record<string, esbuild.LogLevel>;
|
|
753
753
|
tsconfigRaw?: string | esbuild.TsconfigRaw;
|
|
754
754
|
}>]>;
|
|
755
|
-
export declare function bothTpl(input: string, output: string, globalName?: string, external?: string[]): Promise<[[void | esbuild.BuildResult<{
|
|
755
|
+
export declare function bothTpl(input: string, output: string, globalName?: string, libraryName?: string, external?: string[]): Promise<[[void | esbuild.BuildResult<{
|
|
756
756
|
plugins: esbuild.Plugin[];
|
|
757
757
|
bundle?: boolean;
|
|
758
758
|
splitting?: boolean;
|