-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Webpack 4 #17
Changes from 9 commits
915e585
609e993
b4db3d3
cad4054
774a000
b402d12
fb494ff
7b7a0a8
499017c
919782c
7a1ec1b
de09cc0
a765fb5
caa35f8
27da4d2
25b9d90
e6e2dc0
3b913df
7e3d7f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug Jest", | ||
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js", | ||
"cwd": "${workspaceRoot}", | ||
"args": ["--i"] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ function DuplicatePackageCheckerPlugin(options) { | |
} | ||
|
||
function cleanPath(path) { | ||
return path.split("/node_modules/").join("/~/"); | ||
return path.split(/[\/\\]node_modules[\/\\]/).join("/~/"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes clean path work in windows |
||
} | ||
|
||
// Get closest package definition from path | ||
|
@@ -54,7 +54,10 @@ DuplicatePackageCheckerPlugin.prototype.apply = function(compiler) { | |
let exclude = this.options.exclude; | ||
let strict = this.options.strict; | ||
|
||
compiler.plugin("emit", function(compilation, callback) { | ||
compiler.hooks.emit.tapAsync("DuplicatePackageCheckerPlugin", function( | ||
compilation, | ||
callback | ||
) { | ||
let context = compilation.compiler.context; | ||
let modules = {}; | ||
|
||
|
@@ -157,7 +160,14 @@ DuplicatePackageCheckerPlugin.prototype.apply = function(compiler) { | |
let array = emitError ? compilation.errors : compilation.warnings; | ||
|
||
let i = 0; | ||
_.each(duplicates, (instances, name) => { | ||
|
||
let sortedDuplicateKeys = Object.keys(duplicates).sort(); | ||
|
||
sortedDuplicateKeys.map(name => { | ||
let instances = duplicates[name].sort( | ||
(a, b) => (a.version < b.version ? -1 : 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not perfect since it is just a string sort, but it keeps the snapshot tests from being fragile against the ordering of the duplicates and the duplication instances |
||
); | ||
|
||
let error = | ||
name + | ||
"\n" + | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets you debug the unit tests in vscode, I found it useful