Browse Source

Merge pull request #110 from Victorystick/list-globals

Made the list of predefined globals easily extensible
gh-109
Rich Harris 9 years ago
parent
commit
10e9b1e6c0
  1. 12
      src/Bundle.js

12
src/Bundle.js

@ -33,10 +33,16 @@ export default class Bundle {
this.globals = new Scope();
this.scope = new Scope( this.globals );
// TODO strictly speaking, this only applies with non-ES6, non-default-only bundles
// Strictly speaking, these globals only apply to non-ES6, non-default-only bundles.
// However, the deconfliction logic is greatly simplified by being the same for all formats.
this.globals.define( 'exports' );
this.scope.bind( 'exports', this.globals.reference( 'exports' ) );
// * CommonJS needs `module` and `exports` ( and `require`? ) to be in scope.
// * SystemJS needs a reference to a function for its `exports`,
// and another one for any `module` it imports. These global names can be reused!
[ 'exports', 'module' ]
.forEach( name => {
this.globals.define( name );
this.scope.bind( name, this.globals.reference( name ) );
});
// Alias for entryModule.exports.
this.exports = null;

Loading…
Cancel
Save