@@ -812,9 +812,14 @@ function rolldownScanPlugin(
812
812
contents = ( await transform ( contents , { loader } ) ) . code
813
813
}
814
814
if ( contents . includes ( 'import.meta.glob' ) ) {
815
- scripts [ key ] = await doTransformGlobImport ( contents , p )
815
+ scripts [ key ] = {
816
+ contents : await doTransformGlobImport ( contents , p ) ,
817
+ loader
818
+ }
816
819
} else {
817
- scripts [ key ] = contents
820
+ scripts [ key ] = {
821
+ contents, loader
822
+ }
818
823
}
819
824
820
825
const virtualModulePath = JSON . stringify ( virtualModulePrefix + key )
@@ -846,7 +851,10 @@ function rolldownScanPlugin(
846
851
return js
847
852
}
848
853
849
- const scripts : Record < string , string > = { }
854
+ const scripts : Record < string , {
855
+ contents : string ,
856
+ loader : Loader ,
857
+ } > = { }
850
858
851
859
const ASSET_TYPE_RE = new RegExp ( `\\.(${ KNOWN_ASSET_TYPES . join ( '|' ) } )$` )
852
860
@@ -908,10 +916,9 @@ function rolldownScanPlugin(
908
916
if ( depImports [ id ] ) {
909
917
return externalUnlessEntry ( { path : id } )
910
918
}
911
- const loader = parseRequest ( id ) ?. loader
912
919
const resolved = await resolve ( id , importer , {
913
920
custom : {
914
- depScan : { loader } ,
921
+ depScan : importer ? { loader : scripts [ importer ] ?. loader } : { } ,
915
922
} ,
916
923
} )
917
924
if ( resolved ) {
@@ -971,10 +978,9 @@ function rolldownScanPlugin(
971
978
// catch all -------------------------------------------------------------
972
979
973
980
// use vite resolver to support urls and omitted extensions
974
- const loader = parseRequest ( id ) ?. loader
975
981
const resolved = await resolve ( id , importer , {
976
982
custom : {
977
- depScan : { loader } ,
983
+ depScan : importer ? { loader : scripts [ importer ] ?. loader } : { } ,
978
984
} ,
979
985
} )
980
986
if ( resolved ) {
@@ -996,7 +1002,7 @@ function rolldownScanPlugin(
996
1002
load : async function ( id ) {
997
1003
if ( virtualModuleRE . test ( id ) ) {
998
1004
return {
999
- code : scripts [ id . replace ( virtualModulePrefix , '' ) ] ,
1005
+ code : scripts [ id . replace ( virtualModulePrefix , '' ) ] . contents ,
1000
1006
}
1001
1007
}
1002
1008
0 commit comments