Skip to content

Commit

Permalink
Merge branch 'import-specifier-deshadowing' into release-0.55.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 26, 2018
2 parents e51249f + bb3c49f commit 488dbad
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/Chunk.ts
Expand Up @@ -491,6 +491,9 @@ export default class Chunk {
} else {
safeName = (es || system) ? getSafeName(variable.name) : `${module.name}.${name}`;
}
if (es || system) {
toDeshadow.add(safeName);
}
} else if (es || system) {
safeName = getSafeName(variable.name);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ast/scopes/Scope.ts
Expand Up @@ -88,7 +88,7 @@ export default class Scope {
// we can disregard exports.foo etc
if (declaration.exportName && declaration.isReassigned) return;

let name = declaration.getName();
let name = declaration.getName(true);

if (!names.has(name)) {
return;
Expand Down
8 changes: 7 additions & 1 deletion src/ast/variables/Variable.ts
Expand Up @@ -36,7 +36,13 @@ export default class Variable implements ExpressionEntity {
_options: ExecutionPathOptions
) { }

getName (): string {
getName (reset?: boolean): string {
if (reset && this.safeName && this.safeName !== this.name &&
this.safeName[this.name.length] === '$' &&
this.safeName[this.name.length + 1] === '$') {
this.safeName = undefined;
return this.name;
}
return this.safeName || this.name;
}

Expand Down
6 changes: 6 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_config.js
@@ -0,0 +1,6 @@
module.exports = {
description: 'deshadows aliased import bindings',
options: {
name: 'Sticky'
}
};
13 changes: 13 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_expected/amd.js
@@ -0,0 +1,13 @@
define(['react-sticky'], function (reactSticky) { 'use strict';

var Sticky = function () {
function Sticky() {}

Sticky.foo = reactSticky.Sticky;

return Sticky;
}();

return Sticky;

});
13 changes: 13 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_expected/cjs.js
@@ -0,0 +1,13 @@
'use strict';

var reactSticky = require('react-sticky');

var Sticky = function () {
function Sticky() {}

Sticky.foo = reactSticky.Sticky;

return Sticky;
}();

module.exports = Sticky;
11 changes: 11 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_expected/es.js
@@ -0,0 +1,11 @@
import { Sticky } from 'react-sticky';

var Sticky$1 = function () {
function Sticky$$1() {}

Sticky$$1.foo = Sticky;

return Sticky$$1;
}();

export default Sticky$1;
14 changes: 14 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_expected/iife.js
@@ -0,0 +1,14 @@
var Sticky = (function (reactSticky) {
'use strict';

var Sticky = function () {
function Sticky() {}

Sticky.foo = reactSticky.Sticky;

return Sticky;
}();

return Sticky;

}(reactSticky));
17 changes: 17 additions & 0 deletions test/form/samples/import-specifier-deshadowing/_expected/umd.js
@@ -0,0 +1,17 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-sticky')) :
typeof define === 'function' && define.amd ? define(['react-sticky'], factory) :
(global.Sticky = factory(global.reactSticky));
}(this, (function (reactSticky) { 'use strict';

var Sticky = function () {
function Sticky() {}

Sticky.foo = reactSticky.Sticky;

return Sticky;
}();

return Sticky;

})));
11 changes: 11 additions & 0 deletions test/form/samples/import-specifier-deshadowing/main.js
@@ -0,0 +1,11 @@
import { Sticky as ReactSticky } from 'react-sticky';

var Sticky = function () {
function Sticky() {}

Sticky.foo = ReactSticky;

return Sticky;
}();

export { Sticky as default };

0 comments on commit 488dbad

Please sign in to comment.