@@ -15,9 +15,7 @@ import {
15
15
CLIENT_DIR ,
16
16
CLIENT_PUBLIC_PATH ,
17
17
DEP_VERSION_RE ,
18
- FS_PREFIX ,
19
- NULL_BYTE_PLACEHOLDER ,
20
- VALID_ID_PREFIX
18
+ FS_PREFIX
21
19
} from '../constants'
22
20
import {
23
21
debugHmr ,
@@ -42,7 +40,8 @@ import {
42
40
stripBomTag ,
43
41
timeFrom ,
44
42
transformStableResult ,
45
- unwrapId
43
+ unwrapId ,
44
+ wrapId
46
45
} from '../utils'
47
46
import type { ResolvedConfig } from '../config'
48
47
import type { Plugin } from '../plugin'
@@ -330,8 +329,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
330
329
// prefix it to make it valid. We will strip this before feeding it
331
330
// back into the transform pipeline
332
331
if ( ! url . startsWith ( '.' ) && ! url . startsWith ( '/' ) ) {
333
- url =
334
- VALID_ID_PREFIX + resolved . id . replace ( '\0' , NULL_BYTE_PLACEHOLDER )
332
+ url = wrapId ( resolved . id )
335
333
}
336
334
337
335
// make the URL browser-valid if not SSR
@@ -361,7 +359,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
361
359
try {
362
360
// delay setting `isSelfAccepting` until the file is actually used (#7870)
363
361
const depModule = await moduleGraph . ensureEntryFromUrl (
364
- url ,
362
+ unwrapId ( url ) ,
365
363
ssr ,
366
364
canSkipImportAnalysis ( url )
367
365
)
@@ -536,9 +534,9 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
536
534
}
537
535
538
536
// record for HMR import chain analysis
539
- // make sure to normalize away base
540
- const urlWithoutBase = url . replace ( base , '/' )
541
- importedUrls . add ( urlWithoutBase )
537
+ // make sure to unwrap and normalize away base
538
+ const hmrUrl = unwrapId ( url . replace ( base , '/' ) )
539
+ importedUrls . add ( hmrUrl )
542
540
543
541
if ( enablePartialAccept && importedBindings ) {
544
542
extractImportedBindings (
@@ -551,7 +549,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
551
549
552
550
if ( ! isDynamicImport ) {
553
551
// for pre-transforming
554
- staticImportedUrls . add ( { url : urlWithoutBase , id : resolvedId } )
552
+ staticImportedUrls . add ( { url : hmrUrl , id : resolvedId } )
555
553
}
556
554
} else if ( ! importer . startsWith ( clientDir ) ) {
557
555
if ( ! importer . includes ( 'node_modules' ) ) {
@@ -712,10 +710,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
712
710
// by the deps optimizer
713
711
if ( config . server . preTransformRequests && staticImportedUrls . size ) {
714
712
staticImportedUrls . forEach ( ( { url, id } ) => {
715
- url = unwrapId ( removeImportQuery ( url ) ) . replace (
716
- NULL_BYTE_PLACEHOLDER ,
717
- '\0'
718
- )
713
+ url = removeImportQuery ( url )
719
714
transformRequest ( url , server , { ssr } ) . catch ( ( e ) => {
720
715
if ( e ?. code === ERR_OUTDATED_OPTIMIZED_DEP ) {
721
716
// This are expected errors
0 commit comments