Skip to content

Commit

Permalink
Merge pull request #1695 from lukastaegert/do-not-exclude-pure-extern…
Browse files Browse the repository at this point in the history
…al-modules

Fix regression when using pureExternalModules flag
  • Loading branch information
lukastaegert committed Nov 8, 2017
2 parents 63d9ef6 + c406f97 commit 8365bb1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ast/variables/ExternalVariable.js
Expand Up @@ -29,7 +29,7 @@ export default class ExternalVariable extends Variable {
return es ? this.safeName : `${this.module.name}.${this.name}`;
}

includeDeclaration () {
includeVariable () {

This comment has been minimized.

Copy link
@coryjones1

coryjones1 Nov 8, 2017

This breaks the case where we import from an external library in one file and import internally with the same import name in another file. Example:

Container.js:

import Input from './Input';

...stuff with Input() // <-- This input has the namespace object of the external library's import instead of the locally imported thing.

Input.js:

import {Input} from 'external-library';
export default class MyFancyInput {
  stuffAndThing() {
    return Input.Foo();
  }
}
if ( this.included ) {
return false;
}
Expand Down
@@ -0,0 +1,13 @@
module.exports = {
description: 'imports from pure external modules that are used should not be omitted',
options: {
external: [ 'warning' ],
pureExternalModules: [ 'warning' ]
},
context: {
require: id => {
if ( id === 'warning' ) return arg => console.log( arg );
throw new Error( 'Unexpected import', id );
}
}
};
@@ -0,0 +1,3 @@
import warning from 'warning';

warning('hi');

0 comments on commit 8365bb1

Please sign in to comment.