File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,15 @@ export function astNormalizeModuleImportsAndHelpers(code: string): string {
103103 // Keep other prebundles as-is; they may be fetchable directly from the dev server
104104 }
105105 } else if ( isViteVirtual ( src ) || src === '@vite/client' || src === '/@vite/client' ) {
106+ // Removing the Vite client import should also remove its declared locals from our
107+ // `declared` set; otherwise later bridge rewrites may unnecessarily suffix names
108+ // (e.g. `__vite__createHotContext_1`) while call sites still reference the original.
109+ try {
110+ for ( const s of path . node . specifiers || [ ] ) {
111+ const local = ( s as any ) ?. local ?. name ;
112+ if ( typeof local === 'string' && local ) declared . delete ( local ) ;
113+ }
114+ } catch { }
106115 path . remove ( ) ;
107116 return ;
108117 }
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ export const VUE_FILE_IMPORT = /(?:^|\n)(\s*import\s+[^'";]*?\s+from\s+["'])([^"
1919
2020// Vite/HMR noise cleanup
2121export const VITE_CLIENT_IMPORT = / (?: ^ | \n ) \s * i m p o r t \s + [ ' " ] (?: \/ @ v i t e \/ c l i e n t | @ v i t e \/ c l i e n t ) [ ' " ] ; ? / g;
22- export const IMPORT_META_HOT_ASSIGNMENT = / (?: ^ | \n ) \s * i m p o r t \. m e t a \. h o t \s * = \s * [ ^ ; \n ] + ; ? / g;
22+ // Strip Vite's injected `import.meta.hot = __vite__createHotContext(...)` assignment.
23+ // Important: it may appear mid-line after other tokens/spaces in sanitized HTTP output,
24+ // so we cannot rely on it starting at BOL.
25+ export const IMPORT_META_HOT_ASSIGNMENT = / \b i m p o r t \. m e t a \. h o t \s * = \s * [ ^ ; \n ] + ; ? / g;
2326export const IMPORT_META_HOT_CALLS = / (?: ^ | \n ) \s * i m p o r t \. m e t a \. h o t \. [ A - Z a - z _ $ ] [ \w $ ] * \( [ ^ ) ] * \) ; ? \s * / g;
2427
2528// Remove only Vue style virtual imports; keep script/template variants
You can’t perform that action at this time.
0 commit comments