-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't overwrite modules when using multiple versions
- Loading branch information
Showing
5 changed files
with
122 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,3 +391,40 @@ test('async loading', async t => { | |
const doesIncludeReact = outputs.some(output => includes(output, 'THIS IS REACT!')); | ||
t.false(doesIncludeReact); | ||
}); | ||
|
||
test('when using multiple versions of a module, make sure the right version is used for each', async t => { | ||
await cleanDir(path.resolve(__dirname, './fixtures/output/multiple-versions')); | ||
|
||
const stats = await runWebpack({ | ||
context: path.resolve(__dirname, './fixtures/app'), | ||
|
||
output: { | ||
publicPath: '', | ||
path: path.resolve(__dirname, './fixtures/output/multiple-versions') | ||
}, | ||
|
||
entry: { | ||
app: './mix.js' | ||
}, | ||
|
||
plugins: [ | ||
new ModulesCdnWebpackPlugin({ | ||
verbose: true | ||
}) | ||
] | ||
}); | ||
|
||
const files = stats.compilation.chunks.reduce((files, x) => files.concat(x.files), []); | ||
|
||
t.true(includes(files, 'app.js')); | ||
t.true(includes(files, 'https://unpkg.com/[email protected]/dist/react.js')); | ||
|
||
const output = await fs.readFile(path.resolve(__dirname, './fixtures/output/multiple-versions/app.js')); | ||
|
||
// NOTE: not inside t.false to prevent ava to display whole file in console | ||
const doesIncludeReact14 = includes(output, 'THIS IS [email protected]!'); | ||
t.true(doesIncludeReact14); | ||
|
||
const doesIncludeReact = includes(output, 'THIS IS REACT!'); | ||
t.false(doesIncludeReact); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
test/fixtures/app/node_modules/a/node_modules/react/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.