Skip to content

Commit

Permalink
feat(build): remove unneccessary windows cleaning
Browse files Browse the repository at this point in the history
It was not neccessary to clean the modulePaths in getNodeModuleData().
Removed that code.

This is believed to be a non-breaking change.
  • Loading branch information
jsleuth authored and pat841 committed Jun 26, 2018
1 parent 4e482db commit 2192c7e
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/PreserveModuleNamePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,11 @@ function getNodeModuleData(module: Webpack.Module): NodeModule.Data | null {
return null;
}

function cleanWindowsPaths(paths: RegExpMatchArray | null) {
var out: string[] = [];
if (!paths) {
return out;
}
for (var i = 0; i < paths.length; i += 1) {
out[i] = paths[i].replace(':', '').split('\\').join('/');
}
return out;
}

// Note that the negative lookahead (?!.*node_modules) ensures that we only match the last node_modules/ folder in the path,
// in case the package was located in a sub-node_modules (which can occur in special circumstances).
// We also need to take care of scoped modules. If the name starts with @ we must keep two parts,
// so @corp/bar is the proper module name.
const modulePaths = cleanWindowsPaths(module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i));
const modulePaths = module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i);
if (!modulePaths || modulePaths.length !== 4) {
return null;
}
Expand Down

0 comments on commit 2192c7e

Please sign in to comment.