diff --git a/package-lock.json b/package-lock.json index 220ab44e..6354a181 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10679,9 +10679,9 @@ "dev": true }, "mini-css-extract-plugin": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.0.tgz", - "integrity": "sha512-lp3GeY7ygcgAmVIcRPBVhIkf8Us7FZjA+ILpal44qLdSu11wmjKQ3d9k15lfD7pO4esu9eUIAW7qiYIBppv40A==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.10.0.tgz", + "integrity": "sha512-QgKgJBjaJhxVPwrLNqqwNS0AGkuQQ31Hp4xGXEK/P7wehEg6qmNtReHKai3zRXqY60wGVWLYcOMJK2b98aGc3A==", "dev": true, "requires": { "loader-utils": "^1.1.0", diff --git a/package.json b/package.json index e53236df..ad72e6a6 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "less-loader": "^6.2.0", "lint-staged": "^10.2.11", "memfs": "^3.2.0", - "mini-css-extract-plugin": "^0.9.0", + "mini-css-extract-plugin": "^0.10.0", "npm-run-all": "^4.1.5", "postcss-loader": "^3.0.0", "postcss-preset-env": "^6.7.0", @@ -91,7 +91,7 @@ "stylus": "^0.54.8", "stylus-loader": "^3.0.2", "url-loader": "^4.1.0", - "webpack": "^4.44.0" + "webpack": "^4.44.1" }, "keywords": [ "webpack", diff --git a/src/utils.js b/src/utils.js index e08a74cc..49f37d29 100644 --- a/src/utils.js +++ b/src/utils.js @@ -414,7 +414,7 @@ function normalizeSourceMapForRuntime(map, loaderContext) { path.relative(loaderContext.rootContext, absoluteSource) ); - return `webpack:///${contextifyPath}`; + return `webpack://${contextifyPath}`; }); } diff --git a/test/__snapshots__/sourceMap-option.test.js.snap b/test/__snapshots__/sourceMap-option.test.js.snap index f016508c..5b466646 100644 --- a/test/__snapshots__/sourceMap-option.test.js.snap +++ b/test/__snapshots__/sourceMap-option.test.js.snap @@ -1,8 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`"sourceMap" option false should not generate source maps when source maps equal to "null" from an other loader: errors 1`] = `Array []`; +exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: errors 1`] = `Array []`; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "null" from an other loader: module 1`] = ` +exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; @@ -15,7 +15,7 @@ export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "null" from an other loader: result 1`] = ` +exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: result 1`] = ` Array [ Array [ "../../src/index.js?[ident]!./source-map/nested/nested.css", @@ -36,11 +36,11 @@ Array [ ] `; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "null" from an other loader: warnings 1`] = `Array []`; +exports[`"sourceMap" option false should not generate source maps when previous loader does not generate source maps: warnings 1`] = `Array []`; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "undefined" from an other loader: errors 1`] = `Array []`; +exports[`"sourceMap" option false should not generate source maps when previous loader generates source maps: errors 1`] = `Array []`; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "undefined" from an other loader: module 1`] = ` +exports[`"sourceMap" option false should not generate source maps when previous loader generates source maps: module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; @@ -53,7 +53,7 @@ export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "undefined" from an other loader: result 1`] = ` +exports[`"sourceMap" option false should not generate source maps when previous loader generates source maps: result 1`] = ` Array [ Array [ "../../src/index.js?[ident]!./source-map/nested/nested.css", @@ -74,149 +74,7 @@ Array [ ] `; -exports[`"sourceMap" option false should not generate source maps when source maps equal to "undefined" from an other loader: warnings 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid and string from an other loader: errors 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid and string from an other loader: module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; -import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\"]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid and string from an other loader: result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./source-map/nested/nested.css", - ".nested { - color: blue; -} -", - "", - ], - Array [ - "./source-map/basic.css", - ".class { - color: red; -} -", - "", - ], -] -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid and string from an other loader: warnings 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`postcss-loader\`): errors 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`postcss-loader\`): module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; -import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.postcss.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\":root {\\\\n --fontSize: 1rem;\\\\n --mainColor: rgba(18,52,86,0.47059);\\\\n --secondaryColor: rgba(102, 51, 153, 0.9);\\\\n}\\\\n\\\\nhtml {\\\\n overflow-x: hidden;\\\\n overflow-y: auto;\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (max-width: 50rem) {\\\\n body {\\\\n color: rgba(18,52,86,0.47059);\\\\n color: var(--mainColor);\\\\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;\\\\n font-size: 1rem;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(1rem * 1.5);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n word-wrap: break-word;\\\\n padding-left: calc(1rem / 2 + 1px);\\\\n padding-right: calc(1rem / 2 + 1px);\\\\n padding-left: calc(var(--fontSize) / 2 + 1px);\\\\n padding-right: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\nh1,h2,h3,h4,h5,h6 {\\\\n margin-top: 0;\\\\n margin-bottom: 0;\\\\n}\\\\n\\\\na {\\\\n color: rgba(0, 0, 255, 0.9)\\\\n}\\\\n\\\\na:hover {\\\\n color: #639;\\\\n }\\\\n\\", \\"\\"]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`postcss-loader\`): result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./source-map/nested/nested.postcss.css", - ".nested { - color: blue; -} -", - "", - ], - Array [ - "./source-map/basic.postcss.css", - ":root { - --fontSize: 1rem; - --mainColor: rgba(18,52,86,0.47059); - --secondaryColor: rgba(102, 51, 153, 0.9); -} - -html { - overflow-x: hidden; - overflow-y: auto; - overflow: hidden auto; -} - -@media (max-width: 50rem) { - body { - color: rgba(18,52,86,0.47059); - color: var(--mainColor); - font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif; - font-size: 1rem; - font-size: var(--fontSize); - line-height: calc(1rem * 1.5); - line-height: calc(var(--fontSize) * 1.5); - word-wrap: break-word; - padding-left: calc(1rem / 2 + 1px); - padding-right: calc(1rem / 2 + 1px); - padding-left: calc(var(--fontSize) / 2 + 1px); - padding-right: calc(var(--fontSize) / 2 + 1px); - } -} - -h1,h2,h3,h4,h5,h6 { - margin-top: 0; - margin-bottom: 0; -} - -a { - color: rgba(0, 0, 255, 0.9) -} - -a:hover { - color: #639; - } -", - "", - ], -] -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`postcss-loader\`): warnings 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`sass-loader\`): errors 1`] = `Array []`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`sass-loader\`): module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\"body {\\\\n font: 100% Helvetica, sans-serif;\\\\n color: #333;\\\\n}\\", \\"\\"]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`sass-loader\`): result 1`] = ` -Array [ - Array [ - "./source-map/basic.scss", - "body { - font: 100% Helvetica, sans-serif; - color: #333; -}", - "", - ], -] -`; - -exports[`"sourceMap" option false should not generate source maps when source maps is valid from an other loader (\`sass-loader\`): warnings 1`] = `Array []`; +exports[`"sourceMap" option false should not generate source maps when previous loader generates source maps: warnings 1`] = `Array []`; exports[`"sourceMap" option false should not generate source maps: errors 1`] = `Array []`; @@ -301,7 +159,7 @@ exports[`"sourceMap" option true should generate source maps #2: module 1`] = ` import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\".foo {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/with-query.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\".foo {\\\\n color: red;\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\".foo {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/with-query.css\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\".foo {\\\\n color: red;\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " @@ -320,7 +178,7 @@ Array [ "mappings": "AAAA;EACE,UAAU;AACZ", "names": Array [], "sources": Array [ - "webpack:///source-map/with-query.css", + "webpack://source-map/with-query.css", ], "sourcesContent": Array [ ".foo { @@ -336,25 +194,25 @@ Array [ exports[`"sourceMap" option true should generate source maps #2: warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: module 1`] = ` +exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); ___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://test/fixtures/source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: result 1`] = ` +exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: result 1`] = ` Array [ Array [ - "../../src/index.js?[ident]!./source-map/nested/nested.css", + "./src/index.js?[ident]!./test/fixtures/source-map/nested/nested.css", ".nested { color: blue; } @@ -364,7 +222,7 @@ Array [ "mappings": "AAAA;EACE,WAAW;AACb", "names": Array [], "sources": Array [ - "webpack:///source-map/nested/nested.css", + "webpack://test/fixtures/source-map/nested/nested.css", ], "sourcesContent": Array [ ".nested { @@ -376,7 +234,7 @@ Array [ }, ], Array [ - "./source-map/basic.css", + "./test/fixtures/source-map/basic.css", ".class { color: red; } @@ -386,7 +244,7 @@ Array [ "mappings": "AAEA;EACE,UAAU;AACZ", "names": Array [], "sources": Array [ - "webpack:///source-map/basic.css", + "webpack://test/fixtures/source-map/basic.css", ], "sourcesContent": Array [ "@import \\"./nested/nested.css\\"; @@ -402,160 +260,110 @@ Array [ ] `; -exports[`"sourceMap" option true should generate source maps when source maps equal to "null" from an other loader: warnings 1`] = `Array []`; - -exports[`"sourceMap" option true should generate source maps when source maps equal to "undefined" from an other loader: errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps equal to "undefined" from an other loader: module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; -import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; +exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps equal to "undefined" from an other loader: result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./source-map/nested/nested.css", - ".nested { +exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: extracted css 1`] = ` +".nested { color: blue; } -", - "", - Object { - "mappings": "AAAA;EACE,WAAW;AACb", - "names": Array [], - "sources": Array [ - "webpack:///source-map/nested/nested.css", - ], - "sourcesContent": Array [ - ".nested { - color: blue; + +.class { + color: red; } -", - ], - "version": 3, - }, + + +/*# sourceMappingURL=main.xxxxxxxxxxxxxxxxxxxx.css.map*/" +`; + +exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: source map 1`] = ` +Object { + "file": "main.xxxxxxxxxxxxxxxxxxxx.css", + "mappings": "AAAA;EACE,WAAW;AACb;;ACAA;EACE,UAAU;AACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "webpack:///test/fixtures/source-map/nested/nested.css", + "webpack:///test/fixtures/source-map/basic.css", ], - Array [ - "./source-map/basic.css", - ".class { - color: red; + "sourcesContent": Array [ + ".nested { + color: blue; } ", - "", - Object { - "mappings": "AAEA;EACE,UAAU;AACZ", - "names": Array [], - "sources": Array [ - "webpack:///source-map/basic.css", - ], - "sourcesContent": Array [ - "@import \\"./nested/nested.css\\"; + "@import \\"./nested/nested.css\\"; .class { color: red; } ", - ], - "version": 3, - }, ], -] + "version": 3, +} `; -exports[`"sourceMap" option true should generate source maps when source maps equal to "undefined" from an other loader: warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when css was extracted and do not change "[contenthash]" on different platform: warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid and is set sourceRoot: errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when css was extracted: errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid and is set sourceRoot: module 1`] = ` -"// Imports -import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; -import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; -var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); -___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); -// Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); -// Exports -export default ___CSS_LOADER_EXPORT___; -" -`; - -exports[`"sourceMap" option true should generate source maps when source maps is valid and is set sourceRoot: result 1`] = ` -Array [ - Array [ - "../../src/index.js?[ident]!./source-map/nested/nested.css", - ".nested { +exports[`"sourceMap" option true should generate source maps when css was extracted: extracted css 1`] = ` +".nested { color: blue; } -", - "", - Object { - "mappings": "AAAA;EACE,WAAW;AACb", - "names": Array [], - "sources": Array [ - "webpack:///source-map/nested/nested.css", - ], - "sourcesContent": Array [ - ".nested { - color: blue; + +.class { + color: red; } -", - ], - "version": 3, - }, + + +/*# sourceMappingURL=main.css.map*/" +`; + +exports[`"sourceMap" option true should generate source maps when css was extracted: source map 1`] = ` +Object { + "file": "main.css", + "mappings": "AAAA;EACE,WAAW;AACb;;ACAA;EACE,UAAU;AACZ", + "names": Array [], + "sourceRoot": "", + "sources": Array [ + "webpack:///source-map/nested/nested.css", + "webpack:///source-map/basic.css", ], - Array [ - "./source-map/basic.css", - ".class { - color: red; + "sourcesContent": Array [ + ".nested { + color: blue; } ", - "", - Object { - "mappings": "AAEA;EACE,UAAU;AACZ", - "names": Array [], - "sources": Array [ - "webpack:///source-map/basic.css", - ], - "sourcesContent": Array [ - "@import \\"./nested/nested.css\\"; + "@import \\"./nested/nested.css\\"; .class { color: red; } ", - ], - "version": 3, - }, ], -] + "version": 3, +} `; -exports[`"sourceMap" option true should generate source maps when source maps is valid and is set sourceRoot: warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when css was extracted: warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid and string from an other loader: errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader does not generate source maps: errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid and string from an other loader: module 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader does not generate source maps: module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); ___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option true should generate source maps when source maps is valid and string from an other loader: result 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader does not generate source maps: result 1`] = ` Array [ Array [ "../../src/index.js?[ident]!./source-map/nested/nested.css", @@ -568,7 +376,7 @@ Array [ "mappings": "AAAA;EACE,WAAW;AACb", "names": Array [], "sources": Array [ - "webpack:///source-map/nested/nested.css", + "webpack://source-map/nested/nested.css", ], "sourcesContent": Array [ ".nested { @@ -590,7 +398,7 @@ Array [ "mappings": "AAEA;EACE,UAAU;AACZ", "names": Array [], "sources": Array [ - "webpack:///source-map/basic.css", + "webpack://source-map/basic.css", ], "sourcesContent": Array [ "@import \\"./nested/nested.css\\"; @@ -606,22 +414,22 @@ Array [ ] `; -exports[`"sourceMap" option true should generate source maps when source maps is valid and string from an other loader: warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader does not generate source maps: warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`less-loader\`): errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("less-loader"): errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`less-loader\`): module 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("less-loader"): module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\"body {\\\\n font: 100% Helvetica, sans-serif;\\\\n color: #333;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/base.less\\"],\\"names\\":[],\\"mappings\\":\\"AAGA;EACE,gCAAA;EACA,WAAA;AAFF\\",\\"sourcesContent\\":[\\"@font-stack: Helvetica, sans-serif;\\\\n@primary-color: #333;\\\\n\\\\nbody {\\\\n font: 100% @font-stack;\\\\n color: @primary-color;\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\"body {\\\\n font: 100% Helvetica, sans-serif;\\\\n color: #333;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/base.less\\"],\\"names\\":[],\\"mappings\\":\\"AAGA;EACE,gCAAA;EACA,WAAA;AAFF\\",\\"sourcesContent\\":[\\"@font-stack: Helvetica, sans-serif;\\\\n@primary-color: #333;\\\\n\\\\nbody {\\\\n font: 100% @font-stack;\\\\n color: @primary-color;\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`less-loader\`): result 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("less-loader"): result 1`] = ` Array [ Array [ "./source-map/base.less", @@ -635,7 +443,7 @@ Array [ "mappings": "AAGA;EACE,gCAAA;EACA,WAAA;AAFF", "names": Array [], "sources": Array [ - "webpack:///source-map/base.less", + "webpack://source-map/base.less", ], "sourcesContent": Array [ "@font-stack: Helvetica, sans-serif; @@ -653,24 +461,24 @@ body { ] `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`less-loader\`): warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("less-loader"): warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`postcss-loader\`): errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("postcss-loader"): errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`postcss-loader\`): module 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("postcss-loader"): module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.postcss.css\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); ___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\":root {\\\\n --fontSize: 1rem;\\\\n --mainColor: rgba(18,52,86,0.47059);\\\\n --secondaryColor: rgba(102, 51, 153, 0.9);\\\\n}\\\\n\\\\nhtml {\\\\n overflow-x: hidden;\\\\n overflow-y: auto;\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (max-width: 50rem) {\\\\n body {\\\\n color: rgba(18,52,86,0.47059);\\\\n color: var(--mainColor);\\\\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;\\\\n font-size: 1rem;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(1rem * 1.5);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n word-wrap: break-word;\\\\n padding-left: calc(1rem / 2 + 1px);\\\\n padding-right: calc(1rem / 2 + 1px);\\\\n padding-left: calc(var(--fontSize) / 2 + 1px);\\\\n padding-right: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\nh1,h2,h3,h4,h5,h6 {\\\\n margin-top: 0;\\\\n margin-bottom: 0;\\\\n}\\\\n\\\\na {\\\\n color: rgba(0, 0, 255, 0.9)\\\\n}\\\\n\\\\na:hover {\\\\n color: #639;\\\\n }\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.postcss.css\\"],\\"names\\":[],\\"mappings\\":\\"AAKA;EACE,gBAAgB;EAChB,mCAAsB;EACtB,yCAA4C;AAC9C;;AAEA;EACE,kBAAqB;EAArB,gBAAqB;EAArB,qBAAqB;AACvB;;AAEA;EACE;IACE,6BAAuB;IAAvB,uBAAuB;IACvB,iGAAsB;IACtB,eAA0B;IAA1B,0BAA0B;IAC1B,6BAAwC;IAAxC,wCAAwC;IACxC,qBAAyB;IACzB,kCAA+C;IAA/C,mCAA+C;IAA/C,6CAA+C;IAA/C,8CAA+C;EACjD;AACF;;AAEA;EACE,aAAe;EAAf,gBAAe;AACjB;;AAEA;EACE;AAKF;;AAHA;GACG,WAAoB;CACtB\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.postcss.css\\\\\\";\\\\n\\\\n@custom-media --viewport-medium (width <= 50rem);\\\\n@custom-selector :--heading h1, h2, h3, h4, h5, h6;\\\\n\\\\n:root {\\\\n --fontSize: 1rem;\\\\n --mainColor: #12345678;\\\\n --secondaryColor: lab(32.5 38.5 -47.6 / 90%);\\\\n}\\\\n\\\\nhtml {\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (--viewport-medium) {\\\\n body {\\\\n color: var(--mainColor);\\\\n font-family: system-ui;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n overflow-wrap: break-word;\\\\n padding-inline: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\n:--heading {\\\\n margin-block: 0;\\\\n}\\\\n\\\\na {\\\\n color: rgb(0 0 100% / 90%);\\\\n\\\\n&:hover {\\\\n color: rebeccapurple;\\\\n }\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\":root {\\\\n --fontSize: 1rem;\\\\n --mainColor: rgba(18,52,86,0.47059);\\\\n --secondaryColor: rgba(102, 51, 153, 0.9);\\\\n}\\\\n\\\\nhtml {\\\\n overflow-x: hidden;\\\\n overflow-y: auto;\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (max-width: 50rem) {\\\\n body {\\\\n color: rgba(18,52,86,0.47059);\\\\n color: var(--mainColor);\\\\n font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;\\\\n font-size: 1rem;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(1rem * 1.5);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n word-wrap: break-word;\\\\n padding-left: calc(1rem / 2 + 1px);\\\\n padding-right: calc(1rem / 2 + 1px);\\\\n padding-left: calc(var(--fontSize) / 2 + 1px);\\\\n padding-right: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\nh1,h2,h3,h4,h5,h6 {\\\\n margin-top: 0;\\\\n margin-bottom: 0;\\\\n}\\\\n\\\\na {\\\\n color: rgba(0, 0, 255, 0.9)\\\\n}\\\\n\\\\na:hover {\\\\n color: #639;\\\\n }\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/basic.postcss.css\\"],\\"names\\":[],\\"mappings\\":\\"AAKA;EACE,gBAAgB;EAChB,mCAAsB;EACtB,yCAA4C;AAC9C;;AAEA;EACE,kBAAqB;EAArB,gBAAqB;EAArB,qBAAqB;AACvB;;AAEA;EACE;IACE,6BAAuB;IAAvB,uBAAuB;IACvB,iGAAsB;IACtB,eAA0B;IAA1B,0BAA0B;IAC1B,6BAAwC;IAAxC,wCAAwC;IACxC,qBAAyB;IACzB,kCAA+C;IAA/C,mCAA+C;IAA/C,6CAA+C;IAA/C,8CAA+C;EACjD;AACF;;AAEA;EACE,aAAe;EAAf,gBAAe;AACjB;;AAEA;EACE;AAKF;;AAHA;GACG,WAAoB;CACtB\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.postcss.css\\\\\\";\\\\n\\\\n@custom-media --viewport-medium (width <= 50rem);\\\\n@custom-selector :--heading h1, h2, h3, h4, h5, h6;\\\\n\\\\n:root {\\\\n --fontSize: 1rem;\\\\n --mainColor: #12345678;\\\\n --secondaryColor: lab(32.5 38.5 -47.6 / 90%);\\\\n}\\\\n\\\\nhtml {\\\\n overflow: hidden auto;\\\\n}\\\\n\\\\n@media (--viewport-medium) {\\\\n body {\\\\n color: var(--mainColor);\\\\n font-family: system-ui;\\\\n font-size: var(--fontSize);\\\\n line-height: calc(var(--fontSize) * 1.5);\\\\n overflow-wrap: break-word;\\\\n padding-inline: calc(var(--fontSize) / 2 + 1px);\\\\n }\\\\n}\\\\n\\\\n:--heading {\\\\n margin-block: 0;\\\\n}\\\\n\\\\na {\\\\n color: rgb(0 0 100% / 90%);\\\\n\\\\n&:hover {\\\\n color: rebeccapurple;\\\\n }\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`postcss-loader\`): result 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("postcss-loader"): result 1`] = ` Array [ Array [ "../../src/index.js?[ident]!./source-map/nested/nested.postcss.css", @@ -683,7 +491,7 @@ Array [ "mappings": "AAAA;EACE,WAAW;AACb", "names": Array [], "sources": Array [ - "webpack:///source-map/nested/nested.postcss.css", + "webpack://source-map/nested/nested.postcss.css", ], "sourcesContent": Array [ ".nested { @@ -743,7 +551,7 @@ a:hover { "mappings": "AAKA;EACE,gBAAgB;EAChB,mCAAsB;EACtB,yCAA4C;AAC9C;;AAEA;EACE,kBAAqB;EAArB,gBAAqB;EAArB,qBAAqB;AACvB;;AAEA;EACE;IACE,6BAAuB;IAAvB,uBAAuB;IACvB,iGAAsB;IACtB,eAA0B;IAA1B,0BAA0B;IAC1B,6BAAwC;IAAxC,wCAAwC;IACxC,qBAAyB;IACzB,kCAA+C;IAA/C,mCAA+C;IAA/C,6CAA+C;IAA/C,8CAA+C;EACjD;AACF;;AAEA;EACE,aAAe;EAAf,gBAAe;AACjB;;AAEA;EACE;AAKF;;AAHA;GACG,WAAoB;CACtB", "names": Array [], "sources": Array [ - "webpack:///source-map/basic.postcss.css", + "webpack://source-map/basic.postcss.css", ], "sourcesContent": Array [ "@import \\"./nested/nested.postcss.css\\"; @@ -791,22 +599,22 @@ a { ] `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`postcss-loader\`): warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("postcss-loader"): warnings 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`stylus-loader\`): errors 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("stylus-loader"): errors 1`] = `Array []`; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`stylus-loader\`): module 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("stylus-loader"): module 1`] = ` "// Imports import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\"body {\\\\n font: 14px/1.5 Helvetica, arial, sans-serif;\\\\n}\\\\nbody #logo {\\\\n border-radius: 5px;\\\\n}\\\\n/*# sourceMappingURL=test/fixtures/source-map/base.css.map */\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/base.styl\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,2CAAwB;AAC1B;AAAE;EACE,kBAAe;AAEnB;AACA,4DAA4D\\",\\"sourcesContent\\":[\\"body {\\\\n font: 14px/1.5 Helvetica, arial, sans-serif;\\\\n #logo {\\\\n border-radius: 5px;\\\\n }\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\"body {\\\\n font: 14px/1.5 Helvetica, arial, sans-serif;\\\\n}\\\\nbody #logo {\\\\n border-radius: 5px;\\\\n}\\\\n/*# sourceMappingURL=test/fixtures/source-map/base.css.map */\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/base.styl\\"],\\"names\\":[],\\"mappings\\":\\"AAAA;EACE,2CAAwB;AAC1B;AAAE;EACE,kBAAe;AAEnB;AACA,4DAA4D\\",\\"sourcesContent\\":[\\"body {\\\\n font: 14px/1.5 Helvetica, arial, sans-serif;\\\\n #logo {\\\\n border-radius: 5px;\\\\n }\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`stylus-loader\`): result 1`] = ` +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("stylus-loader"): result 1`] = ` Array [ Array [ "./source-map/base.styl", @@ -822,7 +630,7 @@ body #logo { "mappings": "AAAA;EACE,2CAAwB;AAC1B;AAAE;EACE,kBAAe;AAEnB;AACA,4DAA4D", "names": Array [], "sources": Array [ - "webpack:///source-map/base.styl", + "webpack://source-map/base.styl", ], "sourcesContent": Array [ "body { @@ -839,7 +647,143 @@ body #logo { ] `; -exports[`"sourceMap" option true should generate source maps when source maps is valid from an other loader (\`stylus-loader\`): warnings 1`] = `Array []`; +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps ("stylus-loader"): warnings 1`] = `Array []`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps with "sourceRoot": errors 1`] = `Array []`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps with "sourceRoot": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; +import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); +// Exports +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps with "sourceRoot": result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./source-map/nested/nested.css", + ".nested { + color: blue; +} +", + "", + Object { + "mappings": "AAAA;EACE,WAAW;AACb", + "names": Array [], + "sources": Array [ + "webpack://source-map/nested/nested.css", + ], + "sourcesContent": Array [ + ".nested { + color: blue; +} +", + ], + "version": 3, + }, + ], + Array [ + "./source-map/basic.css", + ".class { + color: red; +} +", + "", + Object { + "mappings": "AAEA;EACE,UAAU;AACZ", + "names": Array [], + "sources": Array [ + "webpack://source-map/basic.css", + ], + "sourcesContent": Array [ + "@import \\"./nested/nested.css\\"; + +.class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps with "sourceRoot": warnings 1`] = `Array []`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps without "sourceRoot": errors 1`] = `Array []`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps without "sourceRoot": module 1`] = ` +"// Imports +import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\"; +import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./nested/nested.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); +// Exports +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps without "sourceRoot": result 1`] = ` +Array [ + Array [ + "../../src/index.js?[ident]!./source-map/nested/nested.css", + ".nested { + color: blue; +} +", + "", + Object { + "mappings": "AAAA;EACE,WAAW;AACb", + "names": Array [], + "sources": Array [ + "webpack://source-map/nested/nested.css", + ], + "sourcesContent": Array [ + ".nested { + color: blue; +} +", + ], + "version": 3, + }, + ], + Array [ + "./source-map/basic.css", + ".class { + color: red; +} +", + "", + Object { + "mappings": "AAEA;EACE,UAAU;AACZ", + "names": Array [], + "sources": Array [ + "webpack://source-map/basic.css", + ], + "sourcesContent": Array [ + "@import \\"./nested/nested.css\\"; + +.class { + color: red; +} +", + ], + "version": 3, + }, + ], +] +`; + +exports[`"sourceMap" option true should generate source maps when previous loader generates source maps without "sourceRoot": warnings 1`] = `Array []`; exports[`"sourceMap" option true should generate source maps: errors 1`] = `Array []`; @@ -850,7 +794,7 @@ import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(true); ___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___); // Module -___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack:///source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); +___CSS_LOADER_EXPORT___.push([module.id, \\".class {\\\\n color: red;\\\\n}\\\\n\\", \\"\\",{\\"version\\":3,\\"sources\\":[\\"webpack://source-map/basic.css\\"],\\"names\\":[],\\"mappings\\":\\"AAEA;EACE,UAAU;AACZ\\",\\"sourcesContent\\":[\\"@import \\\\\\"./nested/nested.css\\\\\\";\\\\n\\\\n.class {\\\\n color: red;\\\\n}\\\\n\\"]}]); // Exports export default ___CSS_LOADER_EXPORT___; " @@ -869,7 +813,7 @@ Array [ "mappings": "AAAA;EACE,WAAW;AACb", "names": Array [], "sources": Array [ - "webpack:///source-map/nested/nested.css", + "webpack://source-map/nested/nested.css", ], "sourcesContent": Array [ ".nested { @@ -891,7 +835,7 @@ Array [ "mappings": "AAEA;EACE,UAAU;AACZ", "names": Array [], "sources": Array [ - "webpack:///source-map/basic.css", + "webpack://source-map/basic.css", ], "sourcesContent": Array [ "@import \\"./nested/nested.css\\"; diff --git a/test/helpers/execute.js b/test/helpers/execute.js index 866001ae..8ae07d81 100644 --- a/test/helpers/execute.js +++ b/test/helpers/execute.js @@ -14,7 +14,7 @@ export default (code) => { // eslint-disable-next-line no-underscore-dangle module._compile( - `let __export__;${code};module.exports = __export__;`, + `let __export__;${code};\nmodule.exports = __export__;`, resource ); diff --git a/test/sourceMap-option.test.js b/test/sourceMap-option.test.js index 7e486685..d4845340 100644 --- a/test/sourceMap-option.test.js +++ b/test/sourceMap-option.test.js @@ -1,6 +1,8 @@ import path from 'path'; +import webpack from 'webpack'; import postcssPresetEnv from 'postcss-preset-env'; +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; import { compile, @@ -9,6 +11,7 @@ import { getExecutedCode, getModuleSource, getWarnings, + readAsset, } from './helpers/index'; jest.setTimeout(10000); @@ -63,7 +66,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps equal to "null" from an other loader', async () => { + it('should generate source maps when previous loader does not generate source maps', async () => { const compiler = getCompiler( './source-map/basic.js', {}, @@ -104,49 +107,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps equal to "undefined" from an other loader', async () => { - const compiler = getCompiler( - './source-map/basic.js', - {}, - { - module: { - rules: [ - { - test: /\.css$/i, - use: [ - { - loader: path.resolve(__dirname, '../src'), - options: { sourceMap: true }, - }, - { - loader: path.resolve( - __dirname, - './fixtures/source-map-loader.js' - ), - options: { - // eslint-disable-next-line no-undefined - sourceMap: undefined, - }, - }, - ], - }, - ], - }, - } - ); - const stats = await compile(compiler); - - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' - ); - expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); - }); - - it('should generate source maps when source maps is valid and string from an other loader', async () => { + it('should generate source maps when previous loader generates source maps without "sourceRoot"', async () => { const absolutePath = path.resolve( __dirname, 'fixtures', @@ -203,7 +164,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps is valid and is set sourceRoot', async () => { + it('should generate source maps when previous loader generates source maps with "sourceRoot"', async () => { const absoluteSourceRoot = path.resolve( __dirname, 'fixtures', @@ -260,7 +221,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps is valid from an other loader (`postcss-loader`)', async () => { + it('should generate source maps when previous loader generates source maps ("postcss-loader")', async () => { const compiler = getCompiler( './source-map/basic-postcss.js', {}, @@ -301,7 +262,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it.skip('should generate source maps when source maps is valid from an other loader (`sass-loader`)', async () => { + it.skip('should generate source maps when previous loader generates source maps ("sass-loader")', async () => { const compiler = getCompiler( './source-map/basic-scss.js', {}, @@ -343,7 +304,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps is valid from an other loader (`less-loader`)', async () => { + it('should generate source maps when previous loader generates source maps ("less-loader")', async () => { const compiler = getCompiler( './source-map/basic-less.js', {}, @@ -383,7 +344,7 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should generate source maps when source maps is valid from an other loader (`stylus-loader`)', async () => { + it('should generate source maps when previous loader generates source maps ("stylus-loader")', async () => { const compiler = getCompiler( './source-map/basic-styl.js', {}, @@ -422,47 +383,31 @@ describe('"sourceMap" option', () => { expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); - }); - - describe('false', () => { - it('should not generate source maps', async () => { - const compiler = getCompiler('./source-map/basic.js', { - sourceMap: false, - }); - const stats = await compile(compiler); - - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' - ); - expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); - }); - it('should not generate source maps when source maps equal to "null" from an other loader', async () => { + it('should generate source maps and do not change "[contenthash]" on different platform', async () => { const compiler = getCompiler( './source-map/basic.js', {}, { + devtool: 'source-map', + // webpack@4 has bug + // It uses readableIdentifier to generate the sources, which uses the RequestShortener, + // which has some problems with paths that are 2 folders above the context + context: path.resolve(__dirname, '..'), + output: { + path: path.resolve(__dirname, './outputs'), + filename: '[name].[contenthash].bundle.js', + chunkFilename: '[name].[contenthash].chunk.js', + publicPath: '/webpack/public/path/', + }, module: { rules: [ { test: /\.css$/i, - use: [ + rules: [ { loader: path.resolve(__dirname, '../src'), - options: { sourceMap: false }, - }, - { - loader: path.resolve( - __dirname, - './fixtures/source-map-loader.js' - ), - options: { - sourceMap: null, - }, + options: { sourceMap: true }, }, ], }, @@ -471,40 +416,53 @@ describe('"sourceMap" option', () => { } ); const stats = await compile(compiler); - - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + const chunkName = Object.keys( + stats.compilation.assets + ).find((assetName) => /\.js$/.test(assetName)); + + expect(chunkName).toBe( + webpack.version[0] === '5' + ? 'main.b58b73eca7517a2128fd.bundle.js' + : 'main.1e45307f085c8aadaf4c.bundle.js' ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); + getModuleSource('fixtures/source-map/basic.css', stats) + ).toMatchSnapshot('module'); + expect(getExecutedCode(chunkName, compiler, stats)).toMatchSnapshot( + 'result' + ); expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should not generate source maps when source maps equal to "undefined" from an other loader', async () => { + it('should generate source maps when css was extracted', async () => { const compiler = getCompiler( './source-map/basic.js', {}, { + devtool: 'source-map', + output: { + path: path.resolve(__dirname, '../outputs'), + filename: '[name].bundle.js', + chunkFilename: '[name].chunk.js', + publicPath: '/webpack/public/path/', + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: '[name].css', + }), + ], module: { rules: [ { test: /\.css$/i, - use: [ + rules: [ { - loader: path.resolve(__dirname, '../src'), - options: { sourceMap: false }, + loader: MiniCssExtractPlugin.loader, }, { - loader: path.resolve( - __dirname, - './fixtures/source-map-loader.js' - ), - options: { - // eslint-disable-next-line no-undefined - sourceMap: undefined, - }, + loader: path.resolve(__dirname, '../src'), + options: { sourceMap: true }, }, ], }, @@ -514,46 +472,48 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(readAsset('main.css', compiler, stats)).toMatchSnapshot( + 'extracted css' ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); + JSON.parse(readAsset('main.css.map', compiler, stats)) + ).toMatchSnapshot('source map'); expect(getWarnings(stats)).toMatchSnapshot('warnings'); expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should not generate source maps when source maps is valid and string from an other loader', async () => { + it('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => { const compiler = getCompiler( './source-map/basic.js', {}, { + devtool: 'source-map', + // webpack@4 has bug + // It uses readableIdentifier to generate the sources, which uses the RequestShortener, + // which has some problems with paths that are 2 folders above the context + context: path.resolve(__dirname, '..'), + output: { + path: path.resolve(__dirname, '../outputs'), + filename: '[name].bundle.js', + chunkFilename: '[name].chunk.js', + publicPath: '/webpack/public/path/', + }, + plugins: [ + new MiniCssExtractPlugin({ + filename: '[name].[contenthash].css', + }), + ], module: { rules: [ { test: /\.css$/i, - use: [ + rules: [ { - loader: path.resolve(__dirname, '../src'), - options: { sourceMap: false }, + loader: MiniCssExtractPlugin.loader, }, { - loader: path.resolve( - __dirname, - './fixtures/source-map-loader.js' - ), - options: { - sourceMap: JSON.stringify({ - foo: 'bar', - version: 3, - sources: ['basic.css'], - names: [], - mappings: 'AAAA;EACE,UAAU;AACZ', - file: 'basic.css', - sourcesContent: ['.class {\n color: red;\n}\n'], - }), - }, + loader: path.resolve(__dirname, '../src'), + options: { sourceMap: true }, }, ], }, @@ -562,6 +522,48 @@ describe('"sourceMap" option', () => { } ); const stats = await compile(compiler); + const chunkName = Object.keys( + stats.compilation.assets + ).find((assetName) => /\.css$/.test(assetName)); + + const extractedCSS = readAsset(chunkName, compiler, stats); + + expect(chunkName).toBe( + // TODO still buggy on webpack@4 + webpack.version[0] === '5' ? 'main.8189c1c4f956dd69079a.css' : chunkName + ); + + expect( + extractedCSS.replace( + /=(.+?)\..+?\.css\.map/, + '=$1.xxxxxxxxxxxxxxxxxxxx.css.map' + ) + ).toMatchSnapshot('extracted css'); + + const sourceMap = JSON.parse( + readAsset(`${chunkName}.map`, compiler, stats) + ); + + sourceMap.file = sourceMap.file.replace( + /^(.+?)\..+?\.css$/, + '$1.xxxxxxxxxxxxxxxxxxxx.css' + ); + sourceMap.sources = sourceMap.sources.map((source) => + source.replace('css-loader', '') + ); + + expect(sourceMap).toMatchSnapshot('source map'); + expect(getWarnings(stats)).toMatchSnapshot('warnings'); + expect(getErrors(stats)).toMatchSnapshot('errors'); + }); + }); + + describe('false', () => { + it('should not generate source maps', async () => { + const compiler = getCompiler('./source-map/basic.js', { + sourceMap: false, + }); + const stats = await compile(compiler); expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( 'module' @@ -573,9 +575,9 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should not generate source maps when source maps is valid from an other loader (`postcss-loader`)', async () => { + it('should not generate source maps when previous loader does not generate source maps', async () => { const compiler = getCompiler( - './source-map/basic-postcss.js', + './source-map/basic.js', {}, { module: { @@ -585,14 +587,16 @@ describe('"sourceMap" option', () => { use: [ { loader: path.resolve(__dirname, '../src'), - options: { - sourceMap: false, - }, + options: { sourceMap: false }, }, { - loader: 'postcss-loader', + loader: path.resolve( + __dirname, + './fixtures/source-map-loader.js' + ), options: { - plugins: () => [postcssPresetEnv({ stage: 0 })], + // eslint-disable-next-line no-undefined + sourceMap: undefined, }, }, ], @@ -603,9 +607,9 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect( - getModuleSource('./source-map/basic.postcss.css', stats) - ).toMatchSnapshot('module'); + expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( + 'module' + ); expect( getExecutedCode('main.bundle.js', compiler, stats) ).toMatchSnapshot('result'); @@ -613,28 +617,35 @@ describe('"sourceMap" option', () => { expect(getErrors(stats)).toMatchSnapshot('errors'); }); - it('should not generate source maps when source maps is valid from an other loader (`sass-loader`)', async () => { + it('should not generate source maps when previous loader generates source maps', async () => { const compiler = getCompiler( - './source-map/basic-scss.js', + './source-map/basic.js', {}, { module: { rules: [ { - test: /\.s[ca]ss$/i, + test: /\.css$/i, use: [ { loader: path.resolve(__dirname, '../src'), - options: { - sourceMap: false, - }, + options: { sourceMap: false }, }, { - loader: 'sass-loader', + loader: path.resolve( + __dirname, + './fixtures/source-map-loader.js' + ), options: { - // eslint-disable-next-line global-require - implementation: require('sass'), - sourceMap: true, + sourceMap: JSON.stringify({ + foo: 'bar', + version: 3, + sources: ['basic.css'], + names: [], + mappings: 'AAAA;EACE,UAAU;AACZ', + file: 'basic.css', + sourcesContent: ['.class {\n color: red;\n}\n'], + }), }, }, ], @@ -645,7 +656,7 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.scss', stats)).toMatchSnapshot( + expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( 'module' ); expect(