@genesislcap/vite-builder 15.65.1-alpha-358eaead70.0 → 15.67.0

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.
@@ -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;yBA2CrC,KAAK,YAAY;AAAvC,wBAyQE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;yBA0CrC,KAAK,YAAY;AAAvC,wBA0OE"}
package/dist/index.js CHANGED
@@ -35,94 +35,21 @@ const VITE_DEFAULT_DEP_SCAN_ENTRIES = ['**/*.html', '!**/__tests__/**', '!**/cov
35
35
  exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
36
36
  var _a, _b, _c, _d;
37
37
  const { config: { app: { rootElement }, env, http, }, dirs: { cwd }, cli: { isDev, isBuild, isAnalyze, options: { open, https }, }, pkg: { description }, resolve: { alias }, } = ctx;
38
+ const define = (0, build_kit_1.resolveDefineConfig)(env, http, 'vite');
38
39
  /**
39
- * Everything derived from `process.env`. Returned from the `genesis-env` plugin's `config` hook
40
- * rather than baked into the inline config, so it is recomputed whenever Vite resolves config.
40
+ * The same map, narrowed to keys esbuild will accept as defines (see the `esbuildOptions` note in
41
+ * `optimizeDeps` below for why the optimizer needs it at all).
42
+ *
43
+ * `resolveDefineConfig` derives its keys from `process.env` via pattern match, so a machine with,
44
+ * say, `GENX-SOMETHING` set would produce a key that is not a valid JS identifier. Vite tolerates
45
+ * that in its own `define`; esbuild rejects the whole build. Filtering keeps a stray environment
46
+ * variable from turning into a hard build failure for everyone.
41
47
  */
42
- let publicPath = (0, build_kit_1.getPublicPath)();
43
- const envConfig = () => {
44
- const define = (0, build_kit_1.resolveDefineConfig)(env, http, 'vite');
45
- /**
46
- * The same map, narrowed to keys esbuild will accept as defines (see the `esbuildOptions` note
47
- * below for why the optimizer needs it at all).
48
- *
49
- * `resolveDefineConfig` derives its keys from `process.env` via pattern match, so a machine with,
50
- * say, `GENX-SOMETHING` set would produce a key that is not a valid JS identifier. Vite tolerates
51
- * that in its own `define`; esbuild rejects the whole build. Filtering keeps a stray environment
52
- * variable from turning into a hard build failure for everyone.
53
- */
54
- const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
55
- const depDefine = Object.fromEntries(Object.entries(define).filter(([key]) => IDENTIFIER.test(key)));
56
- publicPath = (0, build_kit_1.getPublicPath)();
57
- return {
58
- define,
59
- base: publicPath,
60
- optimizeDeps: {
61
- /**
62
- * GENC-1581 — the `define` above is applied when Vite TRANSFORMS source, but dependency
63
- * pre-bundling is a separate esbuild pass that does not inherit it. Any env-driven global
64
- * consumed from inside a pre-bundled dependency was therefore left as a bare identifier in
65
- * `node_modules/.vite/deps`, and silently resolved to `undefined` at runtime.
66
- *
67
- * MEASURED before this change: the served `@genesislcap/foundation-utils` chunk contained
68
- * `_DEFAULT_USER = DEFAULT_USER;` with no substitution, and the configured value appeared
69
- * nowhere in the bundle. `foundation-utils` reads these behind `try {} catch {}`, so the
70
- * resulting ReferenceError was swallowed and the variable simply stayed undefined — no
71
- * error, no warning, just a feature that never worked. `DEFAULT_USER`/`DEFAULT_PASSWORD`
72
- * (login pre-fill) is the case that surfaced it; every dependency-resident define was
73
- * equally affected. `API_HOST` masked the problem because `foundation-comms` falls back to
74
- * deriving it from `location`, and the dev proxy makes that fallback correct.
75
- *
76
- * Passing the same map to the optimizer's esbuild keeps source and dependencies consistent.
77
- * Vite hashes `optimizeDeps` into the dep-cache key, so changing a value re-optimizes rather
78
- * than silently serving a stale chunk.
79
- */
80
- esbuildOptions: {
81
- define: Object.assign({
82
- /**
83
- * Vite seeds its OWN optimizer define with `process.env.NODE_ENV` and then spreads
84
- * `esbuildOptions` straight over it (`vite/dist/node/chunks/config.js`: `define: define$1,
85
- * … …esbuildOptions,` — note `supported` gets an explicit deep-merge just below and
86
- * `define` does not). So a bare `define` here REPLACES that map rather than adding to it,
87
- * and pre-bundled deps lose the substitution.
88
- *
89
- * That is not academic: `@reduxjs/toolkit` resolves through its `module` condition to
90
- * `redux-toolkit.modern.mjs` (57 bare `process.env.NODE_ENV` reads) plus `redux` (22),
91
- * and `foundation-redux/src/store.ts` calls `configureStore` at module scope — so any app
92
- * pulling in `@genesislcap/foundation-redux` would get `ReferenceError: process is not
93
- * defined` out of the dep chunk. Dev only (`vite build` applies `define` through Rollup
94
- * for node_modules too), which is exactly the path this change targets.
95
- *
96
- * Re-seeded before the spread. `depDefine` cannot collide with it: its keys are filtered
97
- * to bare identifiers, and this one is dotted.
98
- */
99
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || (isDev ? 'development' : 'production')) }, depDefine),
100
- },
101
- },
102
- server: {
103
- proxy: (0, build_kit_1.createDevProxies)(),
104
- },
105
- };
106
- };
107
- /**
108
- * FUI-2654 — Vite already restarts the dev server in-process when a `.env` file in `envDir` (the
109
- * root) changes, but the restart re-resolves the same inline config object, so defines, `base`
110
- * and the proxy target captured at startup stayed stale until a manual restart. Plugin `config`
111
- * hooks DO re-run on every restart, so reload the env files and hand back fresh values here.
112
- */
113
- let isFirstConfig = true;
114
- const envPlugin = {
115
- name: 'genesis-env',
116
- config() {
117
- // The first resolve runs right after genx's own `setEnvVars`, which already loaded them
118
- if (!isFirstConfig)
119
- (0, build_kit_1.loadEnvFiles)(ctx);
120
- isFirstConfig = false;
121
- return envConfig();
122
- },
123
- };
48
+ const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
49
+ const depDefine = Object.fromEntries(Object.entries(define).filter(([key]) => IDENTIFIER.test(key)));
124
50
  const handlebars = yield (0, vite_js_1.getHandlebarsModule)();
125
51
  const vite = yield (0, vite_js_1.getViteModule)();
52
+ const publicPath = (0, build_kit_1.getPublicPath)();
126
53
  const tsconfigPath = (0, node_path_1.resolve)(cwd, 'tsconfig.json');
127
54
  const buildMode = (_c = (_b = (_a = ctx.config.vite) === null || _a === void 0 ? void 0 : _a.checker) === null || _b === void 0 ? void 0 : _b.buildMode) !== null && _c !== void 0 ? _c : false;
128
55
  const checkerPlugin = (0, node_fs_1.existsSync)(tsconfigPath)
@@ -140,7 +67,6 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
140
67
  };
141
68
  const config = {
142
69
  plugins: [
143
- envPlugin,
144
70
  baseHrefPlugin,
145
71
  ...(checkerPlugin ? [checkerPlugin] : []),
146
72
  handlebars({
@@ -206,6 +132,7 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
206
132
  '@genesislcap/pbc-reporting',
207
133
  ],
208
134
  },
135
+ define,
209
136
  build: {
210
137
  /**
211
138
  * Left to Vite's production default (esbuild for JS and CSS) unless the app opts out, matching
@@ -239,7 +166,48 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
239
166
  * reference, should we convert the above to a glob.
240
167
  */
241
168
  include: ['@genesis-community/golden-layout'],
169
+ /**
170
+ * GENC-1581 — the `define` above is applied when Vite TRANSFORMS source, but dependency
171
+ * pre-bundling is a separate esbuild pass that does not inherit it. Any env-driven global
172
+ * consumed from inside a pre-bundled dependency was therefore left as a bare identifier in
173
+ * `node_modules/.vite/deps`, and silently resolved to `undefined` at runtime.
174
+ *
175
+ * MEASURED before this change: the served `@genesislcap/foundation-utils` chunk contained
176
+ * `_DEFAULT_USER = DEFAULT_USER;` with no substitution, and the configured value appeared
177
+ * nowhere in the bundle. `foundation-utils` reads these behind `try {} catch {}`, so the
178
+ * resulting ReferenceError was swallowed and the variable simply stayed undefined — no
179
+ * error, no warning, just a feature that never worked. `DEFAULT_USER`/`DEFAULT_PASSWORD`
180
+ * (login pre-fill) is the case that surfaced it; every dependency-resident define was
181
+ * equally affected. `API_HOST` masked the problem because `foundation-comms` falls back to
182
+ * deriving it from `location`, and the dev proxy makes that fallback correct.
183
+ *
184
+ * Passing the same map to the optimizer's esbuild keeps source and dependencies consistent.
185
+ * Vite hashes `optimizeDeps` into the dep-cache key, so changing a value re-optimizes rather
186
+ * than silently serving a stale chunk.
187
+ */
188
+ esbuildOptions: {
189
+ define: Object.assign({
190
+ /**
191
+ * Vite seeds its OWN optimizer define with `process.env.NODE_ENV` and then spreads
192
+ * `esbuildOptions` straight over it (`vite/dist/node/chunks/config.js`: `define: define$1,
193
+ * … …esbuildOptions,` — note `supported` gets an explicit deep-merge just below and
194
+ * `define` does not). So a bare `define` here REPLACES that map rather than adding to it,
195
+ * and pre-bundled deps lose the substitution.
196
+ *
197
+ * That is not academic: `@reduxjs/toolkit` resolves through its `module` condition to
198
+ * `redux-toolkit.modern.mjs` (57 bare `process.env.NODE_ENV` reads) plus `redux` (22),
199
+ * and `foundation-redux/src/store.ts` calls `configureStore` at module scope — so any app
200
+ * pulling in `@genesislcap/foundation-redux` would get `ReferenceError: process is not
201
+ * defined` out of the dep chunk. Dev only (`vite build` applies `define` through Rollup
202
+ * for node_modules too), which is exactly the path this change targets.
203
+ *
204
+ * Re-seeded before the spread. `depDefine` cannot collide with it: its keys are filtered
205
+ * to bare identifiers, and this one is dotted.
206
+ */
207
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || (isDev ? 'development' : 'production')) }, depDefine),
208
+ },
242
209
  },
210
+ base: publicPath,
243
211
  };
244
212
  if (!(0, node_fs_1.existsSync)((0, node_path_1.resolve)(cwd, 'index.html'))) {
245
213
  consola_1.default.warn('index.html file not found - copying default one.');
@@ -252,6 +220,7 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
252
220
  open,
253
221
  host: '0.0.0.0',
254
222
  port: (0, build_kit_1.getPort)(ctx.pkg),
223
+ proxy: (0, build_kit_1.createDevProxies)(),
255
224
  https: https ? (0, build_kit_1.getDevCertOptions)() : undefined,
256
225
  } }));
257
226
  yield server.listen();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/vite-builder",
3
3
  "description": "Vite builder",
4
- "version": "15.65.1-alpha-358eaead70.0",
4
+ "version": "15.67.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -16,12 +16,12 @@
16
16
  "lint:fix": "genx lint -l ox --fix"
17
17
  },
18
18
  "dependencies": {
19
- "@genesislcap/build-kit": "15.65.1-alpha-358eaead70.0",
19
+ "@genesislcap/build-kit": "15.67.0",
20
20
  "consola": "^3.0.2",
21
21
  "copyfiles": "^2.4.1",
22
22
  "vite": "^7.2.2",
23
23
  "vite-plugin-checker": "^0.11.0",
24
- "vite-plugin-handlebars": "2.0.0"
24
+ "vite-plugin-handlebars": "^2.0.3"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",