@nativescript/vite 2.0.0 → 2.0.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/configuration/angular.js +3 -2
- package/configuration/angular.js.map +1 -1
- package/configuration/base.js +6 -4
- package/configuration/base.js.map +1 -1
- package/helpers/import-meta-path.d.ts +4 -0
- package/helpers/import-meta-path.js +5 -0
- package/helpers/import-meta-path.js.map +1 -0
- package/hmr/client/index.js +25 -1
- package/hmr/client/index.js.map +1 -1
- package/hmr/entry-runtime.js +12 -0
- package/hmr/entry-runtime.js.map +1 -1
- package/hmr/server/websocket.js +47 -30
- package/hmr/server/websocket.js.map +1 -1
- package/package.json +1 -1
package/hmr/server/websocket.js
CHANGED
|
@@ -2626,9 +2626,25 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
2626
2626
|
const candidates = [...(hasExt ? [spec] : []), baseNoExt + '.ts', baseNoExt + '.js', baseNoExt + '.tsx', baseNoExt + '.jsx', baseNoExt + '.mjs', baseNoExt + '.mts', baseNoExt + '.cts', baseNoExt + '.vue', baseNoExt + '/index.ts', baseNoExt + '/index.js', baseNoExt + '/index.tsx', baseNoExt + '/index.jsx', baseNoExt + '/index.mjs'];
|
|
2627
2627
|
let transformed = null;
|
|
2628
2628
|
let resolvedCandidate = null;
|
|
2629
|
+
// Wrap transformRequest with a timeout to prevent Vite 7+ optimizeDeps
|
|
2630
|
+
// discovery from blocking the HTTP ESM pipeline indefinitely.
|
|
2631
|
+
const transformWithTimeout = (url, timeoutMs = 30000) => {
|
|
2632
|
+
return Promise.race([
|
|
2633
|
+
server.transformRequest(url),
|
|
2634
|
+
new Promise((resolve) => {
|
|
2635
|
+
setTimeout(() => {
|
|
2636
|
+
try {
|
|
2637
|
+
console.warn('[ns:m] transformRequest timeout for', url, '(' + timeoutMs + 'ms)');
|
|
2638
|
+
}
|
|
2639
|
+
catch { }
|
|
2640
|
+
resolve(null);
|
|
2641
|
+
}, timeoutMs);
|
|
2642
|
+
}),
|
|
2643
|
+
]);
|
|
2644
|
+
};
|
|
2629
2645
|
for (const cand of candidates) {
|
|
2630
2646
|
try {
|
|
2631
|
-
const r = await
|
|
2647
|
+
const r = await transformWithTimeout(cand);
|
|
2632
2648
|
if (r?.code) {
|
|
2633
2649
|
transformed = r;
|
|
2634
2650
|
resolvedCandidate = cand;
|
|
@@ -2643,7 +2659,7 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
2643
2659
|
const rid = await server.pluginContainer?.resolveId?.(spec, undefined);
|
|
2644
2660
|
const ridStr = typeof rid === 'string' ? rid : rid?.id || null;
|
|
2645
2661
|
if (ridStr) {
|
|
2646
|
-
const r = await
|
|
2662
|
+
const r = await transformWithTimeout(ridStr);
|
|
2647
2663
|
if (r?.code) {
|
|
2648
2664
|
transformed = r;
|
|
2649
2665
|
resolvedCandidate = ridStr;
|
|
@@ -2660,7 +2676,7 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
2660
2676
|
const rootPosix = toPosix(projectRoot).replace(/\/$/, '');
|
|
2661
2677
|
const absPosix = `${rootPosix}${spec.startsWith('/') ? '' : '/'}${spec}`;
|
|
2662
2678
|
const fsId = `/@fs${absPosix}`;
|
|
2663
|
-
const r = await
|
|
2679
|
+
const r = await transformWithTimeout(fsId);
|
|
2664
2680
|
if (r?.code) {
|
|
2665
2681
|
transformed = r;
|
|
2666
2682
|
resolvedCandidate = fsId;
|
|
@@ -2672,7 +2688,7 @@ function createHmrWebSocketPlugin(opts) {
|
|
|
2672
2688
|
if (!transformed?.code) {
|
|
2673
2689
|
for (const cand of candidates) {
|
|
2674
2690
|
try {
|
|
2675
|
-
const r = await
|
|
2691
|
+
const r = await transformWithTimeout(`${cand}${cand.includes('?') ? '&' : '?'}import`);
|
|
2676
2692
|
if (r?.code) {
|
|
2677
2693
|
transformed = r;
|
|
2678
2694
|
resolvedCandidate = `${cand}?import`;
|
|
@@ -4990,32 +5006,33 @@ export const piniaSymbol = p.piniaSymbol;
|
|
|
4990
5006
|
if (verbose)
|
|
4991
5007
|
console.warn('[hmr-ws][graph] initial population failed', e);
|
|
4992
5008
|
}
|
|
4993
|
-
// Send SFC registry on
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
}
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5009
|
+
// Send SFC registry on every connection (not just the first).
|
|
5010
|
+
// When the NativeScript app restarts (e.g. CLI auto-reload), the new
|
|
5011
|
+
// JS context has an empty sfcArtifactMap. Without the registry the
|
|
5012
|
+
// rescue-mount cannot find the root .vue component.
|
|
5013
|
+
try {
|
|
5014
|
+
await ACTIVE_STRATEGY.buildRegistry({
|
|
5015
|
+
server,
|
|
5016
|
+
sfcFileMap,
|
|
5017
|
+
depFileMap,
|
|
5018
|
+
wss: wss,
|
|
5019
|
+
verbose,
|
|
5020
|
+
helpers: {
|
|
5021
|
+
cleanCode,
|
|
5022
|
+
collectImportDependencies,
|
|
5023
|
+
isCoreGlobalsReference,
|
|
5024
|
+
isNativeScriptCoreModule,
|
|
5025
|
+
isNativeScriptPluginModule,
|
|
5026
|
+
resolveVendorFromCandidate,
|
|
5027
|
+
createHash: (value) => createHash('md5').update(value).digest('hex'),
|
|
5028
|
+
rewriteImports,
|
|
5029
|
+
processSfcCode,
|
|
5030
|
+
},
|
|
5031
|
+
});
|
|
5032
|
+
registrySent = true;
|
|
5033
|
+
}
|
|
5034
|
+
catch (error) {
|
|
5035
|
+
console.warn('[hmr-ws] Failed to send registry:', error);
|
|
5019
5036
|
}
|
|
5020
5037
|
emitFullGraph(ws);
|
|
5021
5038
|
// After sending registry & graph also send current module manifest if any
|