Skip to content

Commit 7049f27

Browse files
committed
feat(build): remove unneccessary windows cleaning
It was not neccessary to clean the modulePaths in getNodeModuleData(). Removed that code. This is believed to be a non-breaking change.
1 parent 881f269 commit 7049f27

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

src/PreserveModuleNamePlugin.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,11 @@ function getNodeModuleData(module: Webpack.Module): NodeModule.Data | null {
149149
return null;
150150
}
151151

152-
function cleanWindowsPaths(paths: RegExpMatchArray | null) {
153-
var out: string[] = [];
154-
if (!paths) {
155-
return out;
156-
}
157-
for (var i = 0; i < paths.length; i += 1) {
158-
out[i] = paths[i].replace(':', '').split('\\').join('/');
159-
}
160-
return out;
161-
}
162-
163152
// Note that the negative lookahead (?!.*node_modules) ensures that we only match the last node_modules/ folder in the path,
164153
// in case the package was located in a sub-node_modules (which can occur in special circumstances).
165154
// We also need to take care of scoped modules. If the name starts with @ we must keep two parts,
166155
// so @corp/bar is the proper module name.
167-
const modulePaths = cleanWindowsPaths(module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i));
156+
const modulePaths = module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i);
168157
if (!modulePaths || modulePaths.length !== 4) {
169158
return null;
170159
}

0 commit comments

Comments
 (0)