@genesislcap/vite-builder 15.22.1 → 15.22.2
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.d.ts.map +1 -1
- package/dist/index.js +51 -0
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAc3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;yBAEmB,KAAK,YAAY;AAAvC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAc3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;yBAEmB,KAAK,YAAY;AAAvC,wBAmOE"}
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,17 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
|
|
|
34
34
|
var _a, _b, _c;
|
|
35
35
|
const { config: { app: { rootElement }, env, http, }, dirs: { cwd }, cli: { isDev, isBuild, isAnalyze, options: { open, https }, }, pkg: { description }, resolve: { alias }, } = ctx;
|
|
36
36
|
const define = (0, build_kit_1.resolveDefineConfig)(env, http, 'vite');
|
|
37
|
+
/**
|
|
38
|
+
* The same map, narrowed to keys esbuild will accept as defines (see the `esbuildOptions` note in
|
|
39
|
+
* `optimizeDeps` below for why the optimizer needs it at all).
|
|
40
|
+
*
|
|
41
|
+
* `resolveDefineConfig` derives its keys from `process.env` via pattern match, so a machine with,
|
|
42
|
+
* say, `GENX-SOMETHING` set would produce a key that is not a valid JS identifier. Vite tolerates
|
|
43
|
+
* that in its own `define`; esbuild rejects the whole build. Filtering keeps a stray environment
|
|
44
|
+
* variable from turning into a hard build failure for everyone.
|
|
45
|
+
*/
|
|
46
|
+
const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
47
|
+
const depDefine = Object.fromEntries(Object.entries(define).filter(([key]) => IDENTIFIER.test(key)));
|
|
37
48
|
const handlebars = yield (0, vite_js_1.getHandlebarsModule)();
|
|
38
49
|
const vite = yield (0, vite_js_1.getViteModule)();
|
|
39
50
|
const publicPath = (0, build_kit_1.getPublicPath)();
|
|
@@ -146,6 +157,46 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
|
|
|
146
157
|
* reference, should we convert the above to a glob.
|
|
147
158
|
*/
|
|
148
159
|
include: ['@genesis-community/golden-layout'],
|
|
160
|
+
/**
|
|
161
|
+
* GENC-1581 — the `define` above is applied when Vite TRANSFORMS source, but dependency
|
|
162
|
+
* pre-bundling is a separate esbuild pass that does not inherit it. Any env-driven global
|
|
163
|
+
* consumed from inside a pre-bundled dependency was therefore left as a bare identifier in
|
|
164
|
+
* `node_modules/.vite/deps`, and silently resolved to `undefined` at runtime.
|
|
165
|
+
*
|
|
166
|
+
* MEASURED before this change: the served `@genesislcap/foundation-utils` chunk contained
|
|
167
|
+
* `_DEFAULT_USER = DEFAULT_USER;` with no substitution, and the configured value appeared
|
|
168
|
+
* nowhere in the bundle. `foundation-utils` reads these behind `try {} catch {}`, so the
|
|
169
|
+
* resulting ReferenceError was swallowed and the variable simply stayed undefined — no
|
|
170
|
+
* error, no warning, just a feature that never worked. `DEFAULT_USER`/`DEFAULT_PASSWORD`
|
|
171
|
+
* (login pre-fill) is the case that surfaced it; every dependency-resident define was
|
|
172
|
+
* equally affected. `API_HOST` masked the problem because `foundation-comms` falls back to
|
|
173
|
+
* deriving it from `location`, and the dev proxy makes that fallback correct.
|
|
174
|
+
*
|
|
175
|
+
* Passing the same map to the optimizer's esbuild keeps source and dependencies consistent.
|
|
176
|
+
* Vite hashes `optimizeDeps` into the dep-cache key, so changing a value re-optimizes rather
|
|
177
|
+
* than silently serving a stale chunk.
|
|
178
|
+
*/
|
|
179
|
+
esbuildOptions: {
|
|
180
|
+
define: Object.assign({
|
|
181
|
+
/**
|
|
182
|
+
* Vite seeds its OWN optimizer define with `process.env.NODE_ENV` and then spreads
|
|
183
|
+
* `esbuildOptions` straight over it (`vite/dist/node/chunks/config.js`: `define: define$1,
|
|
184
|
+
* … …esbuildOptions,` — note `supported` gets an explicit deep-merge just below and
|
|
185
|
+
* `define` does not). So a bare `define` here REPLACES that map rather than adding to it,
|
|
186
|
+
* and pre-bundled deps lose the substitution.
|
|
187
|
+
*
|
|
188
|
+
* That is not academic: `@reduxjs/toolkit` resolves through its `module` condition to
|
|
189
|
+
* `redux-toolkit.modern.mjs` (57 bare `process.env.NODE_ENV` reads) plus `redux` (22),
|
|
190
|
+
* and `foundation-redux/src/store.ts` calls `configureStore` at module scope — so any app
|
|
191
|
+
* pulling in `@genesislcap/foundation-redux` would get `ReferenceError: process is not
|
|
192
|
+
* defined` out of the dep chunk. Dev only (`vite build` applies `define` through Rollup
|
|
193
|
+
* for node_modules too), which is exactly the path this change targets.
|
|
194
|
+
*
|
|
195
|
+
* Re-seeded before the spread. `depDefine` cannot collide with it: its keys are filtered
|
|
196
|
+
* to bare identifiers, and this one is dotted.
|
|
197
|
+
*/
|
|
198
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || (isDev ? 'development' : 'production')) }, depDefine),
|
|
199
|
+
},
|
|
149
200
|
},
|
|
150
201
|
base: publicPath,
|
|
151
202
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/vite-builder",
|
|
3
3
|
"description": "Vite builder",
|
|
4
|
-
"version": "15.22.
|
|
4
|
+
"version": "15.22.2",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint:fix": "genx lint -l ox --fix"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@genesislcap/build-kit": "15.22.
|
|
19
|
+
"@genesislcap/build-kit": "15.22.2",
|
|
20
20
|
"consola": "^3.0.2",
|
|
21
21
|
"copyfiles": "^2.4.1",
|
|
22
22
|
"vite": "^7.2.2",
|