@@ -138,6 +138,7 @@ export default (new Packager({
138
138
let entry ;
139
139
for ( let b of bundleGraph . getReferencedBundles ( bundle , {
140
140
includeInline : false ,
141
+ includeIsolated : false ,
141
142
} ) ) {
142
143
if ( b . type === 'css' ) {
143
144
resources . push (
@@ -238,7 +239,7 @@ async function loadBundleUncached(
238
239
) = > Async < { | contents : Blob | } > ,
239
240
) {
240
241
// Load all asset contents.
241
- let queue = new PromiseQueue < Array < [ string , [ Asset , string ] ] >> ( {
242
+ let queue = new PromiseQueue < Array < [ string , [ NamedBundle , Asset , string ] ] >> ( {
242
243
maxConcurrent : 32 ,
243
244
} ) ;
244
245
bundle . traverse ( node => {
@@ -262,7 +263,7 @@ async function loadBundleUncached(
262
263
return [
263
264
[
264
265
entryBundle . id ,
265
- [ nullthrows ( entryBundle . getMainEntry ( ) ) , contents ] ,
266
+ [ entryBundle , nullthrows ( entryBundle . getMainEntry ( ) ) , contents ] ,
266
267
] ,
267
268
] ;
268
269
} ) ;
@@ -278,23 +279,36 @@ async function loadBundleUncached(
278
279
}
279
280
} else if ( node . type === 'asset' ) {
280
281
let asset = node . value ;
281
- queue . add ( async ( ) => [ [ asset . id , [ asset , await asset . getCode ( ) ] ] ] ) ;
282
+ queue . add ( async ( ) => [
283
+ [ asset . id , [ bundle , asset , await asset . getCode ( ) ] ] ,
284
+ ] ) ;
282
285
}
283
286
} ) ;
284
287
285
- let assets = new Map < string , [ Asset , string ] > (
288
+ for ( let b of bundleGraph . getReferencedBundles ( bundle ) ) {
289
+ queue . add ( async ( ) => {
290
+ let { assets : subAssets } = await loadBundle (
291
+ b ,
292
+ bundleGraph ,
293
+ getInlineBundleContents ,
294
+ ) ;
295
+ return Array . from ( subAssets ) ;
296
+ } ) ;
297
+ }
298
+
299
+ let assets = new Map < string , [ NamedBundle , Asset , string ] > (
286
300
( await queue . run ( ) ) . flatMap ( v => v ) ,
287
301
) ;
288
302
let assetsByFilePath = new Map < string , string > ( ) ;
289
303
let assetsByPublicId = new Map < string , string > ( ) ;
290
- for ( let [ asset ] of assets . values ( ) ) {
304
+ for ( let [ , asset ] of assets . values ( ) ) {
291
305
assetsByFilePath . set ( getCacheKey ( asset ) , asset . id ) ;
292
306
assetsByPublicId . set ( bundleGraph . getAssetPublicId ( asset ) , asset . id ) ;
293
307
}
294
308
295
309
// Load an asset into the module system by id.
296
310
let loadAsset = ( id : string ) => {
297
- let [ asset , code ] = nullthrows ( assets . get ( id ) ) ;
311
+ let [ bundle , asset , code ] = nullthrows ( assets . get ( id ) ) ;
298
312
let cacheKey = getCacheKey ( asset ) ;
299
313
let cachedModule = moduleCache . get ( cacheKey ) ;
300
314
if ( cachedModule ) {
@@ -376,9 +390,9 @@ async function loadBundleUncached(
376
390
bundleGraph ,
377
391
getInlineBundleContents ,
378
392
) ;
379
- for ( let [ id , [ asset , code ] ] of subAssets ) {
393
+ for ( let [ id , [ bundle , asset , code ] ] of subAssets ) {
380
394
if ( ! assets . has ( id ) ) {
381
- assets . set ( id , [ asset , code ] ) ;
395
+ assets . set ( id , [ bundle , asset , code ] ) ;
382
396
assetsByFilePath . set ( getCacheKey ( asset ) , asset . id ) ;
383
397
assetsByPublicId . set ( bundleGraph . getAssetPublicId ( asset ) , asset . id ) ;
384
398
}
@@ -456,7 +470,6 @@ function runModule(
456
470
require : ( id : string ) = > any ,
457
471
parcelRequire : ( id : string ) = > any ,
458
472
) {
459
- // code = code.replace(/import\((['"].*?['"])\)/g, (_, m) => `parcelRequire.load(${m[0] + m.slice(3)})`);
460
473
let moduleFunction = vm . compileFunction (
461
474
code ,
462
475
[
0 commit comments