create-octane-xplat 0.19.0 → 0.20.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.
- package/README.md +2 -147
- package/compatibility.json +74 -61
- package/compatibility.ts +134 -79
- package/dist/compatibility.js +45 -13
- package/dist/index.js +127 -64
- package/dist/package-manager.js +62 -0
- package/dist/scaffold.js +362 -57
- package/index.ts +256 -156
- package/library-template/AGENTS.md +1 -1
- package/library-template/README.md +4 -3
- package/library-template/bunfig +4 -0
- package/library-template/package.json +73 -70
- package/library-template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
- package/library-template/patches/@nativescript__core@9.1.3.patch +98 -0
- package/library-template/patches/@nativescript__vite@8.0.20.patch +532 -17
- package/library-template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/library-template/patches/octane@0.16.3.patch +56 -2
- package/library-template/src/Badge.tsx +5 -5
- package/library-template/src/Badge.web.tsx +5 -5
- package/library-template/src/Welcome.stories.tsx +12 -0
- package/library-template/src/normalizeBadgeLabel.ts +1 -1
- package/library-template/src/props.ts +11 -11
- package/library-template/tests/normalizeBadgeLabel.test.ts +1 -1
- package/library-template/tests/packed-consumer.mjs +140 -123
- package/library-template/tsconfig.envs.json +1 -0
- package/library-template/tsconfig.json +1 -0
- package/library-template/tsconfig.types.json +15 -1
- package/library-template/tsrx-typegen.json +1 -1
- package/library-template/workshop.config.ts +3 -0
- package/package-manager.ts +93 -0
- package/package.json +10 -5
- package/scaffold.ts +1061 -449
- package/template/.agents/skills/xplat/SKILL.md +1 -1
- package/template/.agents/skills/xplat/references/styling.md +10 -10
- package/template/AGENTS.md +2 -2
- package/template/bunfig +4 -0
- package/template/nativescript.config.ts +13 -13
- package/template/package.json +69 -64
- package/template/patches/@nativescript-community__octane@0.2.5.patch +161 -24
- package/template/patches/@nativescript__core@9.1.3.patch +98 -0
- package/template/patches/@nativescript__vite@8.0.20.patch +532 -17
- package/template/patches/@octane-xplat__nativescript-mason-core@1.0.0-beta.7.patch +65 -0
- package/template/patches/octane@0.16.3.patch +56 -2
- package/template/src/App.tsrx +66 -64
- package/template/src/Welcome.stories.tsx +22 -0
- package/template/src/app.spec.tsrx +168 -158
- package/template/src/app.web.test.tsx +18 -13
- package/template/src/failure-reporting.spec.ts +3 -3
- package/template/src/main.ts +14 -13
- package/template/src/main.tsrx +2 -0
- package/template/src/native-runtime.spec.ts +13 -11
- package/template/src/test-setup.web.ts +9 -8
- package/template/src/test.ts +6 -6
- package/template/tsconfig.json +17 -1
- package/template/vite.config.native.mts +1 -2
- package/template/vite.config.ts +29 -23
- package/template/vitest.config.mts +17 -17
- package/template/vitest.web.config.mts +7 -7
- package/template/workshop.config.ts +3 -0
- package/library-template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
- package/template/patches/@tsrx__typescript-plugin@0.4.11.patch +0 -11
- /package/library-template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
- /package/template/patches/{@octanejs__tiptap@0.0.61.patch → @octanejs__tiptap@0.0.62.patch} +0 -0
|
@@ -140,7 +140,7 @@ index 27013b5c8f78a72b6e6df903ac36f72fc0d75c1a..53a2e7d489ab91593cbec47ee6fb640f
|
|
|
140
140
|
const basePath = `${fullPath}${ext}`;
|
|
141
141
|
if (fs.existsSync(basePath)) {
|
|
142
142
|
diff --git a/helpers/typescript-check.js b/helpers/typescript-check.js
|
|
143
|
-
index a05696b679b3feecd1bafa267de44b59db559162..
|
|
143
|
+
index a05696b679b3feecd1bafa267de44b59db559162..e909d6e25b3142f48d13cae2f2c4c8c0dced36e7 100644
|
|
144
144
|
--- a/helpers/typescript-check.js
|
|
145
145
|
+++ b/helpers/typescript-check.js
|
|
146
146
|
@@ -7,14 +7,16 @@ import { getProjectRootPath, getProjectTSConfigPath } from './project.js';
|
|
@@ -163,6 +163,167 @@ index a05696b679b3feecd1bafa267de44b59db559162..06648067a3fcf7f8c74437a82b94ec01
|
|
|
163
163
|
}
|
|
164
164
|
return ['.native', ''];
|
|
165
165
|
}
|
|
166
|
+
@@ -29,13 +31,14 @@ function getVueTscBinPath() {
|
|
167
|
+
const pkgPath = require.resolve('vue-tsc/package.json');
|
|
168
|
+
return path.resolve(path.dirname(pkgPath), 'bin/vue-tsc.js');
|
|
169
|
+
}
|
|
170
|
+
-function getTsrxTscBinPath() {
|
|
171
|
+
+function getTscBinPath() {
|
|
172
|
+
try {
|
|
173
|
+
const projectRequire = createRequire(path.join(getProjectRootPath(), 'package.json'));
|
|
174
|
+
- const pkgPath = projectRequire.resolve('@tsrx/typescript-plugin/package.json');
|
|
175
|
+
+ const pkgPath = projectRequire.resolve('typescript/package.json');
|
|
176
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
177
|
+
- const bin = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.['tsrx-tsc'];
|
|
178
|
+
- return bin ? path.resolve(path.dirname(pkgPath), bin) : undefined;
|
|
179
|
+
+ const bin = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.['tsc'];
|
|
180
|
+
+ const major = Number.parseInt(String(pkg.version ?? ''), 10);
|
|
181
|
+
+ return bin && major >= 7 ? path.resolve(path.dirname(pkgPath), bin) : undefined;
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return undefined;
|
|
185
|
+
@@ -92,7 +95,7 @@ function runTsrxTypeCheck(binPath, opts, tsConfigPath, parsedConfig, rootNames,
|
|
186
|
+
try {
|
|
187
|
+
const configPath = path.join(tempDir, 'tsconfig.json');
|
|
188
|
+
fs.writeFileSync(configPath, JSON.stringify(createTsrxCheckConfig(tsConfigPath, parsedConfig, rootNames, opts.platform)));
|
|
189
|
+
- runTscBinary('tsrx-tsc', [binPath, '--pretty', '-p', configPath], opts, failOnError);
|
|
190
|
+
+ runTscBinary('tsc', [binPath, '--runExternalCode', '--pretty', '-p', configPath], opts, failOnError);
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
194
|
+
@@ -304,9 +307,9 @@ export function typescriptCheckPlugin(opts) {
|
|
195
|
+
const parsedConfig = getParsedConfig(ts, tsConfigPath, opts.platform);
|
|
196
|
+
const failOnError = shouldFailOnTypeCheckError(opts, parsedConfig);
|
|
197
|
+
const rootNames = parsedConfig.fileNames.filter((fileName) => !shouldSkipFileForPlatform(fileName, opts.platform));
|
|
198
|
+
- const tsrxTscBinPath = getTsrxTscBinPath();
|
|
199
|
+
- if (tsrxTscBinPath && hasTsrxImports(ts, rootNames)) {
|
|
200
|
+
- runTsrxTypeCheck(tsrxTscBinPath, opts, tsConfigPath, parsedConfig, rootNames, failOnError);
|
|
201
|
+
+ const tscBinPath = getTscBinPath();
|
|
202
|
+
+ if (tscBinPath && hasTsrxImports(ts, rootNames)) {
|
|
203
|
+
+ runTsrxTypeCheck(tscBinPath, opts, tsConfigPath, parsedConfig, rootNames, failOnError);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const program = ts.createProgram({
|
|
207
|
+
@@ -323,7 +326,7 @@ export function typescriptCheckPlugin(opts) {
|
|
208
|
+
}
|
|
209
|
+
if (opts.logDiagnostics !== false) {
|
|
210
|
+
if (hasUnresolvedTsrxImport(ts, diagnostics)) {
|
|
211
|
+
- console.warn('[ns-vite] Unresolved .tsrx imports: install @tsrx/typescript-plugin so the type check can run through tsrx-tsc.');
|
|
212
|
+
+ console.warn('[ns-vite] Unresolved .tsrx imports: install TypeScript 7.1 or newer so .tsrx files are checked through tsc --runExternalCode.');
|
|
213
|
+
}
|
|
214
|
+
const output = ts.formatDiagnosticsWithColorAndContext(diagnostics, getFormatHost(ts));
|
|
215
|
+
(failOnError ? console.error : console.warn)(output);
|
|
216
|
+
diff --git a/helpers/typescript.js b/helpers/typescript.js
|
|
217
|
+
index fe9c9fe948862def734df7bc5b817a9989155019..8d6b16a7043be959afaa0c1e16aefb09fbf2f142 100644
|
|
218
|
+
--- a/helpers/typescript.js
|
|
219
|
+
+++ b/helpers/typescript.js
|
|
220
|
+
@@ -6,23 +6,33 @@ let loaded;
|
|
221
|
+
* The compiler API backs the NativeClass ES5 downlevel and build-time type
|
|
222
|
+
* checking, but a plain JavaScript app has no reason to install `typescript`.
|
|
223
|
+
* Loading it on demand keeps every config helper importable without it; each
|
|
224
|
+
- * call site decides what to do when it is absent. The project's own copy is
|
|
225
|
+
- * preferred over one reachable from this package so type checking runs on the
|
|
226
|
+
- * version the app was written against.
|
|
227
|
+
+ * call site decides what to do when it is absent. Prefer the project's
|
|
228
|
+
+ * explicit classic API alias; a native TypeScript launcher is not an API.
|
|
229
|
+
+ * TSRX checking still delegates to the project's tsc --runExternalCode.
|
|
230
|
+
*/
|
|
231
|
+
export function loadTypeScript() {
|
|
232
|
+
- if (loaded !== undefined)
|
|
233
|
+
- return loaded;
|
|
234
|
+
- loaded = null;
|
|
235
|
+
+ if (loaded !== undefined) return loaded;
|
|
236
|
+
+ let incompatible = false;
|
|
237
|
+
for (const paths of [[getProjectRootPath()], undefined]) {
|
|
238
|
+
- try {
|
|
239
|
+
- loaded = require(require.resolve('typescript', paths ? { paths } : undefined));
|
|
240
|
+
- break;
|
|
241
|
+
+ for (const name of ['typescript-classic', 'typescript']) {
|
|
242
|
+
+ let candidate;
|
|
243
|
+
+ try {
|
|
244
|
+
+ candidate = require(require.resolve(name, paths ? { paths } : undefined));
|
|
245
|
+
+ } catch { continue; }
|
|
246
|
+
+ if (typeof candidate.transpileModule === 'function' && typeof candidate.getParsedCommandLineOfConfigFile === 'function') {
|
|
247
|
+
+ loaded = candidate;
|
|
248
|
+
+ return loaded;
|
|
249
|
+
+ }
|
|
250
|
+
+ incompatible = true;
|
|
251
|
+
}
|
|
252
|
+
- catch { }
|
|
253
|
+
}
|
|
254
|
+
+ if (incompatible) {
|
|
255
|
+
+ throw new Error('[ns-vite] Native TypeScript does not provide the classic compiler API used by NativeClass and config parsing. Install typescript-classic@npm:typescript@5.9.3; project typechecks can keep native TypeScript.');
|
|
256
|
+
+ }
|
|
257
|
+
+ loaded = null;
|
|
258
|
+
return loaded;
|
|
259
|
+
}
|
|
260
|
+
+
|
|
261
|
+
let warned = false;
|
|
262
|
+
/**
|
|
263
|
+
* Logged once per process. A `@NativeClass` source that is not downleveled
|
|
264
|
+
diff --git a/hmr/client/hot-context.js b/hmr/client/hot-context.js
|
|
265
|
+
index 120bc26fec96d1056701e4c3eb7b78987b40ab8f..f17cea64a1f0f8f87f4c0df856080789ddfa3c14 100644
|
|
266
|
+
--- a/hmr/client/hot-context.js
|
|
267
|
+
+++ b/hmr/client/hot-context.js
|
|
268
|
+
@@ -74,6 +74,47 @@ const VERBOSE = (() => {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
})();
|
|
272
|
+
+/**
|
|
273
|
+
+ * Dev-reload cancellation contract for dynamic imports.
|
|
274
|
+
+ *
|
|
275
|
+
+ * `ns:module` `invalidateModules` deliberately rejects every pending dynamic
|
|
276
|
+
+ * `import()` whose target was evicted, with a plain `Error` reading
|
|
277
|
+
+ * `Module invalidated during dev reload: <url>` (iOS
|
|
278
|
+
+ * `RejectResolversForInvalidation`, Android likewise). A whole-graph eviction
|
|
279
|
+
+ * (`jsFullReload` below) orphans every in-flight app `import()` (most
|
|
280
|
+
+ * visibly an entry's `void import(...)` issued after application start), and
|
|
281
|
+
+ * a targeted HMR eviction can orphan one too; nothing else owns those
|
|
282
|
+
+ * rejections, so each surfaces as a fatal unhandled rejection.
|
|
283
|
+
+ *
|
|
284
|
+
+ * The cancellation is issued by the dev machinery itself, so an *unhandled*
|
|
285
|
+
+ * one is owned here: `preventDefault()` suppresses only the fatal report. A
|
|
286
|
+
+ * call site that attached `.catch` still observes the rejection normally,
|
|
287
|
+
+ * and every other failure — fetch errors, evaluation throws, missing
|
|
288
|
+
+ * modules — reports exactly as before.
|
|
289
|
+
+ */
|
|
290
|
+
+const DEV_RELOAD_CANCELLATION_PREFIX = 'Module invalidated during dev reload:';
|
|
291
|
+
+// Duck-typed rather than `instanceof Error`: the rejected value can cross
|
|
292
|
+
+// module realms on device.
|
|
293
|
+
+function isDevReloadCancellation(reason) {
|
|
294
|
+
+ return (typeof reason === 'object' && reason !== null && typeof reason.message === 'string' &&
|
|
295
|
+
+ reason.message.startsWith(DEV_RELOAD_CANCELLATION_PREFIX));
|
|
296
|
+
+}
|
|
297
|
+
+function installDevReloadRejectionFilter(g) {
|
|
298
|
+
+ try {
|
|
299
|
+
+ if (typeof g.addEventListener !== 'function' || g.__NS_DEV_RELOAD_REJECTION_FILTER__)
|
|
300
|
+
+ return;
|
|
301
|
+
+ g.__NS_DEV_RELOAD_REJECTION_FILTER__ = true;
|
|
302
|
+
+ g.addEventListener('unhandledrejection', (event) => {
|
|
303
|
+
+ const reason = event?.reason;
|
|
304
|
+
+ if (!isDevReloadCancellation(reason))
|
|
305
|
+
+ return;
|
|
306
|
+
+ if (VERBOSE)
|
|
307
|
+
+ console.info('[ns-hot] dev reload cancelled an in-flight import:', reason.message);
|
|
308
|
+
+ event.preventDefault();
|
|
309
|
+
+ });
|
|
310
|
+
+ }
|
|
311
|
+
+ catch { }
|
|
312
|
+
+}
|
|
313
|
+
function createRegistry() {
|
|
314
|
+
const modules = new Map();
|
|
315
|
+
const eventListeners = new Map();
|
|
316
|
+
@@ -384,6 +425,10 @@ function createRegistry() {
|
|
317
|
+
*/
|
|
318
|
+
export function installNsHotRegistry() {
|
|
319
|
+
const g = globalThis;
|
|
320
|
+
+ // The dev machinery owns the deliberate `invalidateModules` cancellation
|
|
321
|
+
+ // regardless of which copy installs the registry — install the filter
|
|
322
|
+
+ // even when another realm already seeded `__NS_HOT_REGISTRY__`.
|
|
323
|
+
+ installDevReloadRejectionFilter(g);
|
|
324
|
+
if (g.__NS_HOT_REGISTRY__ && typeof g.__NS_HOT_REGISTRY__.createHotContext === 'function') {
|
|
325
|
+
return g.__NS_HOT_REGISTRY__;
|
|
326
|
+
}
|
|
166
327
|
diff --git a/hmr/helpers/ast-normalizer.js b/hmr/helpers/ast-normalizer.js
|
|
167
328
|
index 77f5533a289902b644f2dba4c8a558f5a00c8314..5c1d57f34a5e863ae3e684012a99f9bb8796e974 100644
|
|
168
329
|
--- a/hmr/helpers/ast-normalizer.js
|
|
@@ -201,10 +362,10 @@ index 0d7cd968eac690a85411cf3d6a24323a3d3a3992..98094d6ccfb918d00249d8087aebdd99
|
|
|
201
362
|
//# sourceMappingURL=css-device-module.js.map
|
|
202
363
|
|
|
203
364
|
diff --git a/hmr/server/deps-bundle.js b/hmr/server/deps-bundle.js
|
|
204
|
-
index 395c29e9b9b552fbf30c4a7131121a0d841df116..
|
|
365
|
+
index 395c29e9b9b552fbf30c4a7131121a0d841df116..e2523548534dda72042efe318beeeb05c05f73e5 100644
|
|
205
366
|
--- a/hmr/server/deps-bundle.js
|
|
206
367
|
+++ b/hmr/server/deps-bundle.js
|
|
207
|
-
@@ -53,
|
|
368
|
+
@@ -53,21 +53,22 @@
|
|
208
369
|
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
209
370
|
import * as path from 'node:path';
|
|
210
371
|
import { createHash } from 'node:crypto';
|
|
@@ -223,6 +384,13 @@ index 395c29e9b9b552fbf30c4a7131121a0d841df116..78d0bef8eeeaa2a55eec461adb6b1ac9
|
|
|
223
384
|
import { getVendorManifest, setVendorRuntimeModuleProvider } from '../shared/vendor/registry.js';
|
|
224
385
|
import { collectVendorModules } from '../shared/vendor/manifest-collect.js';
|
|
225
386
|
import { generatePlatformPolyfills } from '../shared/runtime/platform-polyfills.js';
|
|
387
|
+
import { getAngularLinkerFactory, runAngularLinker } from '../frameworks/angular/build/shared-linker.js';
|
|
388
|
+
import { getBlockedDeviceNodeModulesReason, isFlavorClientPackageSpecifier, resolveCandidateFilePath } from './websocket-module-specifiers.js';
|
|
389
|
+
-import { extractDirectExportedNames, JS_IDENTIFIER_RE, parseExportSpecList } from './websocket-core-bridge.js';
|
|
390
|
+
+import { extractDirectExportedNames, JS_IDENTIFIER_RE, maskJsComments, parseExportSpecList } from './websocket-core-bridge.js';
|
|
391
|
+
import { hasExistingDefaultExport } from './ns-core-cjs-shape.js';
|
|
392
|
+
import { getCjsNamedExports } from '../helpers/cjs-named-exports.js';
|
|
393
|
+
import { loadPersistedBootRecording } from './boot-recording.js';
|
|
226
394
|
@@ -537,6 +538,7 @@ export function computeDepsBundleCacheKey(input) {
|
|
227
395
|
defines: input.defines,
|
|
228
396
|
entryKeys: input.entryKeys,
|
|
@@ -281,6 +449,68 @@ index 395c29e9b9b552fbf30c4a7131121a0d841df116..78d0bef8eeeaa2a55eec461adb6b1ac9
|
|
|
281
449
|
createOptionalDependencyStubEsbuildPlugin(projectRoot),
|
|
282
450
|
createNativeAddonStubEsbuildPlugin(),
|
|
283
451
|
];
|
|
452
|
+
@@ -793,7 +824,15 @@ export async function generateDepsBundle(options) {
|
|
453
|
+
}
|
|
454
|
+
return state;
|
|
455
|
+
}
|
|
456
|
+
-const ESM_SYNTAX_RE = /^[ \t]*(?:import[\s{"'*]|export[\s{*])/m;
|
|
457
|
+
+// ESM markers can sit anywhere on a line — minified chunks emit
|
|
458
|
+
+// `...;export{mt as g};` after other statements, and a line-anchored check
|
|
459
|
+
+// misclassifies them as opaque CJS (the served shim then drops every named
|
|
460
|
+
+// export). The pattern runs against a copy with comments and string/template/
|
|
461
|
+
+// regex literal interiors blanked (positions preserved), so look-alike text
|
|
462
|
+
+// inside literals can never match. The lookbehind keeps `$export`-style
|
|
463
|
+
+// identifiers and `obj.import`/`obj.export` member access from matching.
|
|
464
|
+
+const ESM_PREFIX = '(?<![.$\\u200c\\u200d\\p{ID_Continue}])';
|
|
465
|
+
+const ESM_SYNTAX_RE = new RegExp(ESM_PREFIX + String.raw`(?:import[\s{"'*]|export[\s{*])`, 'u');
|
|
466
|
+
function resolveLocalReExportTarget(spec, importerPath, platform) {
|
|
467
|
+
const base = path.resolve(path.dirname(importerPath), spec);
|
|
468
|
+
if (existsSync(base) && statSync(base).isFile())
|
|
469
|
+
@@ -881,23 +920,35 @@ export function collectDepsModuleExportInfo(absPath, platform, seen = new Set())
|
|
470
|
+
catch {
|
|
471
|
+
return { names: null, hasDefault: false };
|
|
472
|
+
}
|
|
473
|
+
- if (!/\.mjs$/i.test(absPath) && !ESM_SYNTAX_RE.test(code))
|
|
474
|
+
+ const maskedCode = maskJsComments(code, true);
|
|
475
|
+
+ if (!/\.mjs$/i.test(absPath) && !ESM_SYNTAX_RE.test(maskedCode))
|
|
476
|
+
return collectCjsExportInfo(code);
|
|
477
|
+
- const names = new Set(extractDirectExportedNames(code));
|
|
478
|
+
+ const names = new Set(extractDirectExportedNames(maskedCode));
|
|
479
|
+
let match;
|
|
480
|
+
- const starAsRe = /\bexport\s+\*\s+as\s+([$_\p{ID_Start}][$\p{ID_Continue}]*)\s+from\s+["'][^"']+["']/gu;
|
|
481
|
+
- while ((match = starAsRe.exec(code)) !== null) {
|
|
482
|
+
+ // Minifiers drop the spaces `export * as ns from "x"` keeps — allow none.
|
|
483
|
+
+ const starAsRe = new RegExp(ESM_PREFIX + String.raw`export\s*\*\s*as\s+([$_\p{ID_Start}][$\p{ID_Continue}]*)\s+from\s*["'][^"']*["']`, 'gu');
|
|
484
|
+
+ while ((match = starAsRe.exec(maskedCode)) !== null) {
|
|
485
|
+
names.add(match[1]);
|
|
486
|
+
}
|
|
487
|
+
- const braceRe = /\bexport\s*\{([^}]+)\}/g;
|
|
488
|
+
- while ((match = braceRe.exec(code)) !== null) {
|
|
489
|
+
+ const braceRe = new RegExp(ESM_PREFIX + String.raw`export\s*\{([^}]+)\}`, 'gu');
|
|
490
|
+
+ while ((match = braceRe.exec(maskedCode)) !== null) {
|
|
491
|
+
for (const { exportedName } of parseExportSpecList(match[1])) {
|
|
492
|
+
names.add(exportedName);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
- const starRe = /^[ \t]*export\s+\*\s+from\s+["']([^"']+)["']/gm;
|
|
496
|
+
- while ((match = starRe.exec(code)) !== null) {
|
|
497
|
+
- const spec = match[1];
|
|
498
|
+
+ // `export * from` carries the same mid-line minification hazard — find it
|
|
499
|
+
+ // on the masked copy, then read the specifier literal from the original
|
|
500
|
+
+ // code at the same offset (masked interiors are blanked).
|
|
501
|
+
+ const starRe = new RegExp(ESM_PREFIX + String.raw`export\s*\*\s*from\s*(["'])`, 'gu');
|
|
502
|
+
+ while ((match = starRe.exec(maskedCode)) !== null) {
|
|
503
|
+
+ const quoteIndex = match.index + match[0].length - 1;
|
|
504
|
+
+ const quote = match[1];
|
|
505
|
+
+ let specEnd = quoteIndex + 1;
|
|
506
|
+
+ while (specEnd < code.length && code[specEnd] !== quote)
|
|
507
|
+
+ specEnd += code[specEnd] === '\\' ? 2 : 1;
|
|
508
|
+
+ if (specEnd >= code.length)
|
|
509
|
+
+ return { names: null, hasDefault: false };
|
|
510
|
+
+ const spec = code.slice(quoteIndex + 1, specEnd);
|
|
511
|
+
const target = spec.startsWith('.') ? resolveLocalReExportTarget(spec, absPath, platform) : resolveBareReExportTarget(spec, absPath, platform);
|
|
512
|
+
if (!target)
|
|
513
|
+
return { names: null, hasDefault: false };
|
|
284
514
|
diff --git a/hmr/server/device-transform-helpers.js b/hmr/server/device-transform-helpers.js
|
|
285
515
|
index 71574c48f655183af0c9601b020fd1febd63ccb3..0061d9c9e9fe9c6034576eae8449831d19f8ace7 100644
|
|
286
516
|
--- a/hmr/server/device-transform-helpers.js
|
|
@@ -664,6 +894,53 @@ index 51ad398cefe75c918e887bd9506d9152259b957e..57dc2be15705a5ac8b5393852fd5de41
|
|
|
664
894
|
if (httpOriginSafe) {
|
|
665
895
|
return `${prefix}${httpOriginSafe}${httpSpec}${suffix}`;
|
|
666
896
|
}
|
|
897
|
+
diff --git a/hmr/server/transform-cache-invalidation.js b/hmr/server/transform-cache-invalidation.js
|
|
898
|
+
index c4ee7fbd75d8e630e1702b08f4c1b6f7fc4f27bd..27a2e64215c592eec176fe9fdc6f5ccad7a8ca51 100644
|
|
899
|
+
--- a/hmr/server/transform-cache-invalidation.js
|
|
900
|
+
+++ b/hmr/server/transform-cache-invalidation.js
|
|
901
|
+
@@ -1,3 +1,4 @@
|
|
902
|
+
+import { statSync } from 'node:fs';
|
|
903
|
+
import { isRuntimeGraphExcludedPath, normalizeRuntimeGraphPath } from './runtime-graph-filter.js';
|
|
904
|
+
// Framework-agnostic transform-cache-invalidation primitives shared by the
|
|
905
|
+
// per-flavor `handleHotUpdate` tails (Angular + Solid today). They live in this
|
|
906
|
+
@@ -153,4 +154,36 @@ export function collectTransitiveImportersForInvalidation(options) {
|
|
907
|
+
}
|
|
908
|
+
return Array.from(collected.values());
|
|
909
|
+
}
|
|
910
|
+
+
|
|
911
|
+
+const servedFileFingerprints = new Map();
|
|
912
|
+
+/**
|
|
913
|
+
+ * Out-of-band mutation sentinel for served dependency files. Vite's watcher
|
|
914
|
+
+ * excludes node_modules, so a pnpm/bun patch install (or a manual
|
|
915
|
+
+ * node_modules edit) rewrites dependency sources without a file event —
|
|
916
|
+
+ * `handleHotUpdate` never runs and both transform caches keep serving the
|
|
917
|
+
+ * pre-install output. The `/ns/m` pipeline fingerprints each resolved
|
|
918
|
+
+ * dependency file the first time the dev server sees it and reports a change
|
|
919
|
+
+ * when (mtimeMs, size) differs on a later request; the caller invalidates the
|
|
920
|
+
+ * file's caches before re-transforming. The fingerprint records whatever was
|
|
921
|
+
+ * on disk at first serve, so only subsequent mutations count. A rewrite that
|
|
922
|
+
+ * preserves both mtime and byte size stays undetected — the documented bound
|
|
923
|
+
+ * of this check.
|
|
924
|
+
+ */
|
|
925
|
+
+export function servedDependencyFileChanged(file) {
|
|
926
|
+
+ let stat;
|
|
927
|
+
+ try {
|
|
928
|
+
+ stat = statSync(file);
|
|
929
|
+
+ }
|
|
930
|
+
+ catch {
|
|
931
|
+
+ return false;
|
|
932
|
+
+ }
|
|
933
|
+
+ if (!stat.isFile()) {
|
|
934
|
+
+ return false;
|
|
935
|
+
+ }
|
|
936
|
+
+ const key = file.replace(/\\/g, '/');
|
|
937
|
+
+ const fingerprint = `${stat.mtimeMs}:${stat.size}`;
|
|
938
|
+
+ const previous = servedFileFingerprints.get(key);
|
|
939
|
+
+ servedFileFingerprints.set(key, fingerprint);
|
|
940
|
+
+ return previous !== undefined && previous !== fingerprint;
|
|
941
|
+
+}
|
|
942
|
+
//# sourceMappingURL=transform-cache-invalidation.js.map
|
|
943
|
+
|
|
667
944
|
diff --git a/hmr/server/vite-plugin.js b/hmr/server/vite-plugin.js
|
|
668
945
|
index 15c6c7293826767ce7fd45feb6b03cb64a4bdbb5..1f66ca8ae896fad9ee21eabdf3bb75f609bd7132 100644
|
|
669
946
|
--- a/hmr/server/vite-plugin.js
|
|
@@ -687,6 +964,148 @@ index 15c6c7293826767ce7fd45feb6b03cb64a4bdbb5..1f66ca8ae896fad9ee21eabdf3bb75f6
|
|
|
687
964
|
},
|
|
688
965
|
resolveId(id) {
|
|
689
966
|
if (id === VIRTUAL_ID)
|
|
967
|
+
diff --git a/hmr/server/websocket-core-bridge.js b/hmr/server/websocket-core-bridge.js
|
|
968
|
+
index 0d58dfc3e2254656cd910ddf2dde7845dd1cf595..8d57de97e60bbab854737f33391c2c6e345c64de 100644
|
|
969
|
+
--- a/hmr/server/websocket-core-bridge.js
|
|
970
|
+
+++ b/hmr/server/websocket-core-bridge.js
|
|
971
|
+
@@ -12,10 +12,12 @@ const REGEX_PRECEDING_KEYWORD_RE = /(?:^|[^$\w])(?:return|typeof|instanceof|in|o
|
|
972
|
+
/**
|
|
973
|
+
* Blank line and block comments (preserving newlines) so the regex export
|
|
974
|
+
* scanners never see a commented-out `export` declaration. String, template
|
|
975
|
+
- * and regex literals are skipped so their contents are left intact.
|
|
976
|
+
+ * and regex literals are skipped so their contents are left intact — pass
|
|
977
|
+
+ * `literals` to blank their interiors too (keeping quotes/positions) so the
|
|
978
|
+
+ * scanners can also trust keyword matches as real syntax.
|
|
979
|
+
*/
|
|
980
|
+
-export function maskJsComments(code) {
|
|
981
|
+
- if (!code || (code.indexOf('//') === -1 && code.indexOf('/*') === -1)) {
|
|
982
|
+
+export function maskJsComments(code, literals = false) {
|
|
983
|
+
+ if (!code || (!literals && code.indexOf('//') === -1 && code.indexOf('/*') === -1)) {
|
|
984
|
+
return code;
|
|
985
|
+
}
|
|
986
|
+
const chars = code.split('');
|
|
987
|
+
@@ -38,6 +40,82 @@ export function maskJsComments(code) {
|
|
988
|
+
return true;
|
|
989
|
+
return REGEX_PRECEDING_KEYWORD_RE.test(code.slice(Math.max(0, j - 10), j + 1));
|
|
990
|
+
};
|
|
991
|
+
+ // Skip a regex literal starting at `at`; returns the index just past it.
|
|
992
|
+
+ const skipRegex = (at) => {
|
|
993
|
+
+ let j = at + 1;
|
|
994
|
+
+ let inClass = false;
|
|
995
|
+
+ while (j < n && code[j] !== '\n') {
|
|
996
|
+
+ const r = code[j];
|
|
997
|
+
+ if (r === '\\') {
|
|
998
|
+
+ j += 2;
|
|
999
|
+
+ continue;
|
|
1000
|
+
+ }
|
|
1001
|
+
+ if (r === '[')
|
|
1002
|
+
+ inClass = true;
|
|
1003
|
+
+ else if (r === ']')
|
|
1004
|
+
+ inClass = false;
|
|
1005
|
+
+ else if (r === '/' && !inClass)
|
|
1006
|
+
+ break;
|
|
1007
|
+
+ j++;
|
|
1008
|
+
+ }
|
|
1009
|
+
+ return j + 1;
|
|
1010
|
+
+ };
|
|
1011
|
+
+ // Skip a string/template literal starting at `at`; returns the index just
|
|
1012
|
+
+ // past it. Template `${}` expressions may hold nested literals, comments
|
|
1013
|
+
+ // and regexes — a naive next-backtick scan closes early and desyncs every
|
|
1014
|
+
+ // later literal (`...it's...` inside a template opened a fake string).
|
|
1015
|
+
+ const skipQuoted = (at) => {
|
|
1016
|
+
+ const quote = code[at];
|
|
1017
|
+
+ let j = at + 1;
|
|
1018
|
+
+ if (quote !== '`') {
|
|
1019
|
+
+ while (j < n && code[j] !== quote)
|
|
1020
|
+
+ j += code[j] === '\\' ? 2 : 1;
|
|
1021
|
+
+ return j + 1;
|
|
1022
|
+
+ }
|
|
1023
|
+
+ while (j < n) {
|
|
1024
|
+
+ const t = code[j];
|
|
1025
|
+
+ if (t === '\\') {
|
|
1026
|
+
+ j += 2;
|
|
1027
|
+
+ continue;
|
|
1028
|
+
+ }
|
|
1029
|
+
+ if (t === '`')
|
|
1030
|
+
+ return j + 1;
|
|
1031
|
+
+ if (t === '$' && code[j + 1] === '{') {
|
|
1032
|
+
+ j += 2;
|
|
1033
|
+
+ let depth = 1;
|
|
1034
|
+
+ while (j < n && depth) {
|
|
1035
|
+
+ const e = code[j];
|
|
1036
|
+
+ const e2 = code[j + 1];
|
|
1037
|
+
+ if (e === "'" || e === '"' || e === '`') {
|
|
1038
|
+
+ j = skipQuoted(j);
|
|
1039
|
+
+ continue;
|
|
1040
|
+
+ }
|
|
1041
|
+
+ if (e === '/' && e2 === '/') {
|
|
1042
|
+
+ const eol = code.indexOf('\n', j);
|
|
1043
|
+
+ j = eol === -1 ? n : eol;
|
|
1044
|
+
+ continue;
|
|
1045
|
+
+ }
|
|
1046
|
+
+ if (e === '/' && e2 === '*') {
|
|
1047
|
+
+ const close = code.indexOf('*/', j + 2);
|
|
1048
|
+
+ j = close === -1 ? n : close + 2;
|
|
1049
|
+
+ continue;
|
|
1050
|
+
+ }
|
|
1051
|
+
+ if (e === '/' && slashStartsRegex(j)) {
|
|
1052
|
+
+ j = skipRegex(j);
|
|
1053
|
+
+ continue;
|
|
1054
|
+
+ }
|
|
1055
|
+
+ if (e === '{')
|
|
1056
|
+
+ depth++;
|
|
1057
|
+
+ else if (e === '}')
|
|
1058
|
+
+ depth--;
|
|
1059
|
+
+ j++;
|
|
1060
|
+
+ }
|
|
1061
|
+
+ continue;
|
|
1062
|
+
+ }
|
|
1063
|
+
+ j++;
|
|
1064
|
+
+ }
|
|
1065
|
+
+ return j;
|
|
1066
|
+
+ };
|
|
1067
|
+
let i = 0;
|
|
1068
|
+
while (i < n) {
|
|
1069
|
+
const c = code[i];
|
|
1070
|
+
@@ -55,30 +133,16 @@ export function maskJsComments(code) {
|
|
1071
|
+
i = stop;
|
|
1072
|
+
}
|
|
1073
|
+
else if (c === "'" || c === '"' || c === '`') {
|
|
1074
|
+
- i++;
|
|
1075
|
+
- while (i < n && code[i] !== c) {
|
|
1076
|
+
- i += code[i] === '\\' ? 2 : 1;
|
|
1077
|
+
- }
|
|
1078
|
+
- i++;
|
|
1079
|
+
+ const start = i;
|
|
1080
|
+
+ i = skipQuoted(i);
|
|
1081
|
+
+ if (literals)
|
|
1082
|
+
+ blank(start + 1, i - 1);
|
|
1083
|
+
}
|
|
1084
|
+
else if (c === '/' && slashStartsRegex(i)) {
|
|
1085
|
+
- i++;
|
|
1086
|
+
- let inClass = false;
|
|
1087
|
+
- while (i < n && code[i] !== '\n') {
|
|
1088
|
+
- const r = code[i];
|
|
1089
|
+
- if (r === '\\') {
|
|
1090
|
+
- i += 2;
|
|
1091
|
+
- continue;
|
|
1092
|
+
- }
|
|
1093
|
+
- if (r === '[')
|
|
1094
|
+
- inClass = true;
|
|
1095
|
+
- else if (r === ']')
|
|
1096
|
+
- inClass = false;
|
|
1097
|
+
- else if (r === '/' && !inClass)
|
|
1098
|
+
- break;
|
|
1099
|
+
- i++;
|
|
1100
|
+
- }
|
|
1101
|
+
- i++;
|
|
1102
|
+
+ const start = i;
|
|
1103
|
+
+ i = skipRegex(i);
|
|
1104
|
+
+ if (literals)
|
|
1105
|
+
+ blank(start, i);
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
i++;
|
|
690
1109
|
diff --git a/hmr/server/websocket-module-bindings.js b/hmr/server/websocket-module-bindings.js
|
|
691
1110
|
index 00b89ff3ae13b1c2b219a4c35c0450f97ac5ffc9..54c8716bfc5c9a6e2cd9cbee7bbbe9c7fb971943 100644
|
|
692
1111
|
--- a/hmr/server/websocket-module-bindings.js
|
|
@@ -928,7 +1347,7 @@ index 0081819906b9df7480408697b1afadb149e26e31..ae7ef0adf8b810cbeff74f26bce242d7
|
|
|
928
1347
|
//# sourceMappingURL=websocket-module-specifiers.js.map
|
|
929
1348
|
|
|
930
1349
|
diff --git a/hmr/server/websocket-ns-m-request.js b/hmr/server/websocket-ns-m-request.js
|
|
931
|
-
index 0879633dc5ee172f16de82d5d24bebe2f6f7878f..
|
|
1350
|
+
index 0879633dc5ee172f16de82d5d24bebe2f6f7878f..2c3a7476b1fda40bb454aca5041829a095cb4610 100644
|
|
932
1351
|
--- a/hmr/server/websocket-ns-m-request.js
|
|
933
1352
|
+++ b/hmr/server/websocket-ns-m-request.js
|
|
934
1353
|
@@ -27,10 +27,15 @@ const MODULE_CANDIDATE_EXTS = ['ts', 'js', 'tsx', 'jsx', 'mjs', 'mts', 'cts', 'v
|
|
@@ -949,7 +1368,56 @@ index 0879633dc5ee172f16de82d5d24bebe2f6f7878f..b489d7f1524eb35ba87206d86cdb9448
|
|
|
949
1368
|
}
|
|
950
1369
|
candidates.push(...MODULE_CANDIDATE_EXTS.map((ext) => `${base}.${ext}`));
|
|
951
1370
|
}
|
|
952
|
-
@@ -
|
|
1371
|
+
@@ -163,6 +168,24 @@ export function resolveFsAnchoredSpec(spec, serverRoot, workspaceRoot) {
|
|
1372
|
+
export async function resolveNsMTransformedModule(options) {
|
|
1373
|
+
const { context, transformRequest, resolveId, loadVirtualId, timeoutMs = 120000 } = options;
|
|
1374
|
+
const { spec, serverRoot, workspaceRoot, transformCandidates } = context;
|
|
1375
|
+
+ const notifyServedDependencyFile = options.notifyServedDependencyFile;
|
|
1376
|
+
+ // Dependency files can change without a Vite file event (patch installs
|
|
1377
|
+
+ // rewrite node_modules out of band). Report each resolved node_modules
|
|
1378
|
+
+ // path the pipeline is about to transform so the caller can compare it
|
|
1379
|
+
+ // with the fingerprint of what the caches last served and invalidate on
|
|
1380
|
+
+ // drift — see servedDependencyFileChanged in transform-cache-invalidation.
|
|
1381
|
+
+ const noteServedDependencyFile = (candidate) => {
|
|
1382
|
+
+ if (!notifyServedDependencyFile || !candidate.replace(/[?#].*$/, '').includes('/node_modules/')) {
|
|
1383
|
+
+ return;
|
|
1384
|
+
+ }
|
|
1385
|
+
+ try {
|
|
1386
|
+
+ const resolved = resolveCandidateFilePath(candidate, serverRoot, workspaceRoot);
|
|
1387
|
+
+ if (resolved) {
|
|
1388
|
+
+ notifyServedDependencyFile(resolved);
|
|
1389
|
+
+ }
|
|
1390
|
+
+ }
|
|
1391
|
+
+ catch { }
|
|
1392
|
+
+ };
|
|
1393
|
+
let transformed = null;
|
|
1394
|
+
let resolvedCandidate = null;
|
|
1395
|
+
if (spec.startsWith('/@id/')) {
|
|
1396
|
+
@@ -190,6 +213,7 @@ export async function resolveNsMTransformedModule(options) {
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
for (const candidate of transformCandidates) {
|
|
1400
|
+
+ noteServedDependencyFile(candidate);
|
|
1401
|
+
transformed = await tryTransformRequest(transformRequest, candidate, timeoutMs);
|
|
1402
|
+
if (transformed?.code) {
|
|
1403
|
+
resolvedCandidate = candidate;
|
|
1404
|
+
@@ -198,6 +222,7 @@ export async function resolveNsMTransformedModule(options) {
|
|
1405
|
+
}
|
|
1406
|
+
const resolvedId = await resolveId(spec);
|
|
1407
|
+
if (resolvedId) {
|
|
1408
|
+
+ noteServedDependencyFile(resolvedId);
|
|
1409
|
+
transformed = await tryTransformRequest(transformRequest, resolvedId, timeoutMs);
|
|
1410
|
+
if (transformed?.code) {
|
|
1411
|
+
return { transformed, resolvedCandidate: resolvedId };
|
|
1412
|
+
@@ -209,6 +234,7 @@ export async function resolveNsMTransformedModule(options) {
|
|
1413
|
+
if (bareSpecifier && !bareSpecifier.startsWith('.')) {
|
|
1414
|
+
const resolvedBareId = await resolveId(bareSpecifier);
|
|
1415
|
+
if (resolvedBareId) {
|
|
1416
|
+
+ noteServedDependencyFile(resolvedBareId);
|
|
1417
|
+
transformed = await tryTransformRequest(transformRequest, resolvedBareId, timeoutMs);
|
|
1418
|
+
if (transformed?.code) {
|
|
1419
|
+
return { transformed, resolvedCandidate: resolvedBareId };
|
|
1420
|
+
@@ -216,14 +242,19 @@ export async function resolveNsMTransformedModule(options) {
|
|
953
1421
|
}
|
|
954
1422
|
}
|
|
955
1423
|
}
|
|
@@ -960,14 +1428,30 @@ index 0879633dc5ee172f16de82d5d24bebe2f6f7878f..b489d7f1524eb35ba87206d86cdb9448
|
|
|
960
1428
|
+ for (const candidate of new Set([spec, ...transformCandidates])) {
|
|
961
1429
|
+ const fsId = resolveFsAnchoredSpec(candidate, serverRoot, workspaceRoot);
|
|
962
1430
|
+ if (!fsId) continue;
|
|
1431
|
+
+ noteServedDependencyFile(fsId);
|
|
963
1432
|
transformed = await tryTransformRequest(transformRequest, fsId, timeoutMs);
|
|
964
1433
|
if (transformed?.code) {
|
|
965
1434
|
return { transformed, resolvedCandidate: fsId };
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
for (const candidate of transformCandidates) {
|
|
1438
|
+
+ noteServedDependencyFile(candidate);
|
|
1439
|
+
const importHintCandidate = `${candidate}${candidate.includes('?') ? '&' : '?'}import`;
|
|
1440
|
+
transformed = await tryTransformRequest(transformRequest, importHintCandidate, timeoutMs);
|
|
1441
|
+
if (transformed?.code) {
|
|
966
1442
|
diff --git a/hmr/server/websocket-ns-m.js b/hmr/server/websocket-ns-m.js
|
|
967
|
-
index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..
|
|
1443
|
+
index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ec7c439dcd29af5c341b0bc0146243b7855d2a7f 100644
|
|
968
1444
|
--- a/hmr/server/websocket-ns-m.js
|
|
969
1445
|
+++ b/hmr/server/websocket-ns-m.js
|
|
970
|
-
@@ -
|
|
1446
|
+
@@ -6,6 +6,7 @@ import { isRuntimeGraphExcludedPath } from './runtime-graph-filter.js';
|
|
1447
|
+
import { buildPiniaVendorShim, buildVueVendorShim } from './vendor-bare-module-shims.js';
|
|
1448
|
+
import { collapseLegacyNsMTags } from './websocket-ns-m-paths.js';
|
|
1449
|
+
import { createNsMRequestContext, resolveFsAnchoredSpec, resolveNsMTransformedModule } from './websocket-ns-m-request.js';
|
|
1450
|
+
+import { purgeTransformCachesForHotUpdate, servedDependencyFileChanged } from './transform-cache-invalidation.js';
|
|
1451
|
+
import { setDeviceModuleHeaders } from './route-helpers.js';
|
|
1452
|
+
import { RAW_QUERY_PATTERN } from './constants.js';
|
|
1453
|
+
import { CSS_MODULE_RE, buildCssRegisterSnippetFromVar, normalizeCssForDevice } from './css-device-module.js';
|
|
1454
|
+
@@ -98,7 +99,7 @@ export function registerNsModuleServerRoute(server, options) {
|
|
971
1455
|
// internal virtual modules (e.g., \0nsvite:nsconfig-json for
|
|
972
1456
|
// ~/package.json) that don't exist on disk and must NOT run
|
|
973
1457
|
// through the device post-processing pipeline below.
|
|
@@ -976,7 +1460,7 @@ index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ac33b017b65489472c3573ce45f89bb9
|
|
|
976
1460
|
try {
|
|
977
1461
|
// First try Vite's transform pipeline directly
|
|
978
1462
|
const vr = await sharedTransformRequest(spec);
|
|
979
|
-
@@ -167,8 +
|
|
1463
|
+
@@ -167,8 +168,21 @@ export function registerNsModuleServerRoute(server, options) {
|
|
980
1464
|
// Workspace css outside the vite root must be anchored to /@fs or
|
|
981
1465
|
// `?inline` is denied and the DOM css module (__vite__updateStyle)
|
|
982
1466
|
// is served instead.
|
|
@@ -1000,7 +1484,7 @@ index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ac33b017b65489472c3573ce45f89bb9
|
|
|
1000
1484
|
const inlineCode = inlineRes?.code || '';
|
|
1001
1485
|
// `?inline` output is `export default "<compiled css>"`.
|
|
1002
1486
|
const m = inlineCode.match(/export\s+default\s+("(?:[^"\\]|\\.)*")\s*;?/s);
|
|
1003
|
-
@@ -178,7 +
|
|
1487
|
+
@@ -178,7 +192,14 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1004
1488
|
css = JSON.parse(m[1]);
|
|
1005
1489
|
}
|
|
1006
1490
|
catch { }
|
|
@@ -1016,7 +1500,7 @@ index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ac33b017b65489472c3573ce45f89bb9
|
|
|
1016
1500
|
const out = `// [ns:m][css] ${spec}\n` + `const __ns_css_text__ = ${JSON.stringify(css)};\n` + buildCssRegisterSnippetFromVar(spec, '__ns_css_text__') + `export default __ns_css_text__;\n`;
|
|
1017
1501
|
res.statusCode = 200;
|
|
1018
1502
|
res.end(out);
|
|
1019
|
-
@@ -191,
|
|
1503
|
+
@@ -191,12 +212,27 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1020
1504
|
if (verbose)
|
|
1021
1505
|
console.warn('[ns:m][css] inline compile failed', spec, cssErr?.message);
|
|
1022
1506
|
}
|
|
@@ -1028,7 +1512,32 @@ index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ac33b017b65489472c3573ce45f89bb9
|
|
|
1028
1512
|
}
|
|
1029
1513
|
// Queue and dedupe transformRequest calls so heavy app graphs do not
|
|
1030
1514
|
// overwhelm Vite with concurrent work. Slow-transform warnings start only
|
|
1031
|
-
|
|
1515
|
+
// when the transform actually begins executing, and requests stay pending
|
|
1516
|
+
// until Vite returns a real result.
|
|
1517
|
+
+ // A pnpm/bun patch install rewrites node_modules without a Vite
|
|
1518
|
+
+ // file event, so neither handleHotUpdate nor the shared transform
|
|
1519
|
+
+ // cache learns of it. The serve path fingerprints each resolved
|
|
1520
|
+
+ // dependency file; a drift purges Vite's module graph plus the
|
|
1521
|
+
+ // shared transform cache before this request re-transforms.
|
|
1522
|
+
+ const notifyServedDependencyFile = (file) => {
|
|
1523
|
+
+ if (!servedDependencyFileChanged(file))
|
|
1524
|
+
+ return;
|
|
1525
|
+
+ if (verbose)
|
|
1526
|
+
+ console.log('[ns:m] dependency file changed outside the watcher; invalidating transform caches', file);
|
|
1527
|
+
+ purgeTransformCachesForHotUpdate({ file, server, sharedTransformRequest, verbose, label: 'ns:m-deps' });
|
|
1528
|
+
+ };
|
|
1529
|
+
const transformWithTimeout = async (url, timeoutMs = 120000) => {
|
|
1530
|
+
const r = await sharedTransformRequest(url, timeoutMs);
|
|
1531
|
+
// A type-only .ts module legitimately transforms to EMPTY code
|
|
1532
|
+
@@ -230,6 +266,7 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1533
|
+
transformRequest: transformWithTimeout,
|
|
1534
|
+
resolveId: resolvePluginContainerId,
|
|
1535
|
+
loadVirtualId,
|
|
1536
|
+
+ notifyServedDependencyFile,
|
|
1537
|
+
});
|
|
1538
|
+
let transformed = resolution.transformed;
|
|
1539
|
+
const resolvedCandidate = resolution.resolvedCandidate;
|
|
1540
|
+
@@ -513,6 +550,8 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1032
1541
|
continue;
|
|
1033
1542
|
}
|
|
1034
1543
|
else if (u.pathname.startsWith('/ns/m')) {
|
|
@@ -1037,7 +1546,15 @@ index fcdcd69776b3f82d3fc7d8dd26e03856177c933e..ac33b017b65489472c3573ce45f89bb9
|
|
|
1037
1546
|
// Resolve the import target through the SAME
|
|
1038
1547
|
// canonical pipeline the /ns/m route itself uses
|
|
1039
1548
|
// (websocket-ns-m-request.ts) instead of a third
|
|
1040
|
-
@@ -
|
|
1549
|
+
@@ -532,6 +571,7 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1550
|
+
},
|
|
1551
|
+
resolveId: resolvePluginContainerId,
|
|
1552
|
+
loadVirtualId,
|
|
1553
|
+
+ notifyServedDependencyFile,
|
|
1554
|
+
});
|
|
1555
|
+
targetCode = targetResolution.transformed?.code || '';
|
|
1556
|
+
}
|
|
1557
|
+
@@ -546,7 +586,17 @@ export function registerNsModuleServerRoute(server, options) {
|
|
1041
1558
|
catch { }
|
|
1042
1559
|
if (!targetCode)
|
|
1043
1560
|
continue;
|
|
@@ -1338,14 +1855,12 @@ index 7b3afd4af098cc8587851b04188f6b1c3d5541bc..8951fe0d26c6cd73ad713bf672ca2424
|
|
|
1338
1855
|
}
|
|
1339
1856
|
function canResolveDependencyPackageJson(specifier, projectRequire) {
|
|
1340
1857
|
try {
|
|
1341
|
-
@@ -
|
|
1342
|
-
.split(',')
|
|
1858
|
+
@@ -939,4 +997,3 @@ function parseEnvList(value) {
|
|
1343
1859
|
.map((token) => token.trim())
|
|
1344
1860
|
.filter(Boolean);
|
|
1345
|
-
|
|
1346
|
-
-//# sourceMappingURL=manifest-collect.js.map
|
|
1861
|
+
}
|
|
1347
1862
|
|
|
1348
|
-
|
|
1863
|
+
-//# sourceMappingURL=manifest-collect.js.map
|
|
1349
1864
|
|
|
1350
1865
|
diff --git a/hmr/shared/vendor/manifest.js b/hmr/shared/vendor/manifest.js
|
|
1351
1866
|
index 54ba11ef9c329df049fa93b01b2ce47c9fb1ac3e..f7e3d0d1bd71919584834ef5a56e42f74ad2cf28 100644
|