Skip to content

Commit

Permalink
fix: returns right var name in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mastilver committed Jul 20, 2017
1 parent 7d34004 commit adcd2b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class ModulesCdnWebpackPlugin {
if (isModuleAlreadyLoaded) {
const isSameVersion = this.modulesFromCdn[modulePath].version === version;
if (isSameVersion) {
return modulePath;
return this.modulesFromCdn[modulePath].var;
}

return false;
Expand Down
6 changes: 5 additions & 1 deletion test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ test('when using multiple versions of a module, make sure the right version is u
t.true(includes(files, 'app.js'));
t.true(includes(files, 'https://unpkg.com/react@15.6.1/dist/react.js'));

const output = await fs.readFile(path.resolve(__dirname, './fixtures/output/multiple-versions/app.js'));
let output = await fs.readFile(path.resolve(__dirname, './fixtures/output/multiple-versions/app.js'));
output = output.toString();

const numberOfExports = output.match(/module\.exports =/g).length;
t.is(numberOfExports, 1);

// NOTE: not inside t.false to prevent ava to display whole file in console
const doesIncludeReact14 = includes(output, 'THIS IS REACT@0.14.9!');
Expand Down

0 comments on commit adcd2b9

Please sign in to comment.