@@ -77,7 +77,7 @@ export class Bundler {
77
77
} )
78
78
79
79
if ( this . #app. config . buildTarget !== 'esnext' ) {
80
- await this . bundlePolyfillChunck ( )
80
+ await this . bundlePolyfillsChunck ( )
81
81
}
82
82
await this . bundleChunk (
83
83
'deps' ,
@@ -146,7 +146,6 @@ export class Bundler {
146
146
{
147
147
...this . #app. sharedCompileOptions ,
148
148
swcOptions : {
149
- target : 'es2020' ,
150
149
sourceType : source . type ,
151
150
} ,
152
151
bundleMode : true ,
@@ -157,8 +156,8 @@ export class Bundler {
157
156
if ( starExports && starExports . length > 0 ) {
158
157
for ( let index = 0 ; index < starExports . length ; index ++ ) {
159
158
const url = starExports [ index ]
160
- const source = await this . #app. resolveModule ( url )
161
- const names = await parseExportNames ( url , source . code , { sourceType : source . type } )
159
+ const names = await this . #app. parseModuleExportNames ( url )
160
+ code = code . replace ( `export * from "[ ${ url } ]:` , `export { ${ names . filter ( name => name !== 'default' ) . join ( ',' ) } } from "` )
162
161
code = code . replace ( `export const $$star_${ index } ` , `export const {${ names . filter ( name => name !== 'default' ) . join ( ',' ) } }` )
163
162
}
164
163
}
@@ -168,14 +167,7 @@ export class Bundler {
168
167
if ( ! dep . url . startsWith ( '#' ) && ! external . includes ( dep . url ) ) {
169
168
const depMod = this . #app. getModule ( dep . url )
170
169
if ( depMod !== null ) {
171
- const s = `.bundling.js#${ dep . url } @`
172
170
await this . compile ( depMod , external )
173
- code = code . split ( s ) . map ( ( p , i ) => {
174
- if ( i > 0 && p . charAt ( 6 ) === '"' ) {
175
- return dep . hash . slice ( 0 , 6 ) + p . slice ( 6 )
176
- }
177
- return p
178
- } ) . join ( s )
179
171
}
180
172
}
181
173
}
@@ -201,20 +193,20 @@ export class Bundler {
201
193
log . info ( ` {} main.js ${ dim ( '• ' + util . formatBytes ( mainJS . length ) ) } ` )
202
194
}
203
195
204
- /** create polyfill bundle. */
205
- private async bundlePolyfillChunck ( ) {
196
+ /** create polyfills bundle. */
197
+ private async bundlePolyfillsChunck ( ) {
206
198
const alephPkgUri = getAlephPkgUri ( )
207
199
const { buildTarget } = this . #app. config
208
- const polyfillTarget = 'es' + ( parseInt ( buildTarget . slice ( 2 ) ) + 1 )
200
+ const polyfillTarget = 'es' + ( parseInt ( buildTarget . slice ( 2 ) ) + 1 ) // buildTarget + 1
209
201
const hash = computeHash ( polyfillTarget + '/[email protected] /' + VERSION )
210
- const bundleFilename = `polyfill .bundle.${ hash . slice ( 0 , hashShort ) } .js`
202
+ const bundleFilename = `polyfills .bundle.${ hash . slice ( 0 , hashShort ) } .js`
211
203
const bundleFilePath = join ( this . #app. buildDir , bundleFilename )
212
204
if ( ! existsFileSync ( bundleFilePath ) ) {
213
- const rawPolyfillFile = `${ alephPkgUri } /bundler/polyfills/${ polyfillTarget } /mod.ts`
214
- await this . build ( rawPolyfillFile , bundleFilePath )
205
+ const rawPolyfillsFile = `${ alephPkgUri } /bundler/polyfills/${ polyfillTarget } /mod.ts`
206
+ await this . build ( rawPolyfillsFile , bundleFilePath )
215
207
}
216
- this . #bundledFiles. set ( 'polyfill ' , bundleFilename )
217
- log . info ( ` {} polyfill .js (${ buildTarget . toUpperCase ( ) } ) ${ dim ( '• ' + util . formatBytes ( Deno . statSync ( bundleFilePath ) . size ) ) } ` )
208
+ this . #bundledFiles. set ( 'polyfills ' , bundleFilename )
209
+ log . info ( ` {} polyfills .js (${ buildTarget . toUpperCase ( ) } ) ${ dim ( '• ' + util . formatBytes ( Deno . statSync ( bundleFilePath ) . size ) ) } ` )
218
210
}
219
211
220
212
/** create bundle chunk. */
0 commit comments