@hpcc-js/esbuild-plugins 1.4.7 → 1.4.9
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 +4 -4
- package/dist/index.js.map +3 -3
- package/dist/sfx-wrapper.js +6 -6
- package/dist/sfx-wrapper.js.map +4 -4
- package/package.json +7 -7
- package/src/build.ts +12 -8
- package/src/sfx-wrapper.ts +1 -1
- package/src/vite-utils.ts +67 -9
- package/types/build.d.ts +4 -1
- package/types/vite-utils.d.ts +5 -6
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.9",
|
|
4
4
|
"description": "Various esbuild plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"update": "npx --yes npm-check-updates -u -t minor"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"esbuild": "0.25.
|
|
40
|
+
"esbuild": "0.25.8",
|
|
41
41
|
"esbuild-copy-static-files": "0.1.0",
|
|
42
42
|
"esbuild-plugin-inline-css": "0.0.1",
|
|
43
43
|
"esbuild-plugin-umd-wrapper": "3.0.0",
|
|
44
44
|
"fzstd": "0.1.1",
|
|
45
|
-
"vite": "7.0.
|
|
45
|
+
"vite": "7.0.6",
|
|
46
46
|
"vite-plugin-css-injected-by-js": "3.5.2",
|
|
47
|
-
"vite-plugin-static-copy": "3.1.
|
|
47
|
+
"vite-plugin-static-copy": "3.1.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@hpcc-js/wasm-base91": "1.
|
|
51
|
-
"@hpcc-js/wasm-zstd": "1.
|
|
50
|
+
"@hpcc-js/wasm-base91": "1.5.0",
|
|
51
|
+
"@hpcc-js/wasm-zstd": "1.4.0"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"esbuild",
|
|
@@ -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": "
|
|
67
|
+
"gitHead": "92489547b0e57f479a691236b1a47e977b43cf2e"
|
|
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
|
-
|
|
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
|
|
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" ? [
|
|
116
|
+
plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName }) as Plugin, ...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
|
|
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
|
|
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" ? [
|
|
159
|
+
plugins: options.format === "umd" ? [umdWrapper({ libraryName: options.libraryName }) as Plugin, ...options.plugins ?? []] : options.plugins,
|
|
156
160
|
alias: options.alias,
|
|
157
161
|
define: options.define,
|
|
158
162
|
loader: options.loader,
|
package/src/sfx-wrapper.ts
CHANGED
package/src/vite-utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineConfig,
|
|
1
|
+
import { configDefaults, defineConfig, ViteUserConfig } from "vitest/config";
|
|
2
2
|
import cssInjectedByJsPlugin from "vite-plugin-css-injected-by-js";
|
|
3
3
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
4
4
|
|
|
@@ -54,19 +54,65 @@ export interface ViteHpccConfigOptions {
|
|
|
54
54
|
/**
|
|
55
55
|
* Additional vite config options to merge
|
|
56
56
|
*/
|
|
57
|
-
configOverrides?: Partial<
|
|
57
|
+
configOverrides?: Partial<ViteUserConfig>;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
export const nodeConfig = defineConfig({
|
|
61
|
+
test: {
|
|
62
|
+
name: "node",
|
|
63
|
+
|
|
64
|
+
exclude: [
|
|
65
|
+
...configDefaults.exclude,
|
|
66
|
+
"**/*.browser.spec.{ts,js}",
|
|
67
|
+
"**/node_modules/**",
|
|
68
|
+
"**/.nx/**",
|
|
69
|
+
"**/apps/**",
|
|
70
|
+
"**/components/**",
|
|
71
|
+
"**/demos/**",
|
|
72
|
+
],
|
|
73
|
+
environment: "node",
|
|
74
|
+
setupFiles: []
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
export const browserConfig = defineConfig({
|
|
79
|
+
test: {
|
|
80
|
+
exclude: [
|
|
81
|
+
...configDefaults.exclude,
|
|
82
|
+
"@hpcc-js/dgrid-shim",
|
|
83
|
+
"**/*.node.spec.{ts,js}",
|
|
84
|
+
"**/node_modules/**",
|
|
85
|
+
"**/.nx/**",
|
|
86
|
+
"**/apps/**",
|
|
87
|
+
"**/components/**",
|
|
88
|
+
"**/demos/**",
|
|
89
|
+
"**/src/**",
|
|
90
|
+
],
|
|
91
|
+
browser: {
|
|
92
|
+
enabled: true,
|
|
93
|
+
provider: "playwright",
|
|
94
|
+
instances: [{
|
|
95
|
+
name: "chromium",
|
|
96
|
+
browser: "chromium",
|
|
97
|
+
headless: true,
|
|
98
|
+
//@ts-expect-error
|
|
99
|
+
launch: {
|
|
100
|
+
args: ["--disable-web-security"],
|
|
101
|
+
}
|
|
102
|
+
}],
|
|
103
|
+
screenshotFailures: false,
|
|
104
|
+
},
|
|
105
|
+
setupFiles: [],
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions = {}): ViteUserConfig {
|
|
64
110
|
const {
|
|
65
111
|
external: additionalExternal = [],
|
|
66
112
|
plugins: additionalPlugins = [],
|
|
67
113
|
includeFontAwesome = false,
|
|
68
114
|
entry = "src/index.ts",
|
|
69
|
-
configOverrides = {}
|
|
115
|
+
configOverrides = {},
|
|
70
116
|
} = options;
|
|
71
117
|
|
|
72
118
|
const { alias, external, globals } = hpccBundleNames(pkg);
|
|
@@ -101,7 +147,7 @@ export function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions =
|
|
|
101
147
|
fileName: "index",
|
|
102
148
|
};
|
|
103
149
|
|
|
104
|
-
const config:
|
|
150
|
+
const config: ViteUserConfig = {
|
|
105
151
|
build: {
|
|
106
152
|
lib: {
|
|
107
153
|
...defaultLibConfig,
|
|
@@ -114,6 +160,14 @@ export function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions =
|
|
|
114
160
|
},
|
|
115
161
|
...(configOverrides.build?.rollupOptions || {})
|
|
116
162
|
},
|
|
163
|
+
// Preserve class names and function names in minified output
|
|
164
|
+
minify: "terser",
|
|
165
|
+
terserOptions: {
|
|
166
|
+
keep_classnames: true,
|
|
167
|
+
mangle: {
|
|
168
|
+
keep_classnames: true,
|
|
169
|
+
}
|
|
170
|
+
},
|
|
117
171
|
sourcemap: true,
|
|
118
172
|
...(configOverrides.build ? Object.fromEntries(Object.entries(configOverrides.build).filter(([key]) => key !== "lib" && key !== "rollupOptions")) : {})
|
|
119
173
|
},
|
|
@@ -122,10 +176,14 @@ export function createHpccViteConfig(pkg: any, options: ViteHpccConfigOptions =
|
|
|
122
176
|
...(configOverrides.resolve || {})
|
|
123
177
|
},
|
|
124
178
|
esbuild: {
|
|
125
|
-
|
|
179
|
+
keepNames: true,
|
|
126
180
|
...(configOverrides.esbuild || {})
|
|
127
181
|
},
|
|
128
182
|
plugins: allPlugins,
|
|
183
|
+
test: {
|
|
184
|
+
projects: [nodeConfig, browserConfig],
|
|
185
|
+
...(configOverrides.test || {})
|
|
186
|
+
},
|
|
129
187
|
...Object.fromEntries(Object.entries(configOverrides).filter(([key]) => !["build", "resolve", "esbuild", "plugins"].includes(key)))
|
|
130
188
|
};
|
|
131
189
|
|
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:
|
|
13
|
+
}[], config: BuildOptionsEx): Promise<void>;
|
|
11
14
|
export type TplOptions = {
|
|
12
15
|
format?: Format | "umd";
|
|
13
16
|
globalName?: string;
|
package/types/vite-utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ViteUserConfig } from "vitest/config";
|
|
2
2
|
export declare function hpccBundleNames(pkg: any): {
|
|
3
3
|
alias: {};
|
|
4
4
|
external: string[];
|
|
@@ -26,9 +26,8 @@ export interface ViteHpccConfigOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* Additional vite config options to merge
|
|
28
28
|
*/
|
|
29
|
-
configOverrides?: Partial<
|
|
29
|
+
configOverrides?: Partial<ViteUserConfig>;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export declare function createHpccViteConfig(pkg: any, options?: ViteHpccConfigOptions): UserConfig;
|
|
31
|
+
export declare const nodeConfig: ViteUserConfig;
|
|
32
|
+
export declare const browserConfig: ViteUserConfig & Promise<ViteUserConfig> & (import("vitest/config").UserConfigFnObject & import("vitest/config").UserConfigExport);
|
|
33
|
+
export declare function createHpccViteConfig(pkg: any, options?: ViteHpccConfigOptions): ViteUserConfig;
|