Browse Source

only deconflict reified namespaces

gh-953
Rich Harris 8 years ago
parent
commit
bed6f0650d
  1. 15
      src/Bundle.js
  2. 8
      test/form/namespace-optimization-b/_expected/amd.js
  3. 8
      test/form/namespace-optimization-b/_expected/cjs.js
  4. 8
      test/form/namespace-optimization-b/_expected/es.js
  5. 8
      test/form/namespace-optimization-b/_expected/iife.js
  6. 8
      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 );

8
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 ) {
@ -16,4 +16,4 @@ define(function () { 'use strict';
a();
});
});

8
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 ) {
@ -14,4 +14,4 @@ function a () {
}
}
a();
a();

8
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 ) {
@ -12,4 +12,4 @@ function a () {
}
}
a();
a();

8
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 ) {
@ -17,4 +17,4 @@
a();
}());
}());

8
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 ) {
@ -20,4 +20,4 @@
a();
})));
})));

Loading…
Cancel
Save