From f862f7a8382fab11c9c2a897ab1e26d35167cd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=A3=E5=BC=BA?= Date: Mon, 19 Aug 2024 21:04:43 +0800 Subject: [PATCH] fix: generate correct sourceMaps for `modern-compiler` api (#1228) --- src/utils.js | 2 +- ...ourceMap-options.test.js.no-node-sass.snap | 1096 +++++++++++++- .../sourceMap-options.test.js.snap | 1347 ++++++++++++++++- test/sass/language-source-maps.sass | 60 + test/scss/language-source-maps.scss | 49 + test/sourceMap-options.test.js | 31 + 6 files changed, 2574 insertions(+), 11 deletions(-) create mode 100644 test/sass/language-source-maps.sass create mode 100644 test/scss/language-source-maps.scss diff --git a/src/utils.js b/src/utils.js index 9912b9a9..529652cd 100644 --- a/src/utils.js +++ b/src/utils.js @@ -691,7 +691,7 @@ function getModernWebpackImporter(loaderContext, implementation, loadPaths) { }); }); - return { contents, syntax }; + return { contents, syntax, sourceMapUrl: canonicalUrl }; } catch (err) { return null; } diff --git a/test/__snapshots__/sourceMap-options.test.js.no-node-sass.snap b/test/__snapshots__/sourceMap-options.test.js.no-node-sass.snap index fa5872c1..8d5ca7eb 100644 --- a/test/__snapshots__/sourceMap-options.test.js.no-node-sass.snap +++ b/test/__snapshots__/sourceMap-options.test.js.no-node-sass.snap @@ -634,7 +634,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:11"", +@import "sass-embedded-legacy-load-done:13"", ], "version": 3, } @@ -1639,7 +1639,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:10"", +@import "sass-embedded-legacy-load-done:12"", ], "version": 3, } @@ -2643,7 +2643,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:9"", +@import "sass-embedded-legacy-load-done:11"", ], "version": 3, } @@ -3647,7 +3647,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:8"", +@import "sass-embedded-legacy-load-done:10"", ], "version": 3, } @@ -4020,6 +4020,1092 @@ exports[`sourceMap option should generate source maps when value is not specifie exports[`sourceMap option should generate source maps when value is not specified and the "devtool" option has "source-map" value ('sass-embedded', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "sourcesContent": [ + "@import "another/variables" +@import "./file.css" +@import "module" + +$font-stack: Helvetica, sans-serif +$primary-color: #333 +$pi: '\\e0C6' + +body + font: 100% $font-stack + color: $primary-color + +nav + ul + margin: 0 + padding: 0 + list-style: none + + li + display: inline-block + + a + display: block + padding: 6px 12px + text-decoration: none + +=border-radius($radius) + -webkit-border-radius: $radius + -moz-border-radius: $radius + -ms-border-radius: $radius + border-radius: $radius + +.box + +border-radius(10px) + +.message + border: 1px solid #ccc + padding: 10px + color: #333 + +.success + @extend .message + border-color: green + +.error + @extend .message + border-color: red + +.warning + @extend .message + border-color: yellow + +.foo + &:before + content: $pi + +.bar + &:before + content: $n-ary-summation + +", + ".module { + background: hotpink; +} +", + "$n-ary-summation: '\\2211' +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} +", + ".module { + background: hotpink; +} +", + "$n-ary-summation: '\\2211' +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "sourcesContent": [ + "@import "another/variables" +@import "./file.css" +@import "module" + +$font-stack: Helvetica, sans-serif +$primary-color: #333 +$pi: '\\e0C6' + +body + font: 100% $font-stack + color: $primary-color + +nav + ul + margin: 0 + padding: 0 + list-style: none + + li + display: inline-block + + a + display: block + padding: 6px 12px + text-decoration: none + +=border-radius($radius) + -webkit-border-radius: $radius + -moz-border-radius: $radius + -ms-border-radius: $radius + border-radius: $radius + +.box + +border-radius(10px) + +.message + border: 1px solid #ccc + padding: 10px + color: #333 + +.success + @extend .message + border-color: green + +.error + @extend .message + border-color: red + +.warning + @extend .message + border-color: yellow + +.foo + &:before + content: $pi + +.bar + &:before + content: $n-ary-summation + +", + ".module { + background: hotpink; +} + +;@import "sass-embedded-legacy-load-done:19";", + "$n-ary-summation: '\\2211' + +@import "sass-embedded-legacy-load-done:18"", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} +", + ".module { + background: hotpink; +} + +;@import "sass-embedded-legacy-load-done:9";", + "$n-ary-summation: '\\2211' + +;@import "sass-embedded-legacy-load-done:8";", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; + exports[`sourceMap option should generate sourcemap with "asset/resource" ('dart-sass', 'legacy' API, 'sass' syntax): css 1`] = ` "@charset "UTF-8"; @import "./file.css"; @@ -4665,7 +5751,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:15"", +@import "sass-embedded-legacy-load-done:17"", ], "version": 3, } diff --git a/test/__snapshots__/sourceMap-options.test.js.snap b/test/__snapshots__/sourceMap-options.test.js.snap index 8259d51e..27d4a736 100644 --- a/test/__snapshots__/sourceMap-options.test.js.snap +++ b/test/__snapshots__/sourceMap-options.test.js.snap @@ -869,7 +869,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:11"", +@import "sass-embedded-legacy-load-done:13"", ], "version": 3, } @@ -2107,7 +2107,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:10"", +@import "sass-embedded-legacy-load-done:12"", ], "version": 3, } @@ -3344,7 +3344,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:9"", +@import "sass-embedded-legacy-load-done:11"", ], "version": 3, } @@ -4581,7 +4581,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:8"", +@import "sass-embedded-legacy-load-done:10"", ], "version": 3, } @@ -4954,6 +4954,1343 @@ exports[`sourceMap option should generate source maps when value is not specifie exports[`sourceMap option should generate source maps when value is not specified and the "devtool" option has "source-map" value ('sass-embedded', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "sourcesContent": [ + "@import "another/variables" +@import "./file.css" +@import "module" + +$font-stack: Helvetica, sans-serif +$primary-color: #333 +$pi: '\\e0C6' + +body + font: 100% $font-stack + color: $primary-color + +nav + ul + margin: 0 + padding: 0 + list-style: none + + li + display: inline-block + + a + display: block + padding: 6px 12px + text-decoration: none + +=border-radius($radius) + -webkit-border-radius: $radius + -moz-border-radius: $radius + -ms-border-radius: $radius + border-radius: $radius + +.box + +border-radius(10px) + +.message + border: 1px solid #ccc + padding: 10px + color: #333 + +.success + @extend .message + border-color: green + +.error + @extend .message + border-color: red + +.warning + @extend .message + border-color: yellow + +.foo + &:before + content: $pi + +.bar + &:before + content: $n-ary-summation + +", + ".module { + background: hotpink; +} +", + "$n-ary-summation: '\\2211' +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} +", + ".module { + background: hotpink; +} +", + "$n-ary-summation: '\\2211' +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'legacy' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('dart-sass', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import url(./file.css); +.module { + background: hotpink; } + +body { + font: 100% Helvetica, sans-serif; + color: #333; } + +nav ul { + margin: 0; + padding: 0; + list-style: none; } + +nav li { + display: inline-block; } + +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; } + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; } + +.message, .success, .error, .warning { + border: 1px solid #ccc; + padding: 10px; + color: #333; } + +.success { + border-color: green; } + +.error { + border-color: red; } + +.warning { + border-color: yellow; } + +.foo:before { + content: ""; } + +.bar:before { + content: "∑"; } +" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACA,OAAO,CAAP,eAAO;AEDP,AAAA,OAAO,CAAC;EACJ,UAAU,EAAE,OAAO,GACtB;;AFMD,AAAA,IAAI,CAAC;EACH,IAAI,EAAE,IAAI,CALI,SAAS,EAAE,UAAU;EAMnC,KAAK,EALS,IAAI,GAKM;;AAE1B,AACE,GADC,CACD,EAAE,CAAC;EACD,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,IAAI,GAAG;;AAJvB,AAME,GANC,CAMD,EAAE,CAAC;EACD,OAAO,EAAE,YAAY,GAAG;;AAP5B,AASE,GATC,CASD,CAAC,CAAC;EACA,OAAO,EAAE,KAAK;EACd,OAAO,EAAE,QAAQ;EACjB,eAAe,EAAE,IAAI,GAAG;;AAQ5B,AAAA,IAAI,CAAC;EALH,qBAAqB,EAME,IAAI;EAL3B,kBAAkB,EAKK,IAAI;EAJ3B,iBAAiB,EAIM,IAAI;EAH3B,aAAa,EAGU,IAAI,GAAI;;AAEjC,AAAA,QAAQ,EAKR,QAAQ,EAIR,MAAM,EAIN,QAAQ,CAbC;EACP,MAAM,EAAE,cAAc;EACtB,OAAO,EAAE,IAAI;EACb,KAAK,EAAE,IAAI,GAAG;;AAEhB,AAAA,QAAQ,CAAC;EAEP,YAAY,EAAE,KAAK,GAAG;;AAExB,AAAA,MAAM,CAAC;EAEL,YAAY,EAAE,GAAG,GAAG;;AAEtB,AAAA,QAAQ,CAAC;EAEP,YAAY,EAAE,MAAM,GAAG;;AAEzB,AACE,IADE,AACD,OAAO,CAAC;EACP,OAAO,EAhDK,IAAO,GAgDJ;;AAEnB,AACE,IADE,AACD,OAAO,CAAC;EACP,OAAO,EC1DO,IAAO,GD0DO", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/sass/another/variables.sass", + "test/node_modules/module/module.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import "module"; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; } + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; } + + li { + display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; } } + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; } + +.box { + @include border-radius(10px); } + +.message { + border: 1px solid #ccc; + padding: 10px; + color: #333; } + +.success { + @extend .message; + border-color: green; } + +.error { + @extend .message; + border-color: red; } + +.warning { + @extend .message; + border-color: yellow; } + +.foo { + &:before { + content: $pi; } } + +.bar { + &:before { + content: $n-ary-summation; } } + +", + "$n-ary-summation: '\\2211'; +", + ".module { + background: hotpink; +} +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import url(./file.css); +.module { + background: hotpink; } + +body { + font: 100% Helvetica, sans-serif; + color: #333; } + +nav ul { + margin: 0; + padding: 0; + list-style: none; } + +nav li { + display: inline-block; } + +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; } + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; } + +.foo:before { + content: ""; } + +.bar:before { + content: "∑"; } +" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACA,OAAO,CAAP,eAAO;AEDP,AAAA,OAAO,CAAC;EACJ,UAAU,EAAE,OAAO,GACtB;;AFMD,AAAA,IAAI,CAAC;EACH,IAAI,EAAE,IAAI,CALI,SAAS,EAAE,UAAU;EAMnC,KAAK,EALS,IAAI,GAMnB;;AAED,AACE,GADC,CACD,EAAE,CAAC;EACD,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,IAAI,GACjB;;AALH,AAOE,GAPC,CAOD,EAAE,CAAC;EAAE,OAAO,EAAE,YAAY,GAAI;;AAPhC,AASE,GATC,CASD,CAAC,CAAC;EACA,OAAO,EAAE,KAAK;EACd,OAAO,EAAE,QAAQ;EACjB,eAAe,EAAE,IAAI,GACtB;;AAUH,AAAA,IAAI,CAAC;EANH,qBAAqB,EAMO,IAAI;EAL7B,kBAAkB,EAKO,IAAI;EAJ5B,iBAAiB,EAIO,IAAI;EAHxB,aAAa,EAGO,IAAI,GAAK;;AAEvC,AACE,IADE,AACD,OAAO,CAAC;EACP,OAAO,EAlCK,IAAO,GAmCpB;;AAGH,AACE,IADE,AACD,OAAO,CAAC;EACP,OAAO,EC9CO,IAAO,GD+CtB", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/scss/another/_variables.scss", + "test/node_modules/module/module.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} +", + "$n-ary-summation: '\\2211' +", + ".module { + background: hotpink; +} +", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('node-sass', 'legacy' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "sourcesContent": [ + "@import "another/variables" +@import "./file.css" +@import "module" + +$font-stack: Helvetica, sans-serif +$primary-color: #333 +$pi: '\\e0C6' + +body + font: 100% $font-stack + color: $primary-color + +nav + ul + margin: 0 + padding: 0 + list-style: none + + li + display: inline-block + + a + display: block + padding: 6px 12px + text-decoration: none + +=border-radius($radius) + -webkit-border-radius: $radius + -moz-border-radius: $radius + -ms-border-radius: $radius + border-radius: $radius + +.box + +border-radius(10px) + +.message + border: 1px solid #ccc + padding: 10px + color: #333 + +.success + @extend .message + border-color: green + +.error + @extend .message + border-color: red + +.warning + @extend .message + border-color: yellow + +.foo + &:before + content: $pi + +.bar + &:before + content: $n-ary-summation + +", + ".module { + background: hotpink; +} + +;@import "sass-embedded-legacy-load-done:19";", + "$n-ary-summation: '\\2211' + +@import "sass-embedded-legacy-load-done:18"", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "sourcesContent": [ + "@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} +", + ".module { + background: hotpink; +} + +;@import "sass-embedded-legacy-load-done:9";", + "$n-ary-summation: '\\2211' + +;@import "sass-embedded-legacy-load-done:8";", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'legacy' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern' API, 'scss' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.message, .warning, .error, .success { + border: 1px solid #ccc; + padding: 10px; + color: #333; +} + +.success { + border-color: green; +} + +.error { + border-color: red; +} + +.warning { + border-color: yellow; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AAQd;EACE;EACA;EACA;;AAEF;EACE;;AAEF;EACE;EACA;EACA;;;AAQJ;EALE,uBAMe;EALf,oBAKe;EAJf,mBAIe;EAHf,eAGe;;;AAEjB;EACE;EACA;EACA;;;AAEF;EAEE;;;AAEF;EAEE;;;AAEF;EAEE;;;AAGA;EACE,SAhDY;;;AAmDd;EACE,SE1Dc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/sass/language-source-maps.sass", + "test/node_modules/module/module.scss", + "test/sass/another/variables.sass", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'sass' syntax): warnings 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): css 1`] = ` +"@charset "UTF-8"; +@import "./file.css"; +.module { + background: hotpink; +} + +body { + font: 100% Helvetica, sans-serif; + color: #333; +} + +nav ul { + margin: 0; + padding: 0; + list-style: none; +} +nav li { + display: inline-block; +} +nav a { + display: block; + padding: 6px 12px; + text-decoration: none; +} + +.box { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + border-radius: 10px; +} + +.foo:before { + content: "\\e0c6"; +} + +.bar:before { + content: "∑"; +}" +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): errors 1`] = `[]`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): source map 1`] = ` +{ + "mappings": ";AACQ;ACDR;EACI;;;ADOJ;EACE;EACA,OALc;;;AASd;EACE;EACA;EACA;;AAGF;EAAK;;AAEL;EACE;EACA;EACA;;;AAWJ;EANE,uBAM4B;EALzB,oBAKyB;EAJxB,mBAIwB;EAHpB,eAGoB;;;AAG5B;EACE,SAlCY;;;AAuCd;EACE,SE9Cc", + "names": [], + "sourceRoot": "", + "sources": [ + "test/scss/language-source-maps.scss", + "test/node_modules/module/module.scss", + "test/scss/another/_variables.scss", + ], + "version": 3, +} +`; + +exports[`sourceMap option should generate source maps with absolute URLs ('sass-embedded', 'modern-compiler' API, 'scss' syntax): warnings 1`] = `[]`; + exports[`sourceMap option should generate sourcemap with "asset/resource" ('dart-sass', 'legacy' API, 'sass' syntax): css 1`] = ` "@charset "UTF-8"; @import "./file.css"; @@ -5836,7 +7173,7 @@ nav ", "$n-ary-summation: '\\2211' -@import "sass-embedded-legacy-load-done:15"", +@import "sass-embedded-legacy-load-done:17"", ], "version": 3, } diff --git a/test/sass/language-source-maps.sass b/test/sass/language-source-maps.sass new file mode 100644 index 00000000..0175ea5d --- /dev/null +++ b/test/sass/language-source-maps.sass @@ -0,0 +1,60 @@ +@import "another/variables" +@import "./file.css" +@import "module" + +$font-stack: Helvetica, sans-serif +$primary-color: #333 +$pi: '\e0C6' + +body + font: 100% $font-stack + color: $primary-color + +nav + ul + margin: 0 + padding: 0 + list-style: none + + li + display: inline-block + + a + display: block + padding: 6px 12px + text-decoration: none + +=border-radius($radius) + -webkit-border-radius: $radius + -moz-border-radius: $radius + -ms-border-radius: $radius + border-radius: $radius + +.box + +border-radius(10px) + +.message + border: 1px solid #ccc + padding: 10px + color: #333 + +.success + @extend .message + border-color: green + +.error + @extend .message + border-color: red + +.warning + @extend .message + border-color: yellow + +.foo + &:before + content: $pi + +.bar + &:before + content: $n-ary-summation + diff --git a/test/scss/language-source-maps.scss b/test/scss/language-source-maps.scss new file mode 100644 index 00000000..96eedb99 --- /dev/null +++ b/test/scss/language-source-maps.scss @@ -0,0 +1,49 @@ +@import "another/variables"; +@import "./file.css"; +@import 'module'; + +$font-stack: Helvetica, sans-serif; +$primary-color: #333; +$pi: '\e0C6'; + +body { + font: 100% $font-stack; + color: $primary-color; +} + +nav { + ul { + margin: 0; + padding: 0; + list-style: none; + } + + li { display: inline-block; } + + a { + display: block; + padding: 6px 12px; + text-decoration: none; + } +} + +@mixin border-radius($radius) { + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + -ms-border-radius: $radius; + border-radius: $radius; +} + +.box { @include border-radius(10px); } + +.foo { + &:before { + content: $pi; + } +} + +.bar { + &:before { + content: $n-ary-summation; + } +} diff --git a/test/sourceMap-options.test.js b/test/sourceMap-options.test.js index 6baeba24..09837491 100644 --- a/test/sourceMap-options.test.js +++ b/test/sourceMap-options.test.js @@ -295,6 +295,37 @@ describe("sourceMap option", () => { await close(compiler); }); + + it(`should generate source maps with absolute URLs ('${implementationName}', '${api}' API, '${syntax}' syntax)`, async () => { + const testId = getTestId("language-source-maps", syntax); + const options = { implementation, api }; + const compiler = getCompiler(testId, { + devtool: "source-map", + loader: { options }, + }); + const stats = await compile(compiler); + const { css, sourceMap } = getCodeFromBundle(stats, compiler); + + sourceMap.sourceRoot = ""; + sourceMap.sources = sourceMap.sources.map((source) => { + expect(path.isAbsolute(source)).toBe(true); + expect(source).toBe(path.normalize(source)); + expect( + fs.existsSync(path.resolve(sourceMap.sourceRoot, source)), + ).toBe(true); + + return path + .relative(path.resolve(__dirname, ".."), source) + .replace(/\\/g, "/"); + }); + + expect(css).toMatchSnapshot("css"); + expect(sourceMap).toMatchSnapshot("source map"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + + await close(compiler); + }); }); }); });