-
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: do not include module if peers deps failed
closes #22
- Loading branch information
Showing
4 changed files
with
61 additions
and
2 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 |
---|---|---|
|
@@ -474,3 +474,55 @@ test('when using a custom resolver', async t => { | |
const doesIncludeReact = includes(output, 'THIS IS REACT!'); | ||
t.false(doesIncludeReact); | ||
}); | ||
|
||
test('when one peerDependency fails, do not load from cdn', async t => { | ||
await cleanDir(path.resolve(__dirname, './fixtures/output/failing-peer-dependency')); | ||
|
||
const stats = await runWebpack({ | ||
context: path.resolve(__dirname, './fixtures/app'), | ||
|
||
output: { | ||
publicPath: '', | ||
path: path.resolve(__dirname, './fixtures/output/failing-peer-dependency') | ||
}, | ||
|
||
entry: { | ||
app: './peer-dependencies.js' | ||
}, | ||
|
||
plugins: [ | ||
new ModulesCdnWebpackPlugin({ | ||
resolver: name => { | ||
return { | ||
'@angular/core': { | ||
var: 'ng', | ||
name: 'angular', | ||
url: 'https://unpkg.com/@angular/[email protected]/bundles/core.umd.js', | ||
version: '4.2.4' | ||
}, | ||
rxjs: { | ||
var: 'Rx', | ||
name: 'rxjs', | ||
url: 'https://unpkg.com/[email protected]/bundles/Rx.js', | ||
version: '5.4.1' | ||
} | ||
}[name]; | ||
} | ||
}) | ||
] | ||
}); | ||
|
||
const files = stats.compilation.chunks.reduce((files, x) => files.concat(x.files), []); | ||
|
||
t.is(files.length, 2); | ||
t.true(includes(files, 'app.js')); | ||
t.false(includes(files, 'https://unpkg.com/@angular/[email protected]/bundles/core.umd.js')); | ||
t.true(includes(files, 'https://unpkg.com/[email protected]/bundles/Rx.js')); | ||
t.false(includes(files, 'https://unpkg.com/[email protected]/dist/zone.js')); | ||
|
||
let output = await fs.readFile(path.resolve(__dirname, './fixtures/output/failing-peer-dependency/app.js')); | ||
output = output.toString(); | ||
|
||
const doesIncludeAngular = includes(output, 'console.log(\'THIS IS ANGULAR!\');'); | ||
t.true(doesIncludeAngular); | ||
}); |
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.