@@ -860,9 +860,14 @@ function rolldownScanPlugin(
860
860
contents = ( await transform ( contents , { loader } ) ) . code
861
861
}
862
862
if ( contents . includes ( 'import.meta.glob' ) ) {
863
- scripts [ key ] = await doTransformGlobImport ( contents , p )
863
+ scripts [ key ] = {
864
+ contents : await doTransformGlobImport ( contents , p ) ,
865
+ loader
866
+ }
864
867
} else {
865
- scripts [ key ] = contents
868
+ scripts [ key ] = {
869
+ contents, loader
870
+ }
866
871
}
867
872
868
873
const virtualModulePath = JSON . stringify ( virtualModulePrefix + key )
@@ -894,7 +899,10 @@ function rolldownScanPlugin(
894
899
return js
895
900
}
896
901
897
- const scripts : Record < string , string > = { }
902
+ const scripts : Record < string , {
903
+ contents : string ,
904
+ loader : Loader ,
905
+ } > = { }
898
906
899
907
const ASSET_TYPE_RE = new RegExp ( `\\.(${ KNOWN_ASSET_TYPES . join ( '|' ) } )$` )
900
908
@@ -956,10 +964,9 @@ function rolldownScanPlugin(
956
964
if ( depImports [ id ] ) {
957
965
return externalUnlessEntry ( { path : id } )
958
966
}
959
- const loader = parseRequest ( id ) ?. loader
960
967
const resolved = await resolve ( id , importer , {
961
968
custom : {
962
- depScan : { loader } ,
969
+ depScan : importer ? { loader : scripts [ importer ] ?. loader } : { } ,
963
970
} ,
964
971
} )
965
972
if ( resolved ) {
@@ -1019,10 +1026,9 @@ function rolldownScanPlugin(
1019
1026
// catch all -------------------------------------------------------------
1020
1027
1021
1028
// use vite resolver to support urls and omitted extensions
1022
- const loader = parseRequest ( id ) ?. loader
1023
1029
const resolved = await resolve ( id , importer , {
1024
1030
custom : {
1025
- depScan : { loader } ,
1031
+ depScan : importer ? { loader : scripts [ importer ] ?. loader } : { } ,
1026
1032
} ,
1027
1033
} )
1028
1034
if ( resolved ) {
@@ -1044,7 +1050,7 @@ function rolldownScanPlugin(
1044
1050
load : async function ( id ) {
1045
1051
if ( virtualModuleRE . test ( id ) ) {
1046
1052
return {
1047
- code : scripts [ id . replace ( virtualModulePrefix , '' ) ] ,
1053
+ code : scripts [ id . replace ( virtualModulePrefix , '' ) ] . contents ,
1048
1054
}
1049
1055
}
1050
1056
0 commit comments