@@ -12,60 +12,12 @@ import modulesScope from "postcss-modules-scope";
1212
1313const WEBPACK_IGNORE_COMMENT_REGEXP = / w e b p a c k I g n o r e : ( \s + ) ? ( t r u e | f a l s e ) / ;
1414
15- const matchRelativePath = / ^ \. \. ? [ / \\ ] / ;
16-
17- function isAbsolutePath ( str ) {
18- return path . posix . isAbsolute ( str ) || path . win32 . isAbsolute ( str ) ;
19- }
20-
21- function isRelativePath ( str ) {
22- return matchRelativePath . test ( str ) ;
23- }
24-
25- // TODO simplify for the next major release
2615function stringifyRequest ( loaderContext , request ) {
27- if (
28- typeof loaderContext . utils !== "undefined" &&
29- typeof loaderContext . utils . contextify === "function"
30- ) {
31- return JSON . stringify (
32- loaderContext . utils . contextify (
33- loaderContext . context || loaderContext . rootContext ,
34- request ,
35- ) ,
36- ) ;
37- }
38-
39- const splitted = request . split ( "!" ) ;
40- const { context } = loaderContext ;
41-
4216 return JSON . stringify (
43- splitted
44- . map ( ( part ) => {
45- // First, separate singlePath from query, because the query might contain paths again
46- const splittedPart = part . match ( / ^ ( .* ?) ( \? .* ) / ) ;
47- const query = splittedPart ? splittedPart [ 2 ] : "" ;
48- let singlePath = splittedPart ? splittedPart [ 1 ] : part ;
49-
50- if ( isAbsolutePath ( singlePath ) && context ) {
51- singlePath = path . relative ( context , singlePath ) ;
52-
53- if ( isAbsolutePath ( singlePath ) ) {
54- // If singlePath still matches an absolute path, singlePath was on a different drive than context.
55- // In this case, we leave the path platform-specific without replacing any separators.
56- // @see https://github.com/webpack/loader-utils/pull/14
57- return singlePath + query ;
58- }
59-
60- if ( isRelativePath ( singlePath ) === false ) {
61- // Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
62- singlePath = `./${ singlePath } ` ;
63- }
64- }
65-
66- return singlePath . replace ( / \\ / g, "/" ) + query ;
67- } )
68- . join ( "!" ) ,
17+ loaderContext . utils . contextify (
18+ loaderContext . context || loaderContext . rootContext ,
19+ request ,
20+ ) ,
6921 ) ;
7022}
7123
@@ -313,7 +265,7 @@ const filenameReservedRegex = /[<>:"/\\|?*]/g;
313265const reControlChars = / [ \u0000 - \u001f \u0080 - \u009f ] / g;
314266
315267function escapeLocalIdent ( localident ) {
316- // TODO simplify in the next major release
268+ // TODO simplify?
317269 return escape (
318270 localident
319271 // For `[hash]` placeholder
@@ -375,13 +327,8 @@ function defaultGetLocalIdent(
375327 let localIdentHash = "" ;
376328
377329 for ( let tier = 0 ; localIdentHash . length < hashDigestLength ; tier ++ ) {
378- // TODO remove this in the next major release
379- const hash =
380- loaderContext . utils &&
381- typeof loaderContext . utils . createHash === "function"
382- ? loaderContext . utils . createHash ( hashFunction )
383- : // eslint-disable-next-line no-underscore-dangle
384- loaderContext . _compiler . webpack . util . createHash ( hashFunction ) ;
330+ // eslint-disable-next-line no-underscore-dangle
331+ const hash = loaderContext . _compiler . webpack . util . createHash ( hashFunction ) ;
385332
386333 if ( hashSalt ) {
387334 hash . update ( hashSalt ) ;
0 commit comments