@hpcc-js/esbuild-plugins 1.4.3 → 1.4.4
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 +10 -10
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
- package/src/build.ts +17 -19
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import*as
|
|
2
|
-
if (!document.getElementById('${
|
|
1
|
+
import*as i from"process";import{readFileSync as y,existsSync as k,writeFileSync as C}from"fs";import*as c from"path";import*as h from"esbuild";import{umdWrapper as w}from"esbuild-plugin-umd-wrapper";import*as ne from"esbuild-copy-static-files";import B from"path";import N from"crypto";import{readFile as v}from"fs/promises";function g(t={}){return{name:"inline-css",setup(r){r.onLoad({filter:/\.(css)$/},async e=>{if(r.initialOptions.platform==="browser"){let n=B.resolve(e.path);return{contents:await E(n),loader:"js"}}})}}}async function E(t){let r=_(t),e=await v(t,"utf8");return`(function(){
|
|
2
|
+
if (!document.getElementById('${r}')) {
|
|
3
3
|
var e = document.createElement('style');
|
|
4
|
-
e.id = '${
|
|
4
|
+
e.id = '${r}';
|
|
5
5
|
e.textContent = \`${e.split("\\25").join("\\x15")}\`;
|
|
6
6
|
document.head.appendChild(e);
|
|
7
7
|
}
|
|
8
|
-
})();`}function
|
|
9
|
-
export const PKG_VERSION = "${
|
|
8
|
+
})();`}function _(t){return N.createHash("sha256").update(t).digest("hex").slice(0,8)}function x(t){return{name:"rebuild-logger",setup(r){r.onStart(()=>{console.log("[watch] build started")}),r.onEnd(()=>{console.log(`Rebuilt ${t.outfile??"Unknown"}`)})}}}var a=JSON.parse(y(c.join(i.cwd(),"./package.json"),"utf8")),L=a.type==="module"?"js":"mjs",F=a.type==="module"?"cjs":"js";async function p(t,r){let e=i.argv.includes("--development"),n=i.argv.includes("--watch"),s=!e;if(s&&k(c.join(i.cwd(),"../../package.json"))){let o=JSON.parse(y(c.join(i.cwd(),"../../package.json"),"utf8"));C(c.join(i.cwd(),"src/__package__.ts"),`export const PKG_NAME = "${a.name}";
|
|
9
|
+
export const PKG_VERSION = "${a.version}";
|
|
10
10
|
export const BUILD_VERSION = "${o.version}";
|
|
11
|
-
`,"utf8")}
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==`,loader:"default"}))}}}function
|
|
13
|
-
${s?`import wrapper from "${
|
|
11
|
+
`,"utf8")}r={entryPoints:t,format:"esm",bundle:!0,minify:s,sourcemap:!0,external:[...r.external??[]],...r,loader:{...r.loader},outExtension:{...r.outExtension},banner:{...r.banner},footer:{...r.footer},plugins:[...n?[x(r)]:[],...r.plugins??[],g()],nodePaths:[...r.nodePaths??[]]};let l=await h.context(r);n?await l.watch():(e&&Array.isArray(r.entryPoints)&&console.log("Start: ",r.entryPoints[0],r.outfile),await l.rebuild(),await l.dispose(),e&&Array.isArray(r.entryPoints)&&console.log("Stop: ",r.entryPoints[0],r.outfile))}function I(t){return[...a.dependencies?Object.keys(a.dependencies):[],...a.peerDependencies?Object.keys(a.peerDependencies):[],...t??[]]}function b(t,r,e={}){return e.format=e.format??"esm",p([t],{format:e.format==="umd"?"esm":e.format,external:e.external??[],outfile:`${r}.${e.format==="esm"?"js":`${e.format}.js`}`,platform:"browser",target:"es2022",globalName:e.globalName,keepNames:e.keepNames,plugins:e.format==="umd"?[...e.plugins??[],w({libraryName:e.libraryName})]:e.plugins,alias:e.alias,define:e.define,loader:e.loader,supported:e.supported})}function d(t,r,e={}){return e.format=e.format??"esm",e.packages=e.packages??"external",e.packages==="auto"&&(e.external=I(e.external)),p([t],{format:e.format==="umd"?"esm":e.format,external:e.external??[],outfile:`${r}.${e.format==="esm"?L:F}`,platform:"node",target:"node22",packages:e.packages==="auto"?"bundle":e.packages,globalName:e.globalName,keepNames:e.keepNames,plugins:e.plugins,alias:e.alias,define:e.define,loader:e.loader,supported:e.supported})}function ae(t,r,e={}){return e.format=e.format??"esm",p([t],{format:e.format==="umd"?"esm":e.format,external:e.external??[],outfile:`${r}.${e.format==="esm"?"js":`${e.format}.js`}`,platform:"neutral",target:"es2022",globalName:e.globalName,keepNames:e.keepNames,plugins:e.format==="umd"?[...e.plugins??[],w({libraryName:e.libraryName})]:e.plugins,alias:e.alias,define:e.define,loader:e.loader,supported:e.supported})}function J(t,r,e={}){return Promise.all([b(t,r,{format:"esm",...e}),b(t,r,{format:"umd",...e})])}function ie(t,r,e={}){return Promise.all([d(t,r,{format:"esm",...e}),d(t,r,{format:"cjs",...e})])}function le(t,r,e={}){return Promise.all([J(t,r,{...e}),d(t,r,{format:"cjs",...e})])}import{readFile as R}from"fs/promises";function ue(t){return{name:"exclude-sourcemap",setup(r){r.onLoad({filter:t.filter},async e=>({contents:await R(e.path,"utf8")+`
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==`,loader:"default"}))}}}function pe(){return{name:"problem-matcher",setup(t){t.onStart(()=>{console.log("[watch] build started")}),t.onEnd(r=>{r.errors.forEach(({text:e,location:n})=>{console.error(`\u2718 [ERROR] ${e}`),console.error(` ${n?.file}:${n?.line}:${n?.column}:`)}),console.log("[watch] build finished")})}}}import{writeFileSync as j}from"node:fs";function xe(){return{name:"remove-strict",setup(t){t.initialOptions.write=!1,t.onEnd(r=>{r?.outputFiles?.forEach(e=>{if(e.path.endsWith(".js")){let n=e.text.replace(/"use strict";/g,"");j(e.path,n,{encoding:"utf8"})}else j(e.path,e.contents,{encoding:"binary"})})})}}}import{readFile as A}from"fs/promises";import{existsSync as T}from"fs";import{Base91 as U}from"@hpcc-js/wasm-base91";import{Zstd as D}from"@hpcc-js/wasm-zstd";function W(t,r,e){let n=e.length+8192<=r.length,s=T(t);return`${n?'import { decompress } from "fzstd";':""}
|
|
13
|
+
${s?`import wrapper from "${t}";`:""}
|
|
14
14
|
|
|
15
15
|
const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\`{|}~"';
|
|
16
16
|
|
|
@@ -48,7 +48,7 @@ function decode(raw: string): Uint8Array {
|
|
|
48
48
|
return new Uint8Array(ret);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const blobStr = '${n?e:
|
|
51
|
+
const blobStr = '${n?e:r}';
|
|
52
52
|
|
|
53
53
|
let g_module: Uint8Array | undefined;
|
|
54
54
|
let g_wasmBinary: Uint8Array | undefined;
|
|
@@ -71,5 +71,5 @@ export function reset() {
|
|
|
71
71
|
if (g_module) {
|
|
72
72
|
g_module = undefined;
|
|
73
73
|
}
|
|
74
|
-
} `.trim()}async function z(
|
|
74
|
+
} `.trim()}async function z(t){let r=await U.load(),e=await D.load(),n=await A(t);t=t.replace(/\.js$/,".xxx");let s=t.replace(/\.wasm$/,".js"),l=r.encode(n),o=e.compress(n),u=r.encode(o);return W(s,l,u)}function Pe(){return{name:"sfx-wasm",setup(t){t.onLoad({filter:/\.wasm$/},async r=>({contents:await z(r.path),loader:"ts"}))}}}import{defineConfig as V}from"vite";import H from"vite-plugin-css-injected-by-js";import{viteStaticCopy as M}from"vite-plugin-static-copy";var G={"d3-array":"@hpcc-js/common","d3-brush":"@hpcc-js/common","d3-collection":"@hpcc-js/common","d3-color":"@hpcc-js/common","d3-dispatch":"@hpcc-js/common","d3-drag":"@hpcc-js/common","d3-dsv":"@hpcc-js/common","d3-ease":"@hpcc-js/common","d3-format":"@hpcc-js/common","d3-interpolate":"@hpcc-js/common","d3-scale":"@hpcc-js/common","d3-selection":"@hpcc-js/common","d3-time-format":"@hpcc-js/common","d3-transition":"@hpcc-js/common","d3-zoom":"@hpcc-js/common"};function K(t){let r=[],e={};for(let n in t.dependencies)r.push(n),e[n]=n;for(let n in t.peerDependencies??{})r.push(n),e[n]=n;return{alias:t.name!=="@hpcc-js/common"&&t.dependencies["@hpcc-js/common"]?G:{},external:r,globals:e}}function ve(t,r={}){let{external:e=[],plugins:n=[],includeFontAwesome:s=!1,entry:l="src/index.ts",configOverrides:o={}}=r,{alias:u,external:P,globals:O}=K(t),S=[...P,...e],f=[H({topExecutionPriority:!1}),...n];s&&f.push(M({targets:[{src:"../../node_modules/font-awesome/fonts",dest:"../font-awesome"},{src:"../../node_modules/font-awesome/css",dest:"../font-awesome"}]}));let $={build:{lib:{...{entry:l,name:t.name,fileName:"index"},...o.build?.lib||{}},rollupOptions:{external:S,output:{globals:O},...o.build?.rollupOptions||{}},sourcemap:!0,...o.build?Object.fromEntries(Object.entries(o.build).filter(([m])=>m!=="lib"&&m!=="rollupOptions")):{}},resolve:{alias:u,...o.resolve||{}},esbuild:{minifyIdentifiers:!1,...o.esbuild||{}},plugins:f,...Object.fromEntries(Object.entries(o).filter(([m])=>!["build","resolve","esbuild","plugins"].includes(m)))};return V($)}export{F as NODE_CJS,L as NODE_MJS,le as bothTpl,J as browserBoth,b as browserTpl,p as buildWatch,ne as copyStaticFiles,ve as createHpccViteConfig,ue as excludeSourcemap,K as hpccBundleNames,g as inlineCSS,ae as neutralTpl,ie as nodeBoth,d as nodeTpl,a as pkg,pe as problemMatcher,x as rebuildLogger,xe as removeStrict,Pe as sfxWasm,z as wrap};
|
|
75
75
|
//# 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/inline-css.ts", "../src/rebuild-logger.ts", "../src/exclude-sourcemap.ts", "../src/problem-matcher.ts", "../src/remove-strict.ts", "../src/sfx-wrapper.ts", "../src/vite-utils.ts"],
|
|
4
|
-
"sourcesContent": ["import * as process from \"process\";\nimport { readFileSync, existsSync, writeFileSync } from \"fs\";\nimport * as path from \"path\";\nimport * as esbuild from \"esbuild\";\nimport type { BuildOptions, Format, Loader, Plugin } from \"esbuild\";\nimport { umdWrapper } from \"esbuild-plugin-umd-wrapper\";\nimport * as copyStaticFiles from \"esbuild-copy-static-files\";\nimport { inlineCSS } from \"./inline-css.ts\";\nimport { rebuildLogger } from \"./rebuild-logger.ts\";\n\nexport { copyStaticFiles };\n\nexport const pkg = JSON.parse(readFileSync(path.join(process.cwd(), \"./package.json\"), \"utf8\"));\nexport const NODE_MJS = pkg.type === \"module\" ? \"js\" : \"mjs\";\nexport const NODE_CJS = pkg.type === \"module\" ? \"cjs\" : \"js\";\n\nexport async function buildWatch(inputs: string[] | Record<string, string> | { in: string, out: string }[], config: BuildOptions): Promise<void> {\n const isDevelopment = process.argv.includes(\"--development\");\n const isWatch = process.argv.includes(\"--watch\");\n const isProduction = !isDevelopment;\n\n if (isProduction && existsSync(path.join(process.cwd(), \"../../package.json\"))) {\n const rootPkg = JSON.parse(readFileSync(path.join(process.cwd(), \"../../package.json\"), \"utf8\"));\n writeFileSync(path.join(process.cwd(), \"src/__package__.ts\"), `\\\nexport const PKG_NAME = \"${pkg.name}\";\nexport const PKG_VERSION = \"${pkg.version}\";\nexport const BUILD_VERSION = \"${rootPkg.version}\";\n`, \"utf8\");\n }\n\n config = {\n entryPoints: inputs,\n format: \"esm\",\n bundle: true,\n minify: isProduction,\n sourcemap: true,\n external: [\n ...config.external ?? []\n ],\n ...config,\n loader: {\n ...config.loader\n },\n outExtension: {\n ...config.outExtension\n },\n banner: {\n ...config.banner\n },\n footer: {\n ...config.footer\n },\n plugins: [\n ...(isWatch ? [rebuildLogger(config)] : []),\n ...config.plugins ?? [],\n inlineCSS()\n ],\n nodePaths: [\n ...config.nodePaths ?? []\n ]\n };\n const ctx = await esbuild.context(config);\n\n if (isWatch) {\n await ctx.watch();\n } else {\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n // eslint-disable-next-line no-console\n console.log(\"Start: \", config.entryPoints[0], config.outfile);\n }\n await ctx.rebuild();\n await ctx.dispose();\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n // eslint-disable-next-line no-console\n console.log(\"Stop: \", config.entryPoints[0], config.outfile);\n }\n }\n}\n\nexport type TplOptions = {\n format?: Format | \"umd\";\n globalName?: string;\n libraryName?: string;\n keepNames?: boolean;\n external?: string[];\n plugins?: Plugin[];\n loader?: { [ext: string]: Loader };\n supported?: Record<string, boolean>;\n alias?: Record<string, string>;\n define?: { [key: string]: string };\n packages?: \"bundle\" | \"external\" | \"auto\";\n};\n\nfunction autoExternal(external?: string[]): string[] {\n return [\n ...pkg.dependencies ? Object.keys(pkg.dependencies) : [], ...pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],\n ...external ?? []\n ];\n}\n\nexport function browserTpl(input: string, output: string, options: TplOptions = {}) {\n options.format = options.format ?? \"esm\";\n\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n external: options.external ?? [],\n outfile: `${output}.${options.format === \"esm\" ? \"js\" : `${options.format}.js`}`,\n platform: \"browser\",\n target: \"es2022\",\n globalName: options.globalName,\n keepNames: options.keepNames,\n plugins: options.format === \"umd\" ? [umdWrapper({ libraryName: options.libraryName }), ...options.plugins ?? []] : [...options.plugins ?? []],\n alias: options.alias,\n define: options.define,\n loader: options.loader,\n });\n}\n\nexport function nodeTpl(input: string, output: string, options: TplOptions = {}) {\n options.packages = options.packages ?? \"external\";\n if (options.packages === \"auto\") {\n options.external = autoExternal(options.external);\n }\n\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n outfile: `${output}.${options.format === \"esm\" ? NODE_MJS : NODE_CJS}`,\n platform: \"node\",\n target: \"node22\",\n packages: options.packages === \"auto\" ? \"bundle\" : options.packages,\n });\n}\n\nexport function neutralTpl(input: string, output: string, options: TplOptions = {}) {\n options.format = options.format ?? \"esm\";\n\n let postfix = \"\";\n switch (options.format) {\n case \"iife\":\n postfix = \"iife.js\";\n break;\n case \"esm\":\n postfix = NODE_MJS;\n break;\n case \"cjs\":\n postfix = NODE_CJS;\n break;\n case \"umd\":\n postfix = \"umd.js\";\n break;\n default:\n throw new Error(`Unknown format: ${options.format}`);\n }\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n outfile: `${output}.${options.format === \"esm\" ? \"js\" : `${options.format}.js`}`,\n platform: \"neutral\",\n target: \"es2022\",\n globalName: options.globalName,\n keepNames: options.keepNames,\n plugins: options.format === \"umd\" ? [umdWrapper({ libraryName: options.libraryName })] : [] as Plugin[]\n });\n}\n\nexport function browserBoth(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n browserTpl(input, output, { format: \"esm\", ...options }),\n browserTpl(input, output, { format: \"umd\", ...options })\n ]);\n}\n\nexport function nodeBoth(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n nodeTpl(input, output, { format: \"esm\", ...options }),\n nodeTpl(input, output, { format: \"cjs\", ...options })\n ]);\n}\n\nexport function bothTpl(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n browserBoth(input, output, { ...options }),\n nodeTpl(input, output, { format: \"cjs\", ...options })\n ]);\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport function inlineCSS(options = {}) {\n return {\n name: \"inline-css\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.(css)$/ }, async (args) => {\n if (build.initialOptions.platform === \"browser\") {\n const sourcePath = path.resolve(args.path);\n const sourceJS = await generateInjectCSS(sourcePath);\n return {\n contents: sourceJS,\n loader: \"js\"\n };\n }\n });\n },\n };\n}\n\nasync function generateInjectCSS(sourcePath: string) {\n const styleID = sha256(sourcePath);\n const sourceCSS = await readFile(sourcePath, \"utf8\");\n\n return `(function(){\n if (!document.getElementById('${styleID}')) {\n var e = document.createElement('style');\n e.id = '${styleID}';\n e.textContent = \\`${sourceCSS.split(\"\\\\25\").join(\"\\\\x15\")}\\`;\n document.head.appendChild(e);\n }\n })();`;\n}\n\nfunction sha256(sourcePath: string) {\n const hash = crypto.createHash(\"sha256\").update(sourcePath).digest(\"hex\");\n return hash.slice(0, 8); // Use the first 8 characters of the hash\n}\n\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface RebuildLoggerOptions {\n outfile?: string;\n}\n\nexport function rebuildLogger(opts: RebuildLoggerOptions): Plugin {\n return {\n name: \"rebuild-logger\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n // eslint-disable-next-line no-console\n console.log(\"[watch] build started\");\n });\n\n build.onEnd(() => {\n // eslint-disable-next-line no-console\n console.log(`Rebuilt ${opts.outfile ?? \"Unknown\"}`);\n });\n }\n };\n}\n", "import { readFile } from \"fs/promises\";\nimport type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface ExcludeSourcemapOptions {\n filter: RegExp;\n}\nexport function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {\n return {\n name: \"exclude-sourcemap\",\n\n setup(build: PluginBuild) {\n build.onLoad({ filter: opts.filter }, async args => {\n return {\n contents: await readFile(args.path, \"utf8\") + \"\\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==\",\n loader: \"default\",\n };\n });\n },\n };\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport function problemMatcher(): Plugin {\n return {\n name: \"problem-matcher\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n // eslint-disable-next-line no-console\n console.log(\"[watch] build started\");\n });\n\n build.onEnd((result) => {\n result.errors.forEach(({ text, location }) => {\n console.error(`\u2718 [ERROR] ${text}`);\n console.error(` ${location?.file}:${location?.line}:${location?.column}:`);\n });\n // eslint-disable-next-line no-console\n console.log(\"[watch] build finished\");\n });\n }\n };\n}\n", "import { writeFileSync } from \"node:fs\";\nimport type { PluginBuild, Plugin } from \"esbuild\";\n\nexport function removeStrict(): Plugin {\n return {\n name: \"remove-strict\",\n setup(build: PluginBuild) {\n build.initialOptions.write = false;\n build.onEnd((result) => {\n result?.outputFiles?.forEach(file => {\n if (file.path.endsWith(\".js\")) {\n const contents = file.text.replace(/\"use strict\";/g, \"\");\n writeFileSync(file.path, contents, { encoding: \"utf8\" });\n } else {\n writeFileSync(file.path, file.contents, { encoding: \"binary\" });\n }\n });\n });\n }\n };\n}\n", "import { readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { Base91 } from \"@hpcc-js/wasm-base91\";\nimport { Zstd } from \"@hpcc-js/wasm-zstd\";\nimport type { Plugin, PluginBuild } from \"esbuild\";\n\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\n\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\n const wasmJsExists = existsSync(wasmJsPath);\n\n return `\\\n${compressed ? 'import { decompress } from \"fzstd\";' : \"\"}\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : \"\"}\n\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\n\nfunction decode(raw: string): Uint8Array {\n const len = raw.length;\n const ret: number[] = [];\n\n let b = 0;\n let n = 0;\n let v = -1;\n\n for (let i = 0; i < len; i++) {\n const p = table.indexOf(raw[i]);\n /* istanbul ignore next */\n if (p === -1) continue;\n if (v < 0) {\n v = p;\n } else {\n v += p * 91;\n b |= v << n;\n n += (v & 8191) > 88 ? 13 : 14;\n do {\n ret.push(b & 0xff);\n b >>= 8;\n n -= 8;\n } while (n > 7);\n v = -1;\n }\n }\n\n if (v > -1) {\n ret.push((b | v << n) & 0xff);\n }\n\n return new Uint8Array(ret);\n}\n\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\n\nlet g_module: Uint8Array | undefined;\nlet g_wasmBinary: Uint8Array | undefined;\nexport default function() {\n if (!g_wasmBinary) {\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\n }\n${!wasmJsExists ? `\\\n return g_wasmBinary;\n`: `\\\n if (!g_module) {\n g_module = wrapper({\n wasmBinary: g_wasmBinary,\n locateFile: undefined\n });\n }\n return g_module;\n`}\n}\n\nexport function reset() {\n if (g_module) {\n g_module = undefined;\n }\n} `.trim();\n}\n\nexport async function wrap(path: string) {\n const base91 = await Base91.load();\n const zstd = await Zstd.load();\n\n const wasm = await readFile(path);\n path = path.replace(/\\.js$/, \".xxx\");\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\n const base91Wasm = base91.encode(wasm);\n const compressedWasm = zstd.compress(wasm);\n const base91CompressedWasm = base91.encode(compressedWasm);\n\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\n}\n\nexport function sfxWasm(): Plugin {\n return {\n name: \"sfx-wasm\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\n return {\n contents: await wrap(args.path),\n loader: \"ts\",\n };\n });\n }\n };\n}\n", "import { defineConfig, UserConfig } from \"vite\";\nimport cssInjectedByJsPlugin from \"vite-plugin-css-injected-by-js\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nconst alias = {\n \"d3-array\": \"@hpcc-js/common\",\n \"d3-brush\": \"@hpcc-js/common\",\n \"d3-collection\": \"@hpcc-js/common\",\n \"d3-color\": \"@hpcc-js/common\",\n \"d3-dispatch\": \"@hpcc-js/common\",\n \"d3-drag\": \"@hpcc-js/common\",\n \"d3-dsv\": \"@hpcc-js/common\",\n \"d3-ease\": \"@hpcc-js/common\",\n \"d3-format\": \"@hpcc-js/common\",\n \"d3-interpolate\": \"@hpcc-js/common\",\n \"d3-scale\": \"@hpcc-js/common\",\n \"d3-selection\": \"@hpcc-js/common\",\n \"d3-time-format\": \"@hpcc-js/common\",\n \"d3-transition\": \"@hpcc-js/common\",\n \"d3-zoom\": \"@hpcc-js/common\"\n};\n\nexport function hpccBundleNames(pkg: any) {\n const external: string[] = [];\n const globals: { [id: string]: string } = {};\n for (const dep in pkg.dependencies) {\n external.push(dep);\n globals[dep] = dep;\n }\n for (const dep in pkg.peerDependencies ?? {}) {\n external.push(dep);\n globals[dep] = dep;\n }\n return { alias: (pkg.name !== \"@hpcc-js/common\" && pkg.dependencies[\"@hpcc-js/common\"]) ? alias : {}, external, globals };\n}\n\nexport interface ViteHpccConfigOptions {\n /**\n * Additional external items\n */\n external?: string[];\n /**\n * Additional plugins to include in the configuration\n */\n plugins?: any[];\n /**\n * Whether to include font-awesome static copy (used by @hpcc-js/common)\n */\n includeFontAwesome?: boolean;\n /**\n * Custom entry point (defaults to \"src/index.ts\")\n */\n entry?: string;\n /**\n * Additional vite config options to merge\n */\n configOverrides?: Partial<UserConfig>;\n}\n\n/**\n * Creates a standardized Vite configuration for HPCC-JS packages\n */\nexport function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions = {}): UserConfig {\n const {\n external: additionalExternal = [],\n plugins: additionalPlugins = [],\n includeFontAwesome = false,\n entry = \"src/index.ts\",\n configOverrides = {}\n } = options;\n\n const { alias, external, globals } = hpccBundleNames(pkg);\n const allExternals = [...external, ...additionalExternal];\n\n const allPlugins = [\n cssInjectedByJsPlugin({\n topExecutionPriority: false\n }),\n ...additionalPlugins\n ];\n\n if (includeFontAwesome) {\n allPlugins.push(\n viteStaticCopy({\n targets: [\n {\n src: \"../../node_modules/font-awesome/fonts\",\n dest: \"../font-awesome\"\n }, {\n src: \"../../node_modules/font-awesome/css\",\n dest: \"../font-awesome\",\n }\n ]\n })\n );\n }\n\n const defaultLibConfig = {\n entry,\n name: pkg.name,\n fileName: \"index\",\n };\n\n const config: UserConfig = {\n build: {\n lib: {\n ...defaultLibConfig,\n ...(configOverrides.build?.lib || {})\n },\n rollupOptions: {\n external: allExternals,\n output: {\n globals,\n },\n ...(configOverrides.build?.rollupOptions || {})\n },\n sourcemap: true,\n ...(configOverrides.build ? Object.fromEntries(Object.entries(configOverrides.build).filter(([key]) => key !== \"lib\" && key !== \"rollupOptions\")) : {})\n },\n resolve: {\n alias,\n ...(configOverrides.resolve || {})\n },\n esbuild: {\n minifyIdentifiers: false,\n ...(configOverrides.esbuild || {})\n },\n plugins: allPlugins,\n ...Object.fromEntries(Object.entries(configOverrides).filter(([key]) => ![\"build\", \"resolve\", \"esbuild\", \"plugins\"].includes(key)))\n };\n\n return defineConfig(config);\n}"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAa,UACzB,OAAS,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KACxD,UAAYC,MAAU,OACtB,UAAYC,MAAa,UAEzB,OAAS,cAAAC,MAAkB,6BAC3B,UAAYC,OAAqB,4BCLjC,OAAOC,MAAU,OACjB,OAAOC,MAAY,SACnB,OAAS,YAAAC,MAAgB,cAElB,SAASC,EAAUC,EAAU,CAAC,EAAG,CACpC,MAAO,CACH,KAAM,aAEN,MAAMC,EAAoB,CAEtBA,EAAM,OAAO,CAAE,OAAQ,UAAW,EAAG,MAAOC,GAAS,CACjD,GAAID,EAAM,eAAe,WAAa,UAAW,CAC7C,IAAME,EAAaP,EAAK,QAAQM,EAAK,IAAI,EAEzC,MAAO,CACH,SAFa,MAAME,EAAkBD,CAAU,EAG/C,OAAQ,IACZ,CACJ,CACJ,CAAC,CACL,CACJ,CACJ,CAEA,eAAeC,EAAkBD,EAAoB,CACjD,IAAME,EAAUC,EAAOH,CAAU,EAC3BI,EAAY,MAAMT,EAASK,EAAY,MAAM,EAEnD,MAAO;AAAA,wCAC6BE,CAAO;AAAA;AAAA,sBAEzBA,CAAO;AAAA,gCACGE,EAAU,MAAM,MAAM,EAAE,KAAK,OAAO,CAAC;AAAA;AAAA;AAAA,UAIrE,CAEA,SAASD,EAAOH,EAAoB,CAEhC,OADaN,EAAO,WAAW,QAAQ,EAAE,OAAOM,CAAU,EAAE,OAAO,KAAK,EAC5D,MAAM,EAAG,CAAC,CAC1B,CCpCO,SAASK,EAAcC,EAAoC,CAC9D,MAAO,CACH,KAAM,iBAEN,MAAMC,EAAoB,CAEtBA,EAAM,QAAQ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pCE,EACA,MAAMO,EAAI,MAAM,GAEZR,GAAiB,MAAM,QAAQD,EAAO,WAAW,GAEjD,QAAQ,IAAI,WAAYA,EAAO,YAAY,CAAC,EAAGA,EAAO,OAAO,EAEjE,MAAMS,EAAI,QAAQ,EAClB,MAAMA,EAAI,QAAQ,EACdR,GAAiB,MAAM,QAAQD,EAAO,WAAW,GAEjD,QAAQ,IAAI,WAAYA,EAAO,YAAY,CAAC,EAAGA,EAAO,OAAO,EAGzE,CAgBA,SAASU,EAAaC,EAA+B,CACjD,MAAO,CACH,GAAGjB,EAAI,aAAe,OAAO,KAAKA,EAAI,YAAY,EAAI,CAAC,EAAG,GAAGA,EAAI,iBAAmB,OAAO,KAAKA,EAAI,gBAAgB,EAAI,CAAC,EACzH,GAAGiB,GAAY,CAAC,CACpB,CACJ,CAEO,SAASC,EAAWC,EAAeC,EAAgBC,EAAsB,CAAC,EAAG,CAChF,OAAAA,EAAQ,OAASA,EAAQ,QAAU,MAE5BjB,EAAW,CAACe,CAAK,EAAG,CACvB,OAAQE,EAAQ,SAAW,MAAQ,MAAQA,EAAQ,OACnD,SAAUA,EAAQ,UAAY,CAAC,EAC/B,QAAS,GAAGD,CAAM,IAAIC,EAAQ,SAAW,MAAQ,KAAO,GAAGA,EAAQ,MAAM,KAAK,GAC9E,SAAU,UACV,OAAQ,SACR,WAAYA,EAAQ,WACpB,UAAWA,EAAQ,UACnB,QAASA,EAAQ,SAAW,MAAQ,
|
|
6
|
-
"names": ["process", "readFileSync", "existsSync", "writeFileSync", "path", "esbuild", "umdWrapper", "copyStaticFiles", "path", "crypto", "readFile", "inlineCSS", "options", "build", "args", "sourcePath", "generateInjectCSS", "styleID", "sha256", "sourceCSS", "rebuildLogger", "opts", "build", "pkg", "readFileSync", "NODE_MJS", "NODE_CJS", "buildWatch", "inputs", "config", "isDevelopment", "isWatch", "isProduction", "existsSync", "rootPkg", "writeFileSync", "rebuildLogger", "inlineCSS", "ctx", "autoExternal", "external", "browserTpl", "input", "output", "options", "umdWrapper", "nodeTpl", "neutralTpl", "
|
|
4
|
+
"sourcesContent": ["import * as process from \"process\";\nimport { readFileSync, existsSync, writeFileSync } from \"fs\";\nimport * as path from \"path\";\nimport * as esbuild from \"esbuild\";\nimport type { BuildOptions, Format, Loader, Plugin } from \"esbuild\";\nimport { umdWrapper } from \"esbuild-plugin-umd-wrapper\";\nimport * as copyStaticFiles from \"esbuild-copy-static-files\";\nimport { inlineCSS } from \"./inline-css.ts\";\nimport { rebuildLogger } from \"./rebuild-logger.ts\";\n\nexport { copyStaticFiles };\n\nexport const pkg = JSON.parse(readFileSync(path.join(process.cwd(), \"./package.json\"), \"utf8\"));\nexport const NODE_MJS = pkg.type === \"module\" ? \"js\" : \"mjs\";\nexport const NODE_CJS = pkg.type === \"module\" ? \"cjs\" : \"js\";\n\nexport async function buildWatch(inputs: string[] | Record<string, string> | { in: string, out: string }[], config: BuildOptions): Promise<void> {\n const isDevelopment = process.argv.includes(\"--development\");\n const isWatch = process.argv.includes(\"--watch\");\n const isProduction = !isDevelopment;\n\n if (isProduction && existsSync(path.join(process.cwd(), \"../../package.json\"))) {\n const rootPkg = JSON.parse(readFileSync(path.join(process.cwd(), \"../../package.json\"), \"utf8\"));\n writeFileSync(path.join(process.cwd(), \"src/__package__.ts\"), `\\\nexport const PKG_NAME = \"${pkg.name}\";\nexport const PKG_VERSION = \"${pkg.version}\";\nexport const BUILD_VERSION = \"${rootPkg.version}\";\n`, \"utf8\");\n }\n\n config = {\n entryPoints: inputs,\n format: \"esm\",\n bundle: true,\n minify: isProduction,\n sourcemap: true,\n external: [\n ...config.external ?? []\n ],\n ...config,\n loader: {\n ...config.loader\n },\n outExtension: {\n ...config.outExtension\n },\n banner: {\n ...config.banner\n },\n footer: {\n ...config.footer\n },\n plugins: [\n ...(isWatch ? [rebuildLogger(config)] : []),\n ...config.plugins ?? [],\n inlineCSS()\n ],\n nodePaths: [\n ...config.nodePaths ?? []\n ]\n };\n const ctx = await esbuild.context(config);\n\n if (isWatch) {\n await ctx.watch();\n } else {\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n // eslint-disable-next-line no-console\n console.log(\"Start: \", config.entryPoints[0], config.outfile);\n }\n await ctx.rebuild();\n await ctx.dispose();\n if (isDevelopment && Array.isArray(config.entryPoints)) {\n // eslint-disable-next-line no-console\n console.log(\"Stop: \", config.entryPoints[0], config.outfile);\n }\n }\n}\n\nexport type TplOptions = {\n format?: Format | \"umd\";\n globalName?: string;\n libraryName?: string;\n keepNames?: boolean;\n external?: string[];\n plugins?: Plugin[];\n loader?: { [ext: string]: Loader };\n supported?: Record<string, boolean>;\n alias?: Record<string, string>;\n define?: { [key: string]: string };\n packages?: \"bundle\" | \"external\" | \"auto\";\n};\n\nfunction autoExternal(external?: string[]): string[] {\n return [\n ...pkg.dependencies ? Object.keys(pkg.dependencies) : [], ...pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],\n ...external ?? []\n ];\n}\n\nexport function browserTpl(input: string, output: string, options: TplOptions = {}) {\n options.format = options.format ?? \"esm\";\n\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n external: options.external ?? [],\n outfile: `${output}.${options.format === \"esm\" ? \"js\" : `${options.format}.js`}`,\n platform: \"browser\",\n target: \"es2022\",\n globalName: options.globalName,\n keepNames: options.keepNames,\n plugins: options.format === \"umd\" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,\n alias: options.alias,\n define: options.define,\n loader: options.loader,\n supported: options.supported,\n });\n}\n\nexport function nodeTpl(input: string, output: string, options: TplOptions = {}) {\n options.format = options.format ?? \"esm\";\n options.packages = options.packages ?? \"external\";\n if (options.packages === \"auto\") {\n options.external = autoExternal(options.external);\n }\n\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n external: options.external ?? [],\n outfile: `${output}.${options.format === \"esm\" ? NODE_MJS : NODE_CJS}`,\n platform: \"node\",\n target: \"node22\",\n packages: options.packages === \"auto\" ? \"bundle\" : options.packages,\n globalName: options.globalName,\n keepNames: options.keepNames,\n plugins: options.plugins,\n alias: options.alias,\n define: options.define,\n loader: options.loader,\n supported: options.supported,\n });\n}\n\nexport function neutralTpl(input: string, output: string, options: TplOptions = {}) {\n options.format = options.format ?? \"esm\";\n\n return buildWatch([input], {\n format: options.format === \"umd\" ? \"esm\" : options.format,\n external: options.external ?? [],\n outfile: `${output}.${options.format === \"esm\" ? \"js\" : `${options.format}.js`}`,\n platform: \"neutral\",\n target: \"es2022\",\n globalName: options.globalName,\n keepNames: options.keepNames,\n plugins: options.format === \"umd\" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,\n alias: options.alias,\n define: options.define,\n loader: options.loader,\n supported: options.supported,\n });\n}\n\nexport function browserBoth(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n browserTpl(input, output, { format: \"esm\", ...options }),\n browserTpl(input, output, { format: \"umd\", ...options })\n ]);\n}\n\nexport function nodeBoth(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n nodeTpl(input, output, { format: \"esm\", ...options }),\n nodeTpl(input, output, { format: \"cjs\", ...options })\n ]);\n}\n\nexport function bothTpl(input: string, output: string, options: TplOptions = {}) {\n return Promise.all([\n browserBoth(input, output, { ...options }),\n nodeTpl(input, output, { format: \"cjs\", ...options })\n ]);\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\nimport path from \"path\";\nimport crypto from \"crypto\";\nimport { readFile } from \"fs/promises\";\n\nexport function inlineCSS(options = {}) {\n return {\n name: \"inline-css\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.(css)$/ }, async (args) => {\n if (build.initialOptions.platform === \"browser\") {\n const sourcePath = path.resolve(args.path);\n const sourceJS = await generateInjectCSS(sourcePath);\n return {\n contents: sourceJS,\n loader: \"js\"\n };\n }\n });\n },\n };\n}\n\nasync function generateInjectCSS(sourcePath: string) {\n const styleID = sha256(sourcePath);\n const sourceCSS = await readFile(sourcePath, \"utf8\");\n\n return `(function(){\n if (!document.getElementById('${styleID}')) {\n var e = document.createElement('style');\n e.id = '${styleID}';\n e.textContent = \\`${sourceCSS.split(\"\\\\25\").join(\"\\\\x15\")}\\`;\n document.head.appendChild(e);\n }\n })();`;\n}\n\nfunction sha256(sourcePath: string) {\n const hash = crypto.createHash(\"sha256\").update(sourcePath).digest(\"hex\");\n return hash.slice(0, 8); // Use the first 8 characters of the hash\n}\n\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface RebuildLoggerOptions {\n outfile?: string;\n}\n\nexport function rebuildLogger(opts: RebuildLoggerOptions): Plugin {\n return {\n name: \"rebuild-logger\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n // eslint-disable-next-line no-console\n console.log(\"[watch] build started\");\n });\n\n build.onEnd(() => {\n // eslint-disable-next-line no-console\n console.log(`Rebuilt ${opts.outfile ?? \"Unknown\"}`);\n });\n }\n };\n}\n", "import { readFile } from \"fs/promises\";\nimport type { PluginBuild, Plugin } from \"esbuild\";\n\nexport interface ExcludeSourcemapOptions {\n filter: RegExp;\n}\nexport function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {\n return {\n name: \"exclude-sourcemap\",\n\n setup(build: PluginBuild) {\n build.onLoad({ filter: opts.filter }, async args => {\n return {\n contents: await readFile(args.path, \"utf8\") + \"\\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==\",\n loader: \"default\",\n };\n });\n },\n };\n}\n", "import type { PluginBuild, Plugin } from \"esbuild\";\n\nexport function problemMatcher(): Plugin {\n return {\n name: \"problem-matcher\",\n\n setup(build: PluginBuild) {\n\n build.onStart(() => {\n // eslint-disable-next-line no-console\n console.log(\"[watch] build started\");\n });\n\n build.onEnd((result) => {\n result.errors.forEach(({ text, location }) => {\n console.error(`\u2718 [ERROR] ${text}`);\n console.error(` ${location?.file}:${location?.line}:${location?.column}:`);\n });\n // eslint-disable-next-line no-console\n console.log(\"[watch] build finished\");\n });\n }\n };\n}\n", "import { writeFileSync } from \"node:fs\";\nimport type { PluginBuild, Plugin } from \"esbuild\";\n\nexport function removeStrict(): Plugin {\n return {\n name: \"remove-strict\",\n setup(build: PluginBuild) {\n build.initialOptions.write = false;\n build.onEnd((result) => {\n result?.outputFiles?.forEach(file => {\n if (file.path.endsWith(\".js\")) {\n const contents = file.text.replace(/\"use strict\";/g, \"\");\n writeFileSync(file.path, contents, { encoding: \"utf8\" });\n } else {\n writeFileSync(file.path, file.contents, { encoding: \"binary\" });\n }\n });\n });\n }\n };\n}\n", "import { readFile } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { Base91 } from \"@hpcc-js/wasm-base91\";\nimport { Zstd } from \"@hpcc-js/wasm-zstd\";\nimport type { Plugin, PluginBuild } from \"esbuild\";\n\nfunction tpl(wasmJsPath: string, base91Wasm: string, base91CompressedWasm: string) {\n\n const compressed = (base91CompressedWasm.length + 8 * 1024) <= base91Wasm.length;\n const wasmJsExists = existsSync(wasmJsPath);\n\n return `\\\n${compressed ? 'import { decompress } from \"fzstd\";' : \"\"}\n${wasmJsExists ? `import wrapper from \"${wasmJsPath}\";` : \"\"}\n\nconst table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_\\`{|}~\"';\n\nfunction decode(raw: string): Uint8Array {\n const len = raw.length;\n const ret: number[] = [];\n\n let b = 0;\n let n = 0;\n let v = -1;\n\n for (let i = 0; i < len; i++) {\n const p = table.indexOf(raw[i]);\n /* istanbul ignore next */\n if (p === -1) continue;\n if (v < 0) {\n v = p;\n } else {\n v += p * 91;\n b |= v << n;\n n += (v & 8191) > 88 ? 13 : 14;\n do {\n ret.push(b & 0xff);\n b >>= 8;\n n -= 8;\n } while (n > 7);\n v = -1;\n }\n }\n\n if (v > -1) {\n ret.push((b | v << n) & 0xff);\n }\n\n return new Uint8Array(ret);\n}\n\nconst blobStr = '${compressed ? base91CompressedWasm : base91Wasm}';\n\nlet g_module: Uint8Array | undefined;\nlet g_wasmBinary: Uint8Array | undefined;\nexport default function() {\n if (!g_wasmBinary) {\n g_wasmBinary = ${compressed ? \"decompress(decode(blobStr))\" : \"decode(blobStr)\"};\n }\n${!wasmJsExists ? `\\\n return g_wasmBinary;\n`: `\\\n if (!g_module) {\n g_module = wrapper({\n wasmBinary: g_wasmBinary,\n locateFile: undefined\n });\n }\n return g_module;\n`}\n}\n\nexport function reset() {\n if (g_module) {\n g_module = undefined;\n }\n} `.trim();\n}\n\nexport async function wrap(path: string) {\n const base91 = await Base91.load();\n const zstd = await Zstd.load();\n\n const wasm = await readFile(path);\n path = path.replace(/\\.js$/, \".xxx\");\n const wasmJsPath = path.replace(/\\.wasm$/, \".js\");\n const base91Wasm = base91.encode(wasm);\n const compressedWasm = zstd.compress(wasm);\n const base91CompressedWasm = base91.encode(compressedWasm);\n\n return tpl(wasmJsPath, base91Wasm, base91CompressedWasm);\n}\n\nexport function sfxWasm(): Plugin {\n return {\n name: \"sfx-wasm\",\n\n setup(build: PluginBuild) {\n\n build.onLoad({ filter: /\\.wasm$/ }, async args => {\n return {\n contents: await wrap(args.path),\n loader: \"ts\",\n };\n });\n }\n };\n}\n", "import { defineConfig, UserConfig } from \"vite\";\nimport cssInjectedByJsPlugin from \"vite-plugin-css-injected-by-js\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nconst alias = {\n \"d3-array\": \"@hpcc-js/common\",\n \"d3-brush\": \"@hpcc-js/common\",\n \"d3-collection\": \"@hpcc-js/common\",\n \"d3-color\": \"@hpcc-js/common\",\n \"d3-dispatch\": \"@hpcc-js/common\",\n \"d3-drag\": \"@hpcc-js/common\",\n \"d3-dsv\": \"@hpcc-js/common\",\n \"d3-ease\": \"@hpcc-js/common\",\n \"d3-format\": \"@hpcc-js/common\",\n \"d3-interpolate\": \"@hpcc-js/common\",\n \"d3-scale\": \"@hpcc-js/common\",\n \"d3-selection\": \"@hpcc-js/common\",\n \"d3-time-format\": \"@hpcc-js/common\",\n \"d3-transition\": \"@hpcc-js/common\",\n \"d3-zoom\": \"@hpcc-js/common\"\n};\n\nexport function hpccBundleNames(pkg: any) {\n const external: string[] = [];\n const globals: { [id: string]: string } = {};\n for (const dep in pkg.dependencies) {\n external.push(dep);\n globals[dep] = dep;\n }\n for (const dep in pkg.peerDependencies ?? {}) {\n external.push(dep);\n globals[dep] = dep;\n }\n return { alias: (pkg.name !== \"@hpcc-js/common\" && pkg.dependencies[\"@hpcc-js/common\"]) ? alias : {}, external, globals };\n}\n\nexport interface ViteHpccConfigOptions {\n /**\n * Additional external items\n */\n external?: string[];\n /**\n * Additional plugins to include in the configuration\n */\n plugins?: any[];\n /**\n * Whether to include font-awesome static copy (used by @hpcc-js/common)\n */\n includeFontAwesome?: boolean;\n /**\n * Custom entry point (defaults to \"src/index.ts\")\n */\n entry?: string;\n /**\n * Additional vite config options to merge\n */\n configOverrides?: Partial<UserConfig>;\n}\n\n/**\n * Creates a standardized Vite configuration for HPCC-JS packages\n */\nexport function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions = {}): UserConfig {\n const {\n external: additionalExternal = [],\n plugins: additionalPlugins = [],\n includeFontAwesome = false,\n entry = \"src/index.ts\",\n configOverrides = {}\n } = options;\n\n const { alias, external, globals } = hpccBundleNames(pkg);\n const allExternals = [...external, ...additionalExternal];\n\n const allPlugins = [\n cssInjectedByJsPlugin({\n topExecutionPriority: false\n }),\n ...additionalPlugins\n ];\n\n if (includeFontAwesome) {\n allPlugins.push(\n viteStaticCopy({\n targets: [\n {\n src: \"../../node_modules/font-awesome/fonts\",\n dest: \"../font-awesome\"\n }, {\n src: \"../../node_modules/font-awesome/css\",\n dest: \"../font-awesome\",\n }\n ]\n })\n );\n }\n\n const defaultLibConfig = {\n entry,\n name: pkg.name,\n fileName: \"index\",\n };\n\n const config: UserConfig = {\n build: {\n lib: {\n ...defaultLibConfig,\n ...(configOverrides.build?.lib || {})\n },\n rollupOptions: {\n external: allExternals,\n output: {\n globals,\n },\n ...(configOverrides.build?.rollupOptions || {})\n },\n sourcemap: true,\n ...(configOverrides.build ? Object.fromEntries(Object.entries(configOverrides.build).filter(([key]) => key !== \"lib\" && key !== \"rollupOptions\")) : {})\n },\n resolve: {\n alias,\n ...(configOverrides.resolve || {})\n },\n esbuild: {\n minifyIdentifiers: false,\n ...(configOverrides.esbuild || {})\n },\n plugins: allPlugins,\n ...Object.fromEntries(Object.entries(configOverrides).filter(([key]) => ![\"build\", \"resolve\", \"esbuild\", \"plugins\"].includes(key)))\n };\n\n return defineConfig(config);\n}"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAa,UACzB,OAAS,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KACxD,UAAYC,MAAU,OACtB,UAAYC,MAAa,UAEzB,OAAS,cAAAC,MAAkB,6BAC3B,UAAYC,OAAqB,4BCLjC,OAAOC,MAAU,OACjB,OAAOC,MAAY,SACnB,OAAS,YAAAC,MAAgB,cAElB,SAASC,EAAUC,EAAU,CAAC,EAAG,CACpC,MAAO,CACH,KAAM,aAEN,MAAMC,EAAoB,CAEtBA,EAAM,OAAO,CAAE,OAAQ,UAAW,EAAG,MAAOC,GAAS,CACjD,GAAID,EAAM,eAAe,WAAa,UAAW,CAC7C,IAAME,EAAaP,EAAK,QAAQM,EAAK,IAAI,EAEzC,MAAO,CACH,SAFa,MAAME,EAAkBD,CAAU,EAG/C,OAAQ,IACZ,CACJ,CACJ,CAAC,CACL,CACJ,CACJ,CAEA,eAAeC,EAAkBD,EAAoB,CACjD,IAAME,EAAUC,EAAOH,CAAU,EAC3BI,EAAY,MAAMT,EAASK,EAAY,MAAM,EAEnD,MAAO;AAAA,wCAC6BE,CAAO;AAAA;AAAA,sBAEzBA,CAAO;AAAA,gCACGE,EAAU,MAAM,MAAM,EAAE,KAAK,OAAO,CAAC;AAAA;AAAA;AAAA,UAIrE,CAEA,SAASD,EAA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CACL,kBAAmB,GACnB,GAAIA,EAAgB,SAAW,CAAC,CACpC,EACA,QAASE,EACT,GAAG,OAAO,YAAY,OAAO,QAAQF,CAAe,EAAE,OAAO,CAAC,CAACI,CAAG,IAAM,CAAC,CAAC,QAAS,UAAW,UAAW,SAAS,EAAE,SAASA,CAAG,CAAC,CAAC,CACtI,EAEA,OAAOnB,EAAakB,CAAM,CAC9B",
|
|
6
|
+
"names": ["process", "readFileSync", "existsSync", "writeFileSync", "path", "esbuild", "umdWrapper", "copyStaticFiles", "path", "crypto", "readFile", "inlineCSS", "options", "build", "args", "sourcePath", "generateInjectCSS", "styleID", "sha256", "sourceCSS", "rebuildLogger", "opts", "build", "pkg", "readFileSync", "NODE_MJS", "NODE_CJS", "buildWatch", "inputs", "config", "isDevelopment", "isWatch", "isProduction", "existsSync", "rootPkg", "writeFileSync", "rebuildLogger", "inlineCSS", "ctx", "autoExternal", "external", "browserTpl", "input", "output", "options", "umdWrapper", "nodeTpl", "neutralTpl", "browserBoth", "nodeBoth", "bothTpl", "readFile", "excludeSourcemap", "opts", "build", "args", "problemMatcher", "build", "result", "text", "location", "writeFileSync", "removeStrict", "build", "result", "file", "contents", "readFile", "existsSync", "Base91", "Zstd", "tpl", "wasmJsPath", "base91Wasm", "base91CompressedWasm", "compressed", "wasmJsExists", "wrap", "path", "base91", "zstd", "wasm", "compressedWasm", "sfxWasm", "build", "args", "defineConfig", "cssInjectedByJsPlugin", "viteStaticCopy", "alias", "hpccBundleNames", "pkg", "external", "globals", "dep", "createHpccViteConfig", "options", "additionalExternal", "additionalPlugins", "includeFontAwesome", "entry", "configOverrides", "allExternals", "allPlugins", "config", "key"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/esbuild-plugins",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Various esbuild plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
|
|
64
64
|
"license": "Apache-2.0",
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "dcb220f9576a7efd781244392ec74bc7c02ced02"
|
|
66
66
|
}
|
package/src/build.ts
CHANGED
|
@@ -109,14 +109,16 @@ export function browserTpl(input: string, output: string, options: TplOptions =
|
|
|
109
109
|
target: "es2022",
|
|
110
110
|
globalName: options.globalName,
|
|
111
111
|
keepNames: options.keepNames,
|
|
112
|
-
plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName })
|
|
112
|
+
plugins: options.format === "umd" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,
|
|
113
113
|
alias: options.alias,
|
|
114
114
|
define: options.define,
|
|
115
115
|
loader: options.loader,
|
|
116
|
+
supported: options.supported,
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
export function nodeTpl(input: string, output: string, options: TplOptions = {}) {
|
|
121
|
+
options.format = options.format ?? "esm";
|
|
120
122
|
options.packages = options.packages ?? "external";
|
|
121
123
|
if (options.packages === "auto") {
|
|
122
124
|
options.external = autoExternal(options.external);
|
|
@@ -124,41 +126,37 @@ export function nodeTpl(input: string, output: string, options: TplOptions = {})
|
|
|
124
126
|
|
|
125
127
|
return buildWatch([input], {
|
|
126
128
|
format: options.format === "umd" ? "esm" : options.format,
|
|
129
|
+
external: options.external ?? [],
|
|
127
130
|
outfile: `${output}.${options.format === "esm" ? NODE_MJS : NODE_CJS}`,
|
|
128
131
|
platform: "node",
|
|
129
132
|
target: "node22",
|
|
130
133
|
packages: options.packages === "auto" ? "bundle" : options.packages,
|
|
134
|
+
globalName: options.globalName,
|
|
135
|
+
keepNames: options.keepNames,
|
|
136
|
+
plugins: options.plugins,
|
|
137
|
+
alias: options.alias,
|
|
138
|
+
define: options.define,
|
|
139
|
+
loader: options.loader,
|
|
140
|
+
supported: options.supported,
|
|
131
141
|
});
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
export function neutralTpl(input: string, output: string, options: TplOptions = {}) {
|
|
135
145
|
options.format = options.format ?? "esm";
|
|
136
146
|
|
|
137
|
-
let postfix = "";
|
|
138
|
-
switch (options.format) {
|
|
139
|
-
case "iife":
|
|
140
|
-
postfix = "iife.js";
|
|
141
|
-
break;
|
|
142
|
-
case "esm":
|
|
143
|
-
postfix = NODE_MJS;
|
|
144
|
-
break;
|
|
145
|
-
case "cjs":
|
|
146
|
-
postfix = NODE_CJS;
|
|
147
|
-
break;
|
|
148
|
-
case "umd":
|
|
149
|
-
postfix = "umd.js";
|
|
150
|
-
break;
|
|
151
|
-
default:
|
|
152
|
-
throw new Error(`Unknown format: ${options.format}`);
|
|
153
|
-
}
|
|
154
147
|
return buildWatch([input], {
|
|
155
148
|
format: options.format === "umd" ? "esm" : options.format,
|
|
149
|
+
external: options.external ?? [],
|
|
156
150
|
outfile: `${output}.${options.format === "esm" ? "js" : `${options.format}.js`}`,
|
|
157
151
|
platform: "neutral",
|
|
158
152
|
target: "es2022",
|
|
159
153
|
globalName: options.globalName,
|
|
160
154
|
keepNames: options.keepNames,
|
|
161
|
-
plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName })] :
|
|
155
|
+
plugins: options.format === "umd" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,
|
|
156
|
+
alias: options.alias,
|
|
157
|
+
define: options.define,
|
|
158
|
+
loader: options.loader,
|
|
159
|
+
supported: options.supported,
|
|
162
160
|
});
|
|
163
161
|
}
|
|
164
162
|
|