Browse Source

Correctly deshadow star imports when conflicting

gh-953
Nolan Lawson 8 years ago
parent
commit
8545d85a9e
  1. 9
      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
  7. 3
      test/function/namespacing-collisions-2/Material.js
  8. 3
      test/function/namespacing-collisions-2/MaterialAgain.js
  9. 6
      test/function/namespacing-collisions-2/Something.js
  10. 6
      test/function/namespacing-collisions-2/SomethingAgain.js
  11. 8
      test/function/namespacing-collisions-2/_config.js
  12. 7
      test/function/namespacing-collisions-2/main.js
  13. 3
      test/function/namespacing-collisions/Material.js
  14. 6
      test/function/namespacing-collisions/Something.js
  15. 8
      test/function/namespacing-collisions/_config.js
  16. 5
      test/function/namespacing-collisions/main.js

9
src/Bundle.js

@ -208,6 +208,15 @@ 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;
}
});
});
this.scope.deshadow( toDeshadow );

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

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

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

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

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

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

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

@ -1,13 +1,13 @@
(function () {
'use strict';
function foo () {
function foo$1 () {
console.log( 'foo' );
}
function a () {
foo();
foo();
foo$1();
foo$1();
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 () {
function foo$1 () {
console.log( 'foo' );
}
function a () {
foo();
foo();
foo$1();
foo$1();
var a;
if ( a.b ) {

3
test/function/namespacing-collisions-2/Material.js

@ -0,0 +1,3 @@
export function Material() {
return 'Material';
}

3
test/function/namespacing-collisions-2/MaterialAgain.js

@ -0,0 +1,3 @@
export function MaterialAgain() {
return 'MaterialAgain';
}

6
test/function/namespacing-collisions-2/Something.js

@ -0,0 +1,6 @@
import * as Material from './Material';
export function Something() {
console.log(Material);
return 'Something';
}

6
test/function/namespacing-collisions-2/SomethingAgain.js

@ -0,0 +1,6 @@
import * as Material from './MaterialAgain';
export function SomethingAgain() {
console.log(Material);
return 'SomethingAgain';
}

8
test/function/namespacing-collisions-2/_config.js

@ -0,0 +1,8 @@
var assert = require( 'assert' );
module.exports = {
description: 'correctly namespaces when using * exports, take two (#910)',
exports: function ( exports ) {
assert.deepEqual( exports, ['Material', 'MaterialAgain', 'Something', 'SomethingAgain'] );
}
};

7
test/function/namespacing-collisions-2/main.js

@ -0,0 +1,7 @@
import { Something } from './Something';
import { SomethingAgain } from './SomethingAgain';
import { Material } from './Material';
import { MaterialAgain } from './MaterialAgain';
var result = [Material(), MaterialAgain(), Something(), SomethingAgain()]
export default result;

3
test/function/namespacing-collisions/Material.js

@ -0,0 +1,3 @@
export function Material() {
return 'Material';
}

6
test/function/namespacing-collisions/Something.js

@ -0,0 +1,6 @@
import * as Material from './Material';
export function Something() {
console.log(Material);
return 'Something';
}

8
test/function/namespacing-collisions/_config.js

@ -0,0 +1,8 @@
var assert = require( 'assert' );
module.exports = {
description: 'correctly namespaces when using * exports (#910)',
exports: function ( exports ) {
assert.deepEqual( exports, [ 'Material', 'Something' ] );
}
};

5
test/function/namespacing-collisions/main.js

@ -0,0 +1,5 @@
import { Something } from './Something';
import { Material } from './Material';
var result = [Material(), Something()]
export default result;
Loading…
Cancel
Save