@@ -2201,6 +2201,67 @@ test("runtime source loader maps remote preact imports to local node file URLs",
22012201 }
22022202} ) ;
22032203
2204+ test ( "runtime source loader honors explicit manifest mappings before local preact shortcuts" , async ( ) => {
2205+ const runtime = new DefaultRuntimeManager ( {
2206+ remoteFallbackCdnBases : [ ] ,
2207+ remoteFetchRetries : 0 ,
2208+ remoteFetchBackoffMs : 10 ,
2209+ remoteFetchTimeoutMs : 500 ,
2210+ } ) ;
2211+
2212+ const internals = runtime as unknown as {
2213+ createSourceModuleLoader : (
2214+ moduleManifest : RuntimeModuleManifest | undefined ,
2215+ diagnostics : Array < { code ?: string ; message ?: string } > ,
2216+ ) => {
2217+ resolveRuntimeImportSpecifier (
2218+ specifier : string ,
2219+ parentUrl : string | undefined ,
2220+ ) : Promise < string > ;
2221+ } ;
2222+ } ;
2223+
2224+ const diagnostics : Array < { code ?: string ; message ?: string } > = [ ] ;
2225+ const loader = internals . createSourceModuleLoader (
2226+ {
2227+ react : {
2228+ resolvedUrl :
2229+ "https://ga.jspm.io/npm:preact@10.28.3/compat/dist/compat.module.js" ,
2230+ } ,
2231+ } ,
2232+ diagnostics ,
2233+ ) ;
2234+
2235+ const requestedUrls : string [ ] = [ ] ;
2236+ const originalFetch = globalThis . fetch ;
2237+ globalThis . fetch = ( async ( input : RequestInfo | URL ) => {
2238+ requestedUrls . push ( String ( input ) ) ;
2239+ return new Response ( "export default function Compat() { return null; }" , {
2240+ status : 200 ,
2241+ headers : {
2242+ "content-type" : "text/javascript; charset=utf-8" ,
2243+ } ,
2244+ } ) ;
2245+ } ) as typeof fetch ;
2246+
2247+ try {
2248+ const resolved = await loader . resolveRuntimeImportSpecifier (
2249+ "react" ,
2250+ undefined ,
2251+ ) ;
2252+ assert . match ( resolved , / ^ d a t a : t e x t \/ j a v a s c r i p t ; b a s e 6 4 , / ) ;
2253+ assert . equal (
2254+ requestedUrls . some ( ( url ) =>
2255+ url . includes ( "/npm:preact@10.28.3/compat/dist/compat.module.js" ) ,
2256+ ) ,
2257+ true ,
2258+ ) ;
2259+ assert . doesNotMatch ( resolved , / ^ f i l e : \/ \/ / ) ;
2260+ } finally {
2261+ globalThis . fetch = originalFetch ;
2262+ }
2263+ } ) ;
2264+
22042265test ( "runtime module caches are released across lifecycle cycles" , async ( ) => {
22052266 const runtime = new DefaultRuntimeManager ( {
22062267 remoteFallbackCdnBases : [ ] ,
0 commit comments