Skip to content

Commit 2192c7e

Browse files
jsleuthpat841
authored andcommitted
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 4e482db commit 2192c7e

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
@@ -199,22 +199,11 @@ function getNodeModuleData(module: Webpack.Module): NodeModule.Data | null {
199199
return null;
200200
}
201201

202-
function cleanWindowsPaths(paths: RegExpMatchArray | null) {
203-
var out: string[] = [];
204-
if (!paths) {
205-
return out;
206-
}
207-
for (var i = 0; i < paths.length; i += 1) {
208-
out[i] = paths[i].replace(':', '').split('\\').join('/');
209-
}
210-
return out;
211-
}
212-
213202
// Note that the negative lookahead (?!.*node_modules) ensures that we only match the last node_modules/ folder in the path,
214203
// in case the package was located in a sub-node_modules (which can occur in special circumstances).
215204
// We also need to take care of scoped modules. If the name starts with @ we must keep two parts,
216205
// so @corp/bar is the proper module name.
217-
const modulePaths = cleanWindowsPaths(module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i));
206+
const modulePaths = module.resource.match(/(.*\bnode_modules[\\/](?!.*\bnode_modules\b)((?:@[^\\/]+[\\/])?[^\\/]+))(.*)/i);
218207
if (!modulePaths || modulePaths.length !== 4) {
219208
return null;
220209
}

0 commit comments

Comments
 (0)