@@ -1290,7 +1290,7 @@ export class Application {
1290
1290
}
1291
1291
1292
1292
// download dep when deno cache failed
1293
- log . info ( 'Redownload ' , url )
1293
+ log . info ( 'Force download from ' , url )
1294
1294
const buffer = await fetch ( u . toString ( ) ) . then ( resp => resp . arrayBuffer ( ) )
1295
1295
return await Deno . readAll ( new Deno . Buffer ( buffer ) )
1296
1296
}
@@ -1358,12 +1358,20 @@ export class Application {
1358
1358
}
1359
1359
1360
1360
log . info ( '- Bundling' )
1361
+ await this . createPolyfillBundle ( )
1361
1362
await this . createChunkBundle ( 'deps' , remoteDeps )
1362
1363
if ( localSharedDeps . length > 0 ) {
1363
1364
await this . createChunkBundle ( 'shared' , localSharedDeps )
1364
1365
}
1365
1366
1366
1367
// create and copy polyfill
1368
+ // bundle and copy page moudles
1369
+ await Promise . all ( pageModules . map ( async mod => this . createPageBundle ( mod , localSharedDeps ) ) )
1370
+ }
1371
+
1372
+ /** create polyfill bundle. */
1373
+ private async createPolyfillBundle ( ) {
1374
+ const alephPkgUrl = getAlephPkgUrl ( )
1367
1375
const { buildTarget } = this . config
1368
1376
const hash = computeHash ( AlephRuntimeCode + buildTarget + buildChecksum + Deno . version . deno )
1369
1377
const polyfillFile = path . join ( this . buildDir , `polyfill.bundle.${ util . shortHash ( hash ) } .js` )
@@ -1374,14 +1382,11 @@ export class Application {
1374
1382
await this . runDenoBundle ( rawPolyfillFile , polyfillFile , AlephRuntimeCode , true )
1375
1383
}
1376
1384
log . info ( ` {} polyfill (${ buildTarget . toUpperCase ( ) } ) ${ colors . dim ( '• ' + util . formatBytes ( Deno . statSync ( polyfillFile ) . size ) ) } ` )
1377
-
1378
- // bundle and copy page moudles
1379
- await Promise . all ( pageModules . map ( async mod => this . createPageBundle ( mod , localSharedDeps ) ) )
1380
1385
}
1381
1386
1382
1387
/** create chunk bundle. */
1383
- private async createChunkBundle ( name : string , list : string [ ] ) {
1384
- const bundlingCode = list . map ( ( url , i ) => {
1388
+ private async createChunkBundle ( name : string , deps : string [ ] ) {
1389
+ const bundlingCode = deps . map ( ( url , i ) => {
1385
1390
const mod = this . #modules. get ( url )
1386
1391
if ( mod ) {
1387
1392
const importUrl = util . isLikelyHttpURL ( mod . url ) ? mod . jsFile : mod . bundlingFile
@@ -1394,16 +1399,13 @@ export class Application {
1394
1399
const hash = computeHash ( bundlingCode + buildChecksum + Deno . version . deno )
1395
1400
const bundleEntryFile = path . join ( this . buildDir , `${ name } .bundle.entry.js` )
1396
1401
const bundleFile = path . join ( this . buildDir , `${ name } .bundle.${ util . shortHash ( hash ) } .js` )
1397
-
1402
+ const mod = this . newModule ( `/${ name } .js` )
1403
+ mod . hash = mod . sourceHash = hash
1398
1404
if ( ! existsFileSync ( bundleFile ) ) {
1399
1405
await Deno . writeTextFile ( bundleEntryFile , bundlingCode )
1400
1406
await this . runDenoBundle ( bundleEntryFile , bundleFile )
1401
1407
lazyRemove ( bundleEntryFile )
1402
1408
}
1403
-
1404
- const mod = this . newModule ( `/${ name } .js` )
1405
- mod . hash = mod . sourceHash = hash
1406
-
1407
1409
log . info ( ` {} ${ name } ${ colors . dim ( '• ' + util . formatBytes ( Deno . statSync ( bundleFile ) . size ) ) } ` )
1408
1410
}
1409
1411
@@ -1484,7 +1486,6 @@ export class Application {
1484
1486
pageModules . push ( mod )
1485
1487
}
1486
1488
} ) )
1487
-
1488
1489
await Promise . all ( [
1489
1490
( async ( ) => {
1490
1491
const mainJS = this . getMainJS ( true )
0 commit comments