Browse Source

only deconflict reified namespaces

gh-953
Rich Harris 8 years ago
parent
commit
bed6f0650d
  1. 15
      src/Bundle.js
  2. 6
      test/form/namespace-optimization-b/_expected/amd.js
  3. 6
      test/form/namespace-optimization-b/_expected/cjs.js
  4. 6
      test/form/namespace-optimization-b/_expected/es.js
  5. 6
      test/form/namespace-optimization-b/_expected/iife.js
  6. 6
      test/form/namespace-optimization-b/_expected/umd.js

15
src/Bundle.js

@ -208,15 +208,12 @@ export default class Bundle {
declaration.name = getSafeName( declaration.name );
});
// special case - for `import * as Foo`, we need to make sure that Foo
// gets its own variable because it will eventually be rendered as
// `var Foo = Object.freeze(...)`
forOwn( module.imports, ( importee, importeeName ) => {
if ( importee.name === '*' ) {
delete module.imports[ importeeName ];
module.imports[ getSafeName(importeeName) ] = importee;
}
});
// deconflict reified namespaces
const namespace = module.namespace();
if ( namespace.needsNamespaceBlock ) {
namespace.name = getSafeName( namespace.name );
}
});
this.scope.deshadow( toDeshadow );

6
test/form/namespace-optimization-b/_expected/amd.js

@ -1,12 +1,12 @@
define(function () { 'use strict';
function foo$1 () {
function foo () {
console.log( 'foo' );
}
function a () {
foo$1();
foo$1();
foo();
foo();
var a;
if ( a.b ) {

6
test/form/namespace-optimization-b/_expected/cjs.js

@ -1,12 +1,12 @@
'use strict';
function foo$1 () {
function foo () {
console.log( 'foo' );
}
function a () {
foo$1();
foo$1();
foo();
foo();
var a;
if ( a.b ) {

6
test/form/namespace-optimization-b/_expected/es.js

@ -1,10 +1,10 @@
function foo$1 () {
function foo () {
console.log( 'foo' );
}
function a () {
foo$1();
foo$1();
foo();
foo();
var a;
if ( a.b ) {

6
test/form/namespace-optimization-b/_expected/iife.js

@ -1,13 +1,13 @@
(function () {
'use strict';
function foo$1 () {
function foo () {
console.log( 'foo' );
}
function a () {
foo$1();
foo$1();
foo();
foo();
var a;
if ( a.b ) {

6
test/form/namespace-optimization-b/_expected/umd.js

@ -4,13 +4,13 @@
(factory());
}(this, (function () { 'use strict';
function foo$1 () {
function foo () {
console.log( 'foo' );
}
function a () {
foo$1();
foo$1();
foo();
foo();
var a;
if ( a.b ) {

Loading…
Cancel
Save