File tree 2 files changed +19
-8
lines changed
third_party/es6-module-loader
2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -349,29 +349,31 @@ export class InstantiateModuleTransformer extends ModuleTransformer {
349
349
350
350
// then do export bindings of re-exported dependencies
351
351
if ( externalExportBindings ) {
352
+ let reexports = Object . create ( null ) ;
352
353
externalExportBindings . forEach ( ( { exportName, importName} ) => {
353
- let statement = importName === null ?
354
- parseStatement `$__export(${ exportName } , $__m);` :
355
- parseStatement `$__export(${ exportName } , $__m.${ importName } );` ;
356
- setterStatements . push ( statement ) ;
354
+ reexports [ exportName ] = importName === null ?
355
+ parseExpression `$__m` : parseExpression `$__m.${ importName } ` ;
357
356
} ) ;
357
+ setterStatements . push (
358
+ parseStatement `$__export(${ createObjectLiteral ( reexports ) } )` ) ;
358
359
}
359
360
360
361
// create local module bindings
361
362
if ( moduleBinding ) {
362
363
setterStatements . push (
363
- parseStatement `${ id ( moduleBinding ) } = $__m;`
364
- ) ;
364
+ parseStatement `${ id ( moduleBinding ) } = $__m;` ) ;
365
365
}
366
366
367
367
// finally run export * if applying to this dependency, for not-already
368
368
// exported dependencies
369
369
if ( exportStarBinding ) {
370
370
setterStatements = setterStatements . concat ( parseStatements `
371
+ var exportObj = Object.create(null);
371
372
Object.keys($__m).forEach(function(p) {
372
373
if (p !== 'default' && !$__exportNames[p])
373
- $__export(p, $__m[p]) ;
374
+ exportObj[p] = $__m[p];
374
375
});
376
+ $__export(exportObj);
375
377
` ) ;
376
378
377
379
let exportNames = { } ;
Original file line number Diff line number Diff line change @@ -687,7 +687,16 @@ function logloads(loads) {
687
687
// NB This should be an Object.defineProperty, but that is very slow.
688
688
// By disaling this module write-protection we gain performance.
689
689
// It could be useful to allow an option to enable or disable this.
690
- moduleObj [ name ] = value ;
690
+
691
+ // bulk export object
692
+ if ( typeof name == 'object' ) {
693
+ for ( var p in name )
694
+ moduleObj [ p ] = name [ p ] ;
695
+ }
696
+ // single export name / value pair
697
+ else {
698
+ moduleObj [ name ] = value ;
699
+ }
691
700
692
701
for ( var i = 0 , l = module . importers . length ; i < l ; i ++ ) {
693
702
var importerModule = module . importers [ i ] ;
You can’t perform that action at this time.
0 commit comments