Browse Source

rename variables named `exports`

contingency-plan
Rich-Harris 9 years ago
parent
commit
09eaef6143
  1. 2
      src/Bundle.js
  2. 12
      test/function/deconflicts-exports/_config.js
  3. 8
      test/function/deconflicts-exports/main.js
  4. 3
      test/function/export-and-import-reference-share-var/_config.js

2
src/Bundle.js

@ -39,7 +39,9 @@ export default class Bundle {
this.statements = null;
this.externalModules = [];
this.internalNamespaceModules = [];
this.assumedGlobals = blank();
this.assumedGlobals.exports = true; // TODO strictly speaking, this only applies with non-ES6, non-default-only bundles
}
build () {

12
test/function/deconflicts-exports/_config.js

@ -0,0 +1,12 @@
var assert = require( 'assert' );
module.exports = {
description: 'renames variables named `exports` if necessary',
exports: function ( exports ) {
assert.deepEqual( Object.keys( exports ), [ 'a', 'b' ] );
assert.equal( exports.a, 'A' );
assert.equal( exports.b, 42 );
},
solo: true,
show: true
};

8
test/function/deconflicts-exports/main.js

@ -0,0 +1,8 @@
var exports = {
number: 21
};
export var a = 'A';
export var b = exports.number * 2;
assert.deepEqual( Object.keys( exports ), [ 'number' ]);

3
test/function/export-and-import-reference-share-var/_config.js

@ -4,8 +4,7 @@ module.exports = {
description: 'allows export and import reference to share name',
exports: function ( exports ) {
assert.equal( exports.b, 9 );
},
solo: true
}
};
// adapted from es6-module-transpiler

Loading…
Cancel
Save