@hpcc-js/esbuild-plugins 1.4.7 → 1.4.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpcc-js/esbuild-plugins",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Various esbuild plugins",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,5 +64,5 @@
64
64
  },
65
65
  "homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
66
66
  "license": "Apache-2.0",
67
- "gitHead": "44cd47dfe0d954df395002c2d5ce222a73d73f2a"
67
+ "gitHead": "ef271e12a3730c4503a82f80a37aaaa29643e1e3"
68
68
  }
package/src/build.ts CHANGED
@@ -14,7 +14,11 @@ export const pkg = JSON.parse(readFileSync(path.join(process.cwd(), "./package.j
14
14
  export const NODE_MJS = pkg.type === "module" ? "js" : "mjs";
15
15
  export const NODE_CJS = pkg.type === "module" ? "cjs" : "js";
16
16
 
17
- export async function buildWatch(inputs: string[] | Record<string, string> | { in: string, out: string }[], config: BuildOptions): Promise<void> {
17
+ interface BuildOptionsEx extends Omit<BuildOptions, "format"> {
18
+ format?: Format | "umd";
19
+ }
20
+
21
+ export async function buildWatch(inputs: string[] | Record<string, string> | { in: string, out: string }[], config: BuildOptionsEx): Promise<void> {
18
22
  const isDevelopment = process.argv.includes("--development");
19
23
  const isWatch = process.argv.includes("--watch");
20
24
  const isProduction = !isDevelopment;
@@ -30,7 +34,7 @@ export const BUILD_VERSION = "${rootPkg.version}";
30
34
 
31
35
  config = {
32
36
  entryPoints: inputs,
33
- format: "esm",
37
+ format: config.format ?? "esm",
34
38
  bundle: true,
35
39
  minify: isProduction,
36
40
  sourcemap: true,
@@ -59,7 +63,7 @@ export const BUILD_VERSION = "${rootPkg.version}";
59
63
  ...config.nodePaths ?? []
60
64
  ]
61
65
  };
62
- const ctx = await esbuild.context(config);
66
+ const ctx = await esbuild.context(config as BuildOptions);
63
67
 
64
68
  if (isWatch) {
65
69
  await ctx.watch();
@@ -102,14 +106,14 @@ export function browserTpl(input: string, output: string, options: TplOptions =
102
106
  options.format = options.format ?? "esm";
103
107
 
104
108
  return buildWatch([input], {
105
- format: options.format === "umd" ? "esm" : options.format,
109
+ format: options.format,
106
110
  external: options.external ?? [],
107
111
  outfile: `${output}.${options.format === "esm" ? "js" : `${options.format}.js`}`,
108
112
  platform: "browser",
109
113
  target: "es2022",
110
114
  globalName: options.globalName,
111
115
  keepNames: options.keepNames,
112
- plugins: options.format === "umd" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,
116
+ plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName }), ...options.plugins ?? []] : options.plugins,
113
117
  alias: options.alias,
114
118
  define: options.define,
115
119
  loader: options.loader,
@@ -125,7 +129,7 @@ export function nodeTpl(input: string, output: string, options: TplOptions = {})
125
129
  }
126
130
 
127
131
  return buildWatch([input], {
128
- format: options.format === "umd" ? "esm" : options.format,
132
+ format: options.format,
129
133
  external: options.external ?? [],
130
134
  outfile: `${output}.${options.format === "esm" ? NODE_MJS : NODE_CJS}`,
131
135
  platform: "node",
@@ -145,14 +149,14 @@ export function neutralTpl(input: string, output: string, options: TplOptions =
145
149
  options.format = options.format ?? "esm";
146
150
 
147
151
  return buildWatch([input], {
148
- format: options.format === "umd" ? "esm" : options.format,
152
+ format: options.format,
149
153
  external: options.external ?? [],
150
154
  outfile: `${output}.${options.format === "esm" ? "js" : `${options.format}.js`}`,
151
155
  platform: "neutral",
152
156
  target: "es2022",
153
157
  globalName: options.globalName,
154
158
  keepNames: options.keepNames,
155
- plugins: options.format === "umd" ? [...options.plugins ?? [], umdWrapper({ libraryName: options.libraryName })] : options.plugins,
159
+ plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName }), ...options.plugins ?? []] : options.plugins,
156
160
  alias: options.alias,
157
161
  define: options.define,
158
162
  loader: options.loader,
@@ -63,7 +63,7 @@ ${!wasmJsExists ? `\
63
63
  if (!g_module) {
64
64
  g_module = wrapper({
65
65
  wasmBinary: g_wasmBinary,
66
- locateFile: undefined
66
+ locateFile: (name: string) => "sfx-wrapper nop"
67
67
  });
68
68
  }
69
69
  return g_module;
package/types/build.d.ts CHANGED
@@ -4,10 +4,13 @@ export { copyStaticFiles };
4
4
  export declare const pkg: any;
5
5
  export declare const NODE_MJS: string;
6
6
  export declare const NODE_CJS: string;
7
+ interface BuildOptionsEx extends Omit<BuildOptions, "format"> {
8
+ format?: Format | "umd";
9
+ }
7
10
  export declare function buildWatch(inputs: string[] | Record<string, string> | {
8
11
  in: string;
9
12
  out: string;
10
- }[], config: BuildOptions): Promise<void>;
13
+ }[], config: BuildOptionsEx): Promise<void>;
11
14
  export type TplOptions = {
12
15
  format?: Format | "umd";
13
16
  globalName?: string;