mirror of https://github.com/webpack/webpack.git
feat(perf): hoist final regexp
This commit is contained in:
parent
5806d15221
commit
987a9f3954
|
|
@ -9,6 +9,7 @@ const NORMALIZE_SLASH_DIRECTION_REGEXP = /\\/g;
|
|||
const PATH_CHARS_REGEXP = /[-[\]{}()*+?.,\\^$|#\s]/g;
|
||||
const SEPERATOR_REGEXP = /[\/\\]$/;
|
||||
const FRONT_OR_BACK_BANG_REGEXP = /^!|!$/g;
|
||||
const INDEX_JS_REGEXP = /\/index.js(!|\?|\(query\))/g;
|
||||
|
||||
const normalizeBackSlashDirection = (request) => {
|
||||
return request.replace(NORMALIZE_SLASH_DIRECTION_REGEXP, "/");
|
||||
|
|
@ -41,8 +42,6 @@ class RequestShortener {
|
|||
this.buildinsAsModule = buildinsAsModule;
|
||||
this.buildinsRegExp = createRegExpForPath(buildins);
|
||||
}
|
||||
|
||||
this.indexJsRegExp = /\/index.js(!|\?|\(query\))/g;
|
||||
}
|
||||
|
||||
shorten(request) {
|
||||
|
|
@ -56,7 +55,7 @@ class RequestShortener {
|
|||
request = request.replace(this.parentDirectoryRegExp, "!..");
|
||||
if(!this.buildinsAsModule && this.buildinsRegExp)
|
||||
request = request.replace(this.buildinsRegExp, "!(webpack)");
|
||||
request = request.replace(this.indexJsRegExp, "$1");
|
||||
request = request.replace(INDEX_JS_REGEXP, "$1");
|
||||
return request.replace(FRONT_OR_BACK_BANG_REGEXP, "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue