Browse Source

rename internal namespace exports as appropriate

contingency-plan
Rich-Harris 10 years ago
parent
commit
418ce08a44
  1. 5
      src/Bundle.js
  2. 3
      test/function/import-namespace-from-internal-module-renamed/_config.js
  3. 3
      test/function/import-namespace-from-internal-module-renamed/foo.js
  4. 3
      test/function/import-namespace-from-internal-module-renamed/main.js
  5. 3
      test/function/uses-supplied-ast/_config.js

5
src/Bundle.js

@ -323,7 +323,10 @@ export default class Bundle {
const exportKeys = keys( module.exports ); const exportKeys = keys( module.exports );
return `var ${module.getCanonicalName('*', format === 'es6')} = {\n` + return `var ${module.getCanonicalName('*', format === 'es6')} = {\n` +
exportKeys.map( key => `${indentString}get ${key} () { return ${module.getCanonicalName(key, format === 'es6')}; }` ).join( ',\n' ) + exportKeys.map( key => {
const localName = module.exports[ key ].localName;
return `${indentString}get ${key} () { return ${module.getCanonicalName(localName, format === 'es6')}; }`;
}).join( ',\n' ) +
`\n};\n\n`; `\n};\n\n`;
}).join( '' ); }).join( '' );

3
test/function/import-namespace-from-internal-module-renamed/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'correctly exports x as y inside a bundle'
};

3
test/function/import-namespace-from-internal-module-renamed/foo.js

@ -0,0 +1,3 @@
var x = 42;
export { x as y };

3
test/function/import-namespace-from-internal-module-renamed/main.js

@ -0,0 +1,3 @@
import * as foo from './foo';
assert.equal( foo.y, 42 );

3
test/function/uses-supplied-ast/_config.js

@ -30,6 +30,5 @@ module.exports = {
return modules[ id ]; return modules[ id ];
} }
}, }
solo: true
}; };

Loading…
Cancel
Save