css-loader 5.2.2 → 5.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [5.2.3](https://github.com/webpack-contrib/css-loader/compare/v5.2.2...v5.2.3) (2021-04-19)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* improve performance
|
|
10
|
+
|
|
5
11
|
### [5.2.2](https://github.com/webpack-contrib/css-loader/compare/v5.2.1...v5.2.2) (2021-04-16)
|
|
6
12
|
|
|
7
13
|
|
|
@@ -19,7 +19,7 @@ function parseNode(atRule, key) {
|
|
|
19
19
|
|
|
20
20
|
if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
|
|
21
21
|
const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
|
|
22
|
-
const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.
|
|
22
|
+
const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
|
|
23
23
|
|
|
24
24
|
if (matched && matched[2] === "true") {
|
|
25
25
|
return;
|
|
@@ -29,7 +29,7 @@ function parseNode(atRule, key) {
|
|
|
29
29
|
const prevNode = atRule.prev();
|
|
30
30
|
|
|
31
31
|
if (prevNode && prevNode.type === "comment") {
|
|
32
|
-
const matched = prevNode.text.match(_utils.
|
|
32
|
+
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
|
|
33
33
|
|
|
34
34
|
if (matched && matched[2] === "true") {
|
|
35
35
|
return;
|
|
@@ -45,7 +45,7 @@ function getWebpackIgnoreCommentValue(index, nodes, inBetween) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const matched = prevValueNode.value.match(_utils.
|
|
48
|
+
const matched = prevValueNode.value.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
|
|
49
49
|
return matched && matched[2] === "true";
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -74,7 +74,7 @@ function parseDeclaration(declaration, key, result) {
|
|
|
74
74
|
|
|
75
75
|
if (declaration.raws && declaration.raws.between) {
|
|
76
76
|
const lastCommentIndex = declaration.raws.between.lastIndexOf("/*");
|
|
77
|
-
const matched = declaration.raws.between.slice(lastCommentIndex).match(_utils.
|
|
77
|
+
const matched = declaration.raws.between.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
|
|
78
78
|
|
|
79
79
|
if (matched) {
|
|
80
80
|
inBetween = matched[2] === "true";
|
|
@@ -85,7 +85,7 @@ function parseDeclaration(declaration, key, result) {
|
|
|
85
85
|
const prevNode = declaration.prev();
|
|
86
86
|
|
|
87
87
|
if (prevNode && prevNode.type === "comment") {
|
|
88
|
-
const matched = prevNode.text.match(_utils.
|
|
88
|
+
const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
|
|
89
89
|
|
|
90
90
|
if (matched) {
|
|
91
91
|
isIgnoreOnDeclaration = matched[2] === "true";
|
package/dist/utils.js
CHANGED
|
@@ -22,7 +22,7 @@ exports.resolveRequests = resolveRequests;
|
|
|
22
22
|
exports.isUrlRequestable = isUrlRequestable;
|
|
23
23
|
exports.sort = sort;
|
|
24
24
|
exports.combineRequests = combineRequests;
|
|
25
|
-
exports.
|
|
25
|
+
exports.WEBPACK_IGNORE_COMMENT_REGEXP = void 0;
|
|
26
26
|
|
|
27
27
|
var _url = require("url");
|
|
28
28
|
|
|
@@ -46,12 +46,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
46
46
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
47
47
|
Author Tobias Koppers @sokra
|
|
48
48
|
*/
|
|
49
|
-
const
|
|
50
|
-
const unescapeRegExp = new RegExp(`\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, "ig");
|
|
51
|
-
const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i;
|
|
52
|
-
const webpackIgnoreCommentRegexp = /webpackIgnore:(\s+)?(true|false)/; // eslint-disable-next-line no-useless-escape
|
|
49
|
+
const WEBPACK_IGNORE_COMMENT_REGEXP = /webpackIgnore:(\s+)?(true|false)/; // eslint-disable-next-line no-useless-escape
|
|
53
50
|
|
|
54
|
-
exports.
|
|
51
|
+
exports.WEBPACK_IGNORE_COMMENT_REGEXP = WEBPACK_IGNORE_COMMENT_REGEXP;
|
|
55
52
|
const regexSingleEscape = /[ -,.\/:-@[\]\^`{-~]/;
|
|
56
53
|
const regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
|
|
57
54
|
|
|
@@ -99,20 +96,87 @@ function escape(string) {
|
|
|
99
96
|
return output;
|
|
100
97
|
}
|
|
101
98
|
|
|
99
|
+
function gobbleHex(str) {
|
|
100
|
+
const lower = str.toLowerCase();
|
|
101
|
+
let hex = "";
|
|
102
|
+
let spaceTerminated = false; // eslint-disable-next-line no-undefined
|
|
103
|
+
|
|
104
|
+
for (let i = 0; i < 6 && lower[i] !== undefined; i++) {
|
|
105
|
+
const code = lower.charCodeAt(i); // check to see if we are dealing with a valid hex char [a-f|0-9]
|
|
106
|
+
|
|
107
|
+
const valid = code >= 97 && code <= 102 || code >= 48 && code <= 57; // https://drafts.csswg.org/css-syntax/#consume-escaped-code-point
|
|
108
|
+
|
|
109
|
+
spaceTerminated = code === 32;
|
|
110
|
+
|
|
111
|
+
if (!valid) {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
hex += lower[i];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (hex.length === 0) {
|
|
119
|
+
// eslint-disable-next-line no-undefined
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const codePoint = parseInt(hex, 16);
|
|
124
|
+
const isSurrogate = codePoint >= 0xd800 && codePoint <= 0xdfff; // Add special case for
|
|
125
|
+
// "If this number is zero, or is for a surrogate, or is greater than the maximum allowed code point"
|
|
126
|
+
// https://drafts.csswg.org/css-syntax/#maximum-allowed-code-point
|
|
127
|
+
|
|
128
|
+
if (isSurrogate || codePoint === 0x0000 || codePoint > 0x10ffff) {
|
|
129
|
+
return ["\uFFFD", hex.length + (spaceTerminated ? 1 : 0)];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return [String.fromCodePoint(codePoint), hex.length + (spaceTerminated ? 1 : 0)];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const CONTAINS_ESCAPE = /\\/;
|
|
136
|
+
|
|
102
137
|
function unescape(str) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
const needToProcess = CONTAINS_ESCAPE.test(str);
|
|
139
|
+
|
|
140
|
+
if (!needToProcess) {
|
|
141
|
+
return str;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let ret = "";
|
|
145
|
+
|
|
146
|
+
for (let i = 0; i < str.length; i++) {
|
|
147
|
+
if (str[i] === "\\") {
|
|
148
|
+
const gobbled = gobbleHex(str.slice(i + 1, i + 7)); // eslint-disable-next-line no-undefined
|
|
149
|
+
|
|
150
|
+
if (gobbled !== undefined) {
|
|
151
|
+
ret += gobbled[0];
|
|
152
|
+
i += gobbled[1]; // eslint-disable-next-line no-continue
|
|
153
|
+
|
|
154
|
+
continue;
|
|
155
|
+
} // Retain a pair of \\ if double escaped `\\\\`
|
|
156
|
+
// https://github.com/postcss/postcss-selector-parser/commit/268c9a7656fb53f543dc620aa5b73a30ec3ff20e
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (str[i + 1] === "\\") {
|
|
160
|
+
ret += "\\";
|
|
161
|
+
i += 1; // eslint-disable-next-line no-continue
|
|
162
|
+
|
|
163
|
+
continue;
|
|
164
|
+
} // if \\ is at the end of the string retain it
|
|
165
|
+
// https://github.com/postcss/postcss-selector-parser/commit/01a6b346e3612ce1ab20219acc26abdc259ccefb
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if (str.length === i + 1) {
|
|
169
|
+
ret += str[i];
|
|
170
|
+
} // eslint-disable-next-line no-continue
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
ret += str[i];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return ret;
|
|
116
180
|
}
|
|
117
181
|
|
|
118
182
|
function normalizePath(file) {
|
|
@@ -144,6 +208,8 @@ function defaultGetLocalIdent(loaderContext, localIdentName, localName, options)
|
|
|
144
208
|
return (0, _loaderUtils.interpolateName)(loaderContext, localIdentName, options);
|
|
145
209
|
}
|
|
146
210
|
|
|
211
|
+
const NATIVE_WIN32_PATH = /^[A-Z]:[/\\]|^\\\\/i;
|
|
212
|
+
|
|
147
213
|
function normalizeUrl(url, isStringValue) {
|
|
148
214
|
let normalizedUrl = url.replace(/^( |\t\n|\r\n|\r|\f)*/g, "").replace(/( |\t\n|\r\n|\r|\f)*$/g, "");
|
|
149
215
|
|
|
@@ -151,7 +217,7 @@ function normalizeUrl(url, isStringValue) {
|
|
|
151
217
|
normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, "");
|
|
152
218
|
}
|
|
153
219
|
|
|
154
|
-
if (
|
|
220
|
+
if (NATIVE_WIN32_PATH.test(url)) {
|
|
155
221
|
try {
|
|
156
222
|
normalizedUrl = decodeURI(normalizedUrl);
|
|
157
223
|
} catch (error) {// Ignore
|
|
@@ -685,7 +751,7 @@ function isUrlRequestable(url) {
|
|
|
685
751
|
} // Absolute URLs
|
|
686
752
|
|
|
687
753
|
|
|
688
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !
|
|
754
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(url) && !NATIVE_WIN32_PATH.test(url)) {
|
|
689
755
|
return false;
|
|
690
756
|
} // `#` URLs
|
|
691
757
|
|