",
+Code:
+ color: red
+",
]
`;
-exports[`loader should register dependencies using the "messages" API: errors 1`] = `Array []`;
+exports[`loader should register dependencies using the "messages" API: errors 1`] = `[]`;
-exports[`loader should register dependencies using the "messages" API: warnings 1`] = `Array []`;
+exports[`loader should register dependencies using the "messages" API: warnings 1`] = `[]`;
exports[`loader should reuse PostCSS AST: css 1`] = `
"a {
@@ -217,13 +231,14 @@ a {
"
`;
-exports[`loader should reuse PostCSS AST: errors 1`] = `Array []`;
+exports[`loader should reuse PostCSS AST: errors 1`] = `[]`;
-exports[`loader should reuse PostCSS AST: warnings 1`] = `Array []`;
+exports[`loader should reuse PostCSS AST: warnings 1`] = `[]`;
exports[`loader should throw an error on invalid syntax: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
+
SyntaxError
(1:3) /test/fixtures/css/style.css Unnecessary curly bracket
@@ -236,7 +251,7 @@ SyntaxError
]
`;
-exports[`loader should throw an error on invalid syntax: warnings 1`] = `Array []`;
+exports[`loader should throw an error on invalid syntax: warnings 1`] = `[]`;
exports[`loader should work with SugarSS: css 1`] = `
"a {
@@ -245,9 +260,9 @@ exports[`loader should work with SugarSS: css 1`] = `
"
`;
-exports[`loader should work with SugarSS: errors 1`] = `Array []`;
+exports[`loader should work with SugarSS: errors 1`] = `[]`;
-exports[`loader should work with SugarSS: warnings 1`] = `Array []`;
+exports[`loader should work with SugarSS: warnings 1`] = `[]`;
exports[`loader should work: css 1`] = `
"a {
@@ -296,6 +311,6 @@ a {
"
`;
-exports[`loader should work: errors 1`] = `Array []`;
+exports[`loader should work: errors 1`] = `[]`;
-exports[`loader should work: warnings 1`] = `Array []`;
+exports[`loader should work: warnings 1`] = `[]`;
diff --git a/test/__snapshots__/postcssOptions.test.js.snap b/test/__snapshots__/postcssOptions.test.js.snap
index a08d376e..15d0c976 100644
--- a/test/__snapshots__/postcssOptions.test.js.snap
+++ b/test/__snapshots__/postcssOptions.test.js.snap
@@ -1,64 +1,64 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`"postcssOptions" option should throw an error with "syntax" option on the unresolved syntax: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: Cannot read properties of undefined (reading 'parse')",
"ModuleError: Module Error (from \`replaced original path\`):
-Loading PostCSS \\"unresolved\\" syntax failed: Cannot find module 'unresolved' from 'src/utils.js'",
+Loading PostCSS "unresolved" syntax failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
-exports[`"postcssOptions" option should throw an error with "syntax" option on the unresolved syntax: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with "syntax" option on the unresolved syntax: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Error: invalid postcss config",
]
`;
-exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with the "config" option on the invalid config: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
Error: No PostCSS config found in: /test/fixtures/config-scope/css/unresolve.js",
]
`;
-exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with the "config" option on the unresolved config: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: parser is not a function",
"ModuleError: Module Error (from \`replaced original path\`):
-Loading PostCSS \\"unresolved\\" parser failed: Cannot find module 'unresolved' from 'src/utils.js'",
+Loading PostCSS "unresolved" parser failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
-exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with the "parser" option on the unresolved parser: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: errors 1`] = `
-Array [
+[
"ModuleError: Module Error (from \`replaced original path\`):
-Loading PostCSS \\"postcss-unresolved\\" plugin failed: Cannot find module 'postcss-unresolved' from 'src/utils.js'",
+Loading PostCSS "postcss-unresolved" plugin failed: Cannot find module 'postcss-unresolved' from 'src/utils.js'",
]
`;
-exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with the "plugins" option on the unresolved plugin: warnings 1`] = `[]`;
exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: errors 1`] = `
-Array [
+[
"ModuleBuildError: Module build failed (from \`replaced original path\`):
TypeError: this.stringify is not a function",
"ModuleError: Module Error (from \`replaced original path\`):
-Loading PostCSS \\"unresolved\\" stringifier failed: Cannot find module 'unresolved' from 'src/utils.js'",
+Loading PostCSS "unresolved" stringifier failed: Cannot find module 'unresolved' from 'src/utils.js'",
]
`;
-exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should throw an error with the "stringifier" option on the unresolved stringifier: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: css 1`] = `
"a {
@@ -107,9 +107,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value and with "Array" syntax of the "plugins" option: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: css 1`] = `
"a {
@@ -158,9 +158,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value and with "Object" syntax of the "plugins" option: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work "Function" value: css 1`] = `
"a {
@@ -209,9 +209,23 @@ a {
"
`;
-exports[`"postcssOptions" option should work "Function" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work "Function" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work "Function" value: warnings 1`] = `[]`;
+
+exports[`"postcssOptions" option should work and don't modify postcss options: css 1`] = `
+"a { color: black }
+
+.foo {
+ float: right;
+}
+
+/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZyb20uY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLElBQUksYUFBYTs7QUFFakI7RUFDRSxZQUFZO0FBQ2QiLCJmaWxlIjoidG8uY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7IGNvbG9yOiBibGFjayB9XG5cbi5mb28ge1xuICBmbG9hdDogcmlnaHQ7XG59XG4iXX0= */"
+`;
+
+exports[`"postcssOptions" option should work and don't modify postcss options: errors 1`] = `[]`;
+
+exports[`"postcssOptions" option should work and don't modify postcss options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work and provide API for the configuration: css 1`] = `
"a {
@@ -262,9 +276,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work and provide API for the configuration: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work and provide API for the configuration: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work and provide API for the configuration: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work and provide API for the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): css 1`] = `
"a {
@@ -313,11 +327,11 @@ a {
"
`;
-exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): map 1`] = `undefined`;
-exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with "from", "to" and "map" options (absolute paths): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): css 1`] = `
"a {
@@ -366,11 +380,11 @@ a {
"
`;
-exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): errors 1`] = `[]`;
exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): map 1`] = `undefined`;
-exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with "from", "to" and "map" options (relative paths): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
@@ -381,9 +395,9 @@ exports[`"postcssOptions" option should work with the "config" options "String"
"
`;
-exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options "String" value (relative path): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: css 1`] = `
"a { color: black }
@@ -394,18 +408,18 @@ exports[`"postcssOptions" option should work with the "config" options and resol
"
`;
-exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: source map 1`] = `
-Object {
+{
"file": "style.css",
"mappings": "AAAA,IAAI,aAAa;;AAEjB;EACE,YAAY;AACd",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"style.css",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a { color: black }
.foo {
@@ -417,7 +431,7 @@ Object {
}
`;
-exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options and use plugins: css 1`] = `
"a { color: black }
@@ -434,26 +448,26 @@ exports[`"postcssOptions" option should work with the "config" options and use p
}
@media (prefers-color-scheme: dark) {
- :root:not(.is-light) { /* :root is for HTML documents */
+ :root:where(:not(.is-light)) { /* :root is for HTML documents */
--text-color: white
}
- html:not(.is-light) body {
+ :where(html:not(.is-light)) body {
background: black
}
}
-:root.is-dark { /* :root is for HTML documents */
+:root:where(.is-dark) { /* :root is for HTML documents */
--text-color: white
}
-html.is-dark body {
+:where(html.is-dark) body {
background: black
}"
`;
-exports[`"postcssOptions" option should work with the "config" options and use plugins: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options and use plugins: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options and use plugins: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options and use plugins: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
@@ -464,9 +478,9 @@ exports[`"postcssOptions" option should work with the "config" options with "Str
"
`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value (absolute path): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
@@ -477,9 +491,9 @@ exports[`"postcssOptions" option should work with the "config" options with "Str
"
`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value (with path to the directory with the configuration): warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: css 1`] = `
"a {
@@ -489,9 +503,9 @@ exports[`"postcssOptions" option should work with the "config" options with "Str
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLnNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFO0FBREYiLCJmaWxlIjoic3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYVxuICBjb2xvcjogYmxhY2tcbiJdfQ== */"
`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "String" value and respect all options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "false" value: css 1`] = `
"a { color: black }
@@ -502,9 +516,9 @@ exports[`"postcssOptions" option should work with the "config" options with "fal
"
`;
-exports[`"postcssOptions" option should work with the "config" options with "false" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "false" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "false" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "false" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: css 1`] = `
".import {
@@ -517,9 +531,9 @@ exports[`"postcssOptions" option should work with the "config" options with "pac
"
`;
-exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "package.json" configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "config" options with "true" value: css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
@@ -530,9 +544,9 @@ exports[`"postcssOptions" option should work with the "config" options with "tru
"
`;
-exports[`"postcssOptions" option should work with the "config" options with "true" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "true" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "config" options with "true" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "config" options with "true" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: css 1`] = `
"a {
@@ -582,11 +596,11 @@ a {
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
-exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: errors 1`] = `[]`;
exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: map 1`] = `undefined`;
-exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "map" option and generate inlined source maps: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Function" value: css 1`] = `
"a {
@@ -595,9 +609,9 @@ exports[`"postcssOptions" option should work with the "parser" option with "Func
"
`;
-exports[`"postcssOptions" option should work with the "parser" option with "Function" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "Function" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "parser" option with "Function" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "Function" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "Object" value: css 1`] = `
"a {
@@ -606,9 +620,9 @@ exports[`"postcssOptions" option should work with the "parser" option with "Obje
"
`;
-exports[`"postcssOptions" option should work with the "parser" option with "Object" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "Object" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "parser" option with "Object" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "parser" option with "String" value: css 1`] = `
"a {
@@ -617,13 +631,13 @@ exports[`"postcssOptions" option should work with the "parser" option with "Stri
"
`;
-exports[`"postcssOptions" option should work with the "parser" option with "String" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "String" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "parser" option with "String" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "parser" option with "String" value: warnings 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and not throw an error on falsy plugin: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: css 1`] = `
"a {
@@ -674,9 +688,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: css 1`] = `
"a {
@@ -725,9 +739,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value and support disabling plugins from the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: css 1`] = `
"a {
@@ -778,9 +792,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value, and config, and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: css 1`] = `
"a {
@@ -832,9 +846,9 @@ body.is_dark .phone_title {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Array" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: css 1`] = `
"a {
@@ -883,9 +897,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and only disabled plugins: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: css 1`] = `
"a {
@@ -936,9 +950,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: css 1`] = `
"a {
@@ -987,9 +1001,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value and support disabling plugins from the configuration: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: css 1`] = `
"a {
@@ -1040,9 +1054,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value, and config, and override the previous plugin options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: css 1`] = `
"a {
@@ -1094,9 +1108,9 @@ body.is_dark .phone_title {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: css 1`] = `
"a {
@@ -1145,9 +1159,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with empty "Array" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: css 1`] = `
"a {
@@ -1196,9 +1210,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with empty "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: css 1`] = `
"a {
@@ -1247,9 +1261,9 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with the "default" property with options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: css 1`] = `
"a {
@@ -1298,60 +1312,60 @@ a {
"
`;
-exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "plugins" option with the "default" property without options: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: css 1`] = `
-"a {
- color: black;
-}
-
-a {
- color: red;
-}
-
-a {
- color: green;
-}
-
-a {
- color: blue;
-}
-
-.class {
- -x-border-color: blue blue *;
- -x-color: * #fafafa;
-}
-
-.class-foo {
- -z-border-color: blue blue *;
- -z-color: * #fafafa;
-}
-
-.phone {
- _title {
- width: 500px;
-
- @media (max-width: 500px) {
- width: auto;
- }
-
- body.is_dark {
- color: white;
- }
- }
-
- img {
- display: block;
- }
-}
+"a {
+ color: black;
+}
+
+a {
+ color: red;
+}
+
+a {
+ color: green;
+}
+
+a {
+ color: blue;
+}
+
+.class {
+ -x-border-color: blue blue *;
+ -x-color: * #fafafa;
+}
+
+.class-foo {
+ -z-border-color: blue blue *;
+ -z-color: * #fafafa;
+}
+
+.phone {
+ _title {
+ width: 500px;
+
+ @media (max-width: 500px) {
+ width: auto;
+ }
+
+ body.is_dark {
+ color: white;
+ }
+ }
+
+ img {
+ display: block;
+ }
+}
"
`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "Function" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: css 1`] = `
"a
@@ -1389,9 +1403,9 @@ a
"
`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: css 1`] = `
"a
@@ -1429,9 +1443,9 @@ a
"
`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "stringifier" option with "String" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: css 1`] = `
"a
@@ -1439,9 +1453,9 @@ exports[`"postcssOptions" option should work with the "syntax" option with "Obje
"
`;
-exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "syntax" option with "Object" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work with the "syntax" option with "String" value: css 1`] = `
"a
@@ -1449,9 +1463,9 @@ exports[`"postcssOptions" option should work with the "syntax" option with "Stri
"
`;
-exports[`"postcssOptions" option should work with the "syntax" option with "String" value: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "syntax" option with "String" value: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work with the "syntax" option with "String" value: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work with the "syntax" option with "String" value: warnings 1`] = `[]`;
exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: css 1`] = `
"a { color: rgba(0, 0, 0, 1.0) }
@@ -1462,6 +1476,6 @@ exports[`"postcssOptions" option should work without the specified values in the
"
`;
-exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: errors 1`] = `Array []`;
+exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: errors 1`] = `[]`;
-exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: warnings 1`] = `Array []`;
+exports[`"postcssOptions" option should work without the specified values in the "postcssOptions" option: warnings 1`] = `[]`;
diff --git a/test/__snapshots__/sourceMap.test.js.snap b/test/__snapshots__/sourceMap.test.js.snap
index 48303c8f..3e3393d0 100644
--- a/test/__snapshots__/sourceMap.test.js.snap
+++ b/test/__snapshots__/sourceMap.test.js.snap
@@ -1,4 +1,4 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": css 1`] = `
"a {
@@ -48,9 +48,9 @@ a {
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
-exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": errors 1`] = `[]`;
-exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate inline source maps when the "devtool" is "false": warnings 1`] = `[]`;
exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": css 1`] = `
"a {
@@ -100,9 +100,9 @@ a {
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsImZpbGUiOiJzdHlsZS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyJhIHtcbiAgY29sb3I6IGJsYWNrO1xufVxuXG5hIHtcbiAgY29sb3I6IHJlZDtcbn1cblxuYSB7XG4gIGNvbG9yOiBncmVlbjtcbn1cblxuYSB7XG4gIGNvbG9yOiBibHVlO1xufVxuXG4uY2xhc3Mge1xuICAteC1ib3JkZXItY29sb3I6IGJsdWUgYmx1ZSAqO1xuICAteC1jb2xvcjogKiAjZmFmYWZhO1xufVxuXG4uY2xhc3MtZm9vIHtcbiAgLXotYm9yZGVyLWNvbG9yOiBibHVlIGJsdWUgKjtcbiAgLXotY29sb3I6ICogI2ZhZmFmYTtcbn1cblxuLnBob25lIHtcbiAgJl90aXRsZSB7XG4gICAgd2lkdGg6IDUwMHB4O1xuXG4gICAgQG1lZGlhIChtYXgtd2lkdGg6IDUwMHB4KSB7XG4gICAgICB3aWR0aDogYXV0bztcbiAgICB9XG5cbiAgICBib2R5LmlzX2RhcmsgJiB7XG4gICAgICBjb2xvcjogd2hpdGU7XG4gICAgfVxuICB9XG5cbiAgaW1nIHtcbiAgICBkaXNwbGF5OiBibG9jaztcbiAgfVxufVxuIl19 */"
`;
-exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": errors 1`] = `[]`;
-exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate inline source maps when the "devtool" is "true": warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
@@ -111,9 +111,16 @@ exports[`"sourceMap" option should generate source maps using the "postcssOption
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7RUFBSSIsImZpbGUiOiJzdHlsZS5zY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7XG4gIGNvbG9yOiBjb3JhbDtcbn0iXX0= */"
`;
-exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
-exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with "true" value and previous loader returns source maps ("sass-loader"): warnings 1`] = `
+[
+ "ModuleWarning: Module Warning (from \`replaced original path\`):
+Deprecation The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
+
+More info: https://sass-lang.com/d/legacy-js-api",
+]
+`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
@@ -122,18 +129,18 @@ exports[`"sourceMap" option should generate source maps using the "postcssOption
/*# sourceMappingURL=style.scss.map */"
`;
-exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): source map 1`] = `
-Object {
+{
"file": "style.scss",
"mappings": "AAAA;EAAI",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"style.scss",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: coral;
}",
@@ -142,7 +149,14 @@ Object {
}
`;
-exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps using the "postcssOptions.map" option with values and previous loader returns source maps ("sass-loader"): warnings 1`] = `
+[
+ "ModuleWarning: Module Warning (from \`replaced original path\`):
+Deprecation The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
+
+More info: https://sass-lang.com/d/legacy-js-api",
+]
+`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): css 1`] = `
"a {
@@ -151,17 +165,17 @@ exports[`"sourceMap" option should generate source maps when previous loader ret
"
`;
-exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): source map 1`] = `
-Object {
+{
"mappings": "AAAA;EAAI,YAAA",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"less/style.less",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: coral;
}
@@ -171,7 +185,7 @@ Object {
}
`;
-exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("less-loader"): warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): css 1`] = `
"a {
@@ -179,17 +193,17 @@ exports[`"sourceMap" option should generate source maps when previous loader ret
}"
`;
-exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): source map 1`] = `
-Object {
+{
"mappings": "AAAA;EAAI",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"scss/style.scss",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: coral;
}",
@@ -198,7 +212,14 @@ Object {
}
`;
-exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when previous loader returns source maps ("sass-loader"): warnings 1`] = `
+[
+ "ModuleWarning: Module Warning (from \`replaced original path\`):
+Deprecation The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0.
+
+More info: https://sass-lang.com/d/legacy-js-api",
+]
+`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: css 1`] = `
"a {
@@ -247,17 +268,17 @@ a {
"
`;
-exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: source map 1`] = `
-Object {
+{
"mappings": "AAAA",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"css/style.css",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: black;
}
@@ -307,7 +328,7 @@ a {
}
`;
-exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps when value is not specified and the "devtool" with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: css 1`] = `
"a {
@@ -356,18 +377,18 @@ a {
"
`;
-exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: source map 1`] = `
-Object {
+{
"file": "style.css",
"mappings": "AAAA",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"style.css",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: black;
}
@@ -417,7 +438,7 @@ a {
}
`;
-exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "false" value, but the "postcssOptions.map" has values: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: css 1`] = `
"a {
@@ -466,17 +487,17 @@ a {
"
`;
-exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: source map 1`] = `
-Object {
+{
"mappings": "AAAA",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"css/style.css",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: black;
}
@@ -526,7 +547,7 @@ a {
}
`;
-exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: css 1`] = `
"a {
@@ -575,17 +596,17 @@ a {
"
`;
-exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: errors 1`] = `[]`;
exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: source map 1`] = `
-Object {
+{
"mappings": "AAAA",
- "names": Array [],
+ "names": [],
"sourceRoot": "",
- "sources": Array [
+ "sources": [
"css/style.css",
],
- "sourcesContent": Array [
+ "sourcesContent": [
"a {
color: black;
}
@@ -635,7 +656,7 @@ a {
}
`;
-exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should generate source maps with "true" value and the "devtool" with "false" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: css 1`] = `
"a {
@@ -684,9 +705,9 @@ a {
"
`;
-exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: errors 1`] = `[]`;
-exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps when value is not specified and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: css 1`] = `
"a {
@@ -735,9 +756,9 @@ a {
"
`;
-exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: errors 1`] = `[]`;
-exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "false" value: warnings 1`] = `[]`;
exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: css 1`] = `
"a {
@@ -786,6 +807,6 @@ a {
"
`;
-exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: errors 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: errors 1`] = `[]`;
-exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: warnings 1`] = `Array []`;
+exports[`"sourceMap" option should not generate source maps with "false" value and the "devtool" option with "source-map" value: warnings 1`] = `[]`;
diff --git a/test/config-autoload.test.js b/test/config-autoload.test.js
index c4c0c6cf..504bcfcc 100644
--- a/test/config-autoload.test.js
+++ b/test/config-autoload.test.js
@@ -1,5 +1,5 @@
-import path from "path";
-import fs from "fs";
+import fs from "node:fs";
+import path from "node:path";
import { loadConfig } from "../src/utils";
@@ -15,98 +15,194 @@ describe("autoload config", () => {
it('should load ".postcssrc"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "rc")
+ path.resolve(testDirectory, "rc"),
);
- expect(loadedConfig.config.map).toEqual(false);
- expect(loadedConfig.config.from).toEqual("./test/rc/fixtures/index.css");
- expect(loadedConfig.config.to).toEqual("./test/rc/expect/index.css");
- expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe("./test/rc/fixtures/index.css");
+ expect(loadedConfig.config.to).toBe("./test/rc/expect/index.css");
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(2);
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "rc", ".postcssrc")
+ path.resolve(testDirectory, "rc", ".postcssrc"),
);
});
it('should load ".postcssrc.js"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "rc-js")
+ path.resolve(testDirectory, "rc-js"),
);
- expect(loadedConfig.config.map).toEqual(false);
- expect(loadedConfig.config.from).toEqual("./test/rc-js/fixtures/index.css");
- expect(loadedConfig.config.to).toEqual("./test/rc-js/expect/index.css");
- expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe("./test/rc-js/fixtures/index.css");
+ expect(loadedConfig.config.to).toBe("./test/rc-js/expect/index.css");
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(2);
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "rc-js", ".postcssrc.js")
+ path.resolve(testDirectory, "rc-js", ".postcssrc.js"),
);
});
it('should load "package.json"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "pkg")
+ path.resolve(testDirectory, "pkg"),
);
- expect(loadedConfig.config.parser).toEqual(false);
- expect(loadedConfig.config.syntax).toEqual(false);
- expect(loadedConfig.config.map).toEqual(false);
- expect(loadedConfig.config.from).toEqual("./index.css");
- expect(loadedConfig.config.to).toEqual("./index.css");
- expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
+ expect(loadedConfig.config.parser).toBe(false);
+ expect(loadedConfig.config.syntax).toBe(false);
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe("./index.css");
+ expect(loadedConfig.config.to).toBe("./index.css");
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(2);
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "pkg", "package.json")
+ path.resolve(testDirectory, "pkg", "package.json"),
);
});
it('should load "postcss.config.js" with "Object" syntax of plugins', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "js/object")
+ path.resolve(testDirectory, "js/object"),
);
- expect(loadedConfig.config.map).toEqual(false);
- expect(loadedConfig.config.from).toEqual(
- "./test/fixtures/config-autoload/js/object/index.css"
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/js/object/index.css",
);
- expect(loadedConfig.config.to).toEqual(
- "./test/fixtures/config-autoload/js/object/expect/index.css"
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/js/object/expect/index.css",
);
- expect(Object.keys(loadedConfig.config.plugins).length).toEqual(2);
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(2);
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "js/object", "postcss.config.js")
+ path.resolve(testDirectory, "js/object", "postcss.config.js"),
+ );
+ });
+
+ it('should load "postcss.config.cts" with "Object" syntax of plugins', async () => {
+ const loadedConfig = await loadConfig(
+ loaderContext,
+ path.resolve(testDirectory, "ts/object"),
+ );
+
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/ts/object/index.css",
+ );
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/ts/object/expect/index.css",
+ );
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(2);
+ expect(loadedConfig.filepath).toEqual(
+ path.resolve(testDirectory, "ts/object", "postcss.config.ts"),
);
});
it('should load "postcss.config.js" with "Array" syntax of plugins', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "js/array")
+ path.resolve(testDirectory, "js/array"),
+ );
+
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/js/object/index.css",
+ );
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/js/object/expect/index.css",
+ );
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(4);
+ expect(loadedConfig.filepath).toEqual(
+ path.resolve(testDirectory, "js/array", "postcss.config.js"),
+ );
+ });
+
+ it('should load ESM version of "postcss.config.js" with "Array" syntax of plugins', async () => {
+ const loadedConfig = await loadConfig(
+ loaderContext,
+ path.resolve(testDirectory, "js/array-esm-js"),
+ );
+
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/js/object/index.css",
+ );
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/js/object/expect/index.css",
+ );
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(4);
+ expect(loadedConfig.filepath).toEqual(
+ path.resolve(testDirectory, "js/array-esm-js", "postcss.config.js"),
+ );
+ });
+
+ // TODO Test manually with NODE_OPTIONS=--experimental-vm-modules to enable ESM support in jest
+ // eslint-disable-next-line jest/no-disabled-tests
+ it.skip('should load "postcss.config.mjs" with "Array" syntax of plugins', async () => {
+ const loadedConfig = await loadConfig(
+ loaderContext,
+ path.resolve(testDirectory, "js/array-mjs"),
+ );
+
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/js/object/index.css",
+ );
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/js/object/expect/index.css",
+ );
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(4);
+ expect(loadedConfig.filepath).toEqual(
+ path.resolve(testDirectory, "js/array-mjs", "postcss.config.mjs"),
+ );
+ });
+
+ it('should load "postcss.config.ts" with "Array" syntax of plugins', async () => {
+ const loadedConfig = await loadConfig(
+ loaderContext,
+ path.resolve(testDirectory, "ts/array"),
+ );
+
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/ts/object/index.css",
+ );
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/ts/object/expect/index.css",
+ );
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(4);
+ expect(loadedConfig.filepath).toEqual(
+ path.resolve(testDirectory, "ts/array", "postcss.config.ts"),
+ );
+ });
+
+ it('should load "postcss.config.mts" with "Array" syntax of plugins', async () => {
+ const loadedConfig = await loadConfig(
+ loaderContext,
+ path.resolve(testDirectory, "ts/array-mts"),
);
- expect(loadedConfig.config.map).toEqual(false);
- expect(loadedConfig.config.from).toEqual(
- "./test/fixtures/config-autoload/js/object/index.css"
+ expect(loadedConfig.config.map).toBe(false);
+ expect(loadedConfig.config.from).toBe(
+ "./test/fixtures/config-autoload/ts/object/index.css",
);
- expect(loadedConfig.config.to).toEqual(
- "./test/fixtures/config-autoload/js/object/expect/index.css"
+ expect(loadedConfig.config.to).toBe(
+ "./test/fixtures/config-autoload/ts/object/expect/index.css",
);
- expect(Object.keys(loadedConfig.config.plugins).length).toEqual(4);
+ expect(Object.keys(loadedConfig.config.plugins)).toHaveLength(4);
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "js/array", "postcss.config.js")
+ path.resolve(testDirectory, "ts/array-mts", "postcss.config.mts"),
);
});
it('should load empty ".postcssrc"', async () => {
const loadedConfig = await loadConfig(
loaderContext,
- path.resolve(testDirectory, "empty/.postcssrc")
+ path.resolve(testDirectory, "empty/.postcssrc"),
);
- // eslint-disable-next-line no-undefined
- expect(loadedConfig.config).toEqual(undefined);
+ expect(loadedConfig.config).toBeUndefined();
expect(loadedConfig.filepath).toEqual(
- path.resolve(testDirectory, "empty/.postcssrc")
+ path.resolve(testDirectory, "empty/.postcssrc"),
);
});
diff --git a/test/execute.test.js b/test/execute.test.js
index 4254378d..99c50a94 100644
--- a/test/execute.test.js
+++ b/test/execute.test.js
@@ -1,10 +1,10 @@
-import path from "path";
+import path from "node:path";
import {
compile,
+ getCodeFromBundle,
getCompiler,
getErrors,
- getCodeFromBundle,
getWarnings,
} from "./helpers";
@@ -33,7 +33,7 @@ describe('"execute" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.exec.js", stats);
@@ -70,7 +70,7 @@ describe('"execute" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.js", stats);
@@ -109,7 +109,7 @@ describe('"execute" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.exec.js", stats);
diff --git a/test/fixtures/config-autoload/js/array-esm-js/imports/section.css b/test/fixtures/config-autoload/js/array-esm-js/imports/section.css
new file mode 100644
index 00000000..4568aa99
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-esm-js/imports/section.css
@@ -0,0 +1,3 @@
+.import {
+ color: goldenrod;
+}
diff --git a/test/fixtures/config-autoload/js/array-esm-js/index.css b/test/fixtures/config-autoload/js/array-esm-js/index.css
new file mode 100644
index 00000000..3b228825
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-esm-js/index.css
@@ -0,0 +1,5 @@
+@import 'imports/section.css';
+
+.test {
+ color: cyan;
+}
diff --git a/test/fixtures/config-autoload/js/array-esm-js/index.js b/test/fixtures/config-autoload/js/array-esm-js/index.js
new file mode 100644
index 00000000..07bf0b31
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-esm-js/index.js
@@ -0,0 +1,3 @@
+import style from './index.css'
+
+export default style
diff --git a/test/fixtures/config-autoload/js/array-esm-js/postcss.config.js b/test/fixtures/config-autoload/js/array-esm-js/postcss.config.js
new file mode 100644
index 00000000..53cd49c0
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-esm-js/postcss.config.js
@@ -0,0 +1,21 @@
+import postcssNested from 'postcss-nested';
+export default function (api) {
+ return {
+ parser: 'sugarss',
+ syntax: 'sugarss',
+ map: api.mode === 'development' ? 'inline' : false,
+ from: './test/fixtures/config-autoload/js/object/index.css',
+ to: './test/fixtures/config-autoload/js/object/expect/index.css',
+ plugins: [
+ 'postcss-import',
+ [
+ 'postcss-nested',
+ {
+ // Options
+ }
+ ],
+ postcssNested,
+ postcssNested({ /* Options */ }),
+ ]
+ }
+};
diff --git a/test/fixtures/config-autoload/js/array-mjs/imports/section.css b/test/fixtures/config-autoload/js/array-mjs/imports/section.css
new file mode 100644
index 00000000..4568aa99
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-mjs/imports/section.css
@@ -0,0 +1,3 @@
+.import {
+ color: goldenrod;
+}
diff --git a/test/fixtures/config-autoload/js/array-mjs/index.css b/test/fixtures/config-autoload/js/array-mjs/index.css
new file mode 100644
index 00000000..3b228825
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-mjs/index.css
@@ -0,0 +1,5 @@
+@import 'imports/section.css';
+
+.test {
+ color: cyan;
+}
diff --git a/test/fixtures/config-autoload/js/array-mjs/index.js b/test/fixtures/config-autoload/js/array-mjs/index.js
new file mode 100644
index 00000000..07bf0b31
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-mjs/index.js
@@ -0,0 +1,3 @@
+import style from './index.css'
+
+export default style
diff --git a/test/fixtures/config-autoload/js/array-mjs/postcss.config.mjs b/test/fixtures/config-autoload/js/array-mjs/postcss.config.mjs
new file mode 100644
index 00000000..53cd49c0
--- /dev/null
+++ b/test/fixtures/config-autoload/js/array-mjs/postcss.config.mjs
@@ -0,0 +1,21 @@
+import postcssNested from 'postcss-nested';
+export default function (api) {
+ return {
+ parser: 'sugarss',
+ syntax: 'sugarss',
+ map: api.mode === 'development' ? 'inline' : false,
+ from: './test/fixtures/config-autoload/js/object/index.css',
+ to: './test/fixtures/config-autoload/js/object/expect/index.css',
+ plugins: [
+ 'postcss-import',
+ [
+ 'postcss-nested',
+ {
+ // Options
+ }
+ ],
+ postcssNested,
+ postcssNested({ /* Options */ }),
+ ]
+ }
+};
diff --git a/test/fixtures/config-autoload/ts/array-mts/imports/section.css b/test/fixtures/config-autoload/ts/array-mts/imports/section.css
new file mode 100644
index 00000000..4568aa99
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array-mts/imports/section.css
@@ -0,0 +1,3 @@
+.import {
+ color: goldenrod;
+}
diff --git a/test/fixtures/config-autoload/ts/array-mts/index.css b/test/fixtures/config-autoload/ts/array-mts/index.css
new file mode 100644
index 00000000..3b228825
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array-mts/index.css
@@ -0,0 +1,5 @@
+@import 'imports/section.css';
+
+.test {
+ color: cyan;
+}
diff --git a/test/fixtures/config-autoload/ts/array-mts/index.js b/test/fixtures/config-autoload/ts/array-mts/index.js
new file mode 100644
index 00000000..07bf0b31
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array-mts/index.js
@@ -0,0 +1,3 @@
+import style from './index.css'
+
+export default style
diff --git a/test/fixtures/config-autoload/ts/array-mts/postcss.config.mts b/test/fixtures/config-autoload/ts/array-mts/postcss.config.mts
new file mode 100644
index 00000000..f556ec98
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array-mts/postcss.config.mts
@@ -0,0 +1,37 @@
+import type { Config as PostCSSConfig } from 'postcss-load-config';
+import type { LoaderContext } from 'webpack';
+
+type PostCSSLoaderContext = LoaderContext;
+
+interface PostCSSLoaderAPI {
+ mode: PostCSSLoaderContext['mode'];
+ file: PostCSSLoaderContext['resourcePath'];
+ webpackLoaderContext: PostCSSLoaderContext;
+ env: PostCSSLoaderContext['mode'];
+ options: PostCSSConfig;
+}
+
+type PostCSSLoaderOptions = PostCSSConfig | ((api: PostCSSLoaderAPI) => PostCSSConfig);
+
+const config: PostCSSLoaderOptions = function (api) {
+ return {
+ parser: 'sugarss',
+ syntax: 'sugarss',
+ map: api.mode === 'development' ? 'inline' : false,
+ from: './test/fixtures/config-autoload/ts/object/index.css',
+ to: './test/fixtures/config-autoload/ts/object/expect/index.css',
+ plugins: [
+ 'postcss-import',
+ [
+ 'postcss-nested',
+ {
+ // Options
+ }
+ ],
+ require('postcss-nested'),
+ require('postcss-nested')({ /* Options */ }),
+ ]
+ }
+};
+
+export default config;
diff --git a/test/fixtures/config-autoload/ts/array/imports/section.css b/test/fixtures/config-autoload/ts/array/imports/section.css
new file mode 100644
index 00000000..4568aa99
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array/imports/section.css
@@ -0,0 +1,3 @@
+.import {
+ color: goldenrod;
+}
diff --git a/test/fixtures/config-autoload/ts/array/index.css b/test/fixtures/config-autoload/ts/array/index.css
new file mode 100644
index 00000000..3b228825
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array/index.css
@@ -0,0 +1,5 @@
+@import 'imports/section.css';
+
+.test {
+ color: cyan;
+}
diff --git a/test/fixtures/config-autoload/ts/array/index.js b/test/fixtures/config-autoload/ts/array/index.js
new file mode 100644
index 00000000..07bf0b31
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array/index.js
@@ -0,0 +1,3 @@
+import style from './index.css'
+
+export default style
diff --git a/test/fixtures/config-autoload/ts/array/postcss.config.ts b/test/fixtures/config-autoload/ts/array/postcss.config.ts
new file mode 100644
index 00000000..29f50a96
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/array/postcss.config.ts
@@ -0,0 +1,37 @@
+import type { Config as PostCSSConfig } from 'postcss-load-config';
+import type { LoaderContext } from 'webpack';
+
+type PostCSSLoaderContext = LoaderContext;
+
+interface PostCSSLoaderAPI {
+ mode: PostCSSLoaderContext['mode'];
+ file: PostCSSLoaderContext['resourcePath'];
+ webpackLoaderContext: PostCSSLoaderContext;
+ env: PostCSSLoaderContext['mode'];
+ options: PostCSSConfig;
+}
+
+type PostCSSLoaderOptions = PostCSSConfig | ((api: PostCSSLoaderAPI) => PostCSSConfig);
+
+const config: PostCSSLoaderOptions = function (api) {
+ return {
+ parser: 'sugarss',
+ syntax: 'sugarss',
+ map: api.mode === 'development' ? 'inline' : false,
+ from: './test/fixtures/config-autoload/ts/object/index.css',
+ to: './test/fixtures/config-autoload/ts/object/expect/index.css',
+ plugins: [
+ 'postcss-import',
+ [
+ 'postcss-nested',
+ {
+ // Options
+ }
+ ],
+ require('postcss-nested'),
+ require('postcss-nested')({ /* Options */ }),
+ ]
+ }
+};
+
+module.exports = config;
diff --git a/test/fixtures/config-autoload/ts/object/imports/section.css b/test/fixtures/config-autoload/ts/object/imports/section.css
new file mode 100644
index 00000000..626b1b56
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/object/imports/section.css
@@ -0,0 +1,3 @@
+.import {
+ color: red;
+}
diff --git a/test/fixtures/config-autoload/ts/object/index.css b/test/fixtures/config-autoload/ts/object/index.css
new file mode 100644
index 00000000..48162650
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/object/index.css
@@ -0,0 +1,5 @@
+@import "imports/section.css";
+
+.test {
+ color: blue;
+}
diff --git a/test/fixtures/config-autoload/ts/object/index.js b/test/fixtures/config-autoload/ts/object/index.js
new file mode 100644
index 00000000..07bf0b31
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/object/index.js
@@ -0,0 +1,3 @@
+import style from './index.css'
+
+export default style
diff --git a/test/fixtures/config-autoload/ts/object/postcss.config.ts b/test/fixtures/config-autoload/ts/object/postcss.config.ts
new file mode 100644
index 00000000..4605a658
--- /dev/null
+++ b/test/fixtures/config-autoload/ts/object/postcss.config.ts
@@ -0,0 +1,30 @@
+import type { Config as PostCSSConfig } from 'postcss-load-config';
+import type { LoaderContext } from 'webpack';
+
+type PostCSSLoaderContext = LoaderContext;
+
+interface PostCSSLoaderAPI {
+ mode: PostCSSLoaderContext['mode'];
+ file: PostCSSLoaderContext['resourcePath'];
+ webpackLoaderContext: PostCSSLoaderContext;
+ env: PostCSSLoaderContext['mode'];
+ options: PostCSSConfig;
+}
+
+type PostCSSLoaderOptions = PostCSSConfig | ((api: PostCSSLoaderAPI) => PostCSSConfig);
+
+const config: PostCSSLoaderOptions = function (api) {
+ return {
+ parser: 'sugarss',
+ syntax: 'sugarss',
+ map: api.mode === 'development' ? 'inline' : false,
+ from: './test/fixtures/config-autoload/ts/object/index.css',
+ to: './test/fixtures/config-autoload/ts/object/expect/index.css',
+ plugins: {
+ 'postcss-import': {},
+ 'postcss-nested': {},
+ }
+ }
+};
+
+export default config;
diff --git a/test/fixtures/package-json-files/no-postcss/package.json b/test/fixtures/package-json-files/no-postcss/package.json
index 255dac01..0967ef42 100644
--- a/test/fixtures/package-json-files/no-postcss/package.json
+++ b/test/fixtures/package-json-files/no-postcss/package.json
@@ -1,4 +1 @@
-{
- "dependencies": {},
- "devDependencies": {}
-}
\ No newline at end of file
+{}
diff --git a/test/fixtures/package-json-files/postcss-v8-in-dependencies/package.json b/test/fixtures/package-json-files/postcss-v8-in-dependencies/package.json
index 7e20ba4d..2003d907 100644
--- a/test/fixtures/package-json-files/postcss-v8-in-dependencies/package.json
+++ b/test/fixtures/package-json-files/postcss-v8-in-dependencies/package.json
@@ -1,6 +1,5 @@
{
"dependencies": {
"postcss": "^8.0.0"
- },
- "devDependencies": {}
-}
\ No newline at end of file
+ }
+}
diff --git a/test/fixtures/package-json-files/postcss-v8-in-devDependencies/package.json b/test/fixtures/package-json-files/postcss-v8-in-devDependencies/package.json
index 0712e31c..b750286e 100644
--- a/test/fixtures/package-json-files/postcss-v8-in-devDependencies/package.json
+++ b/test/fixtures/package-json-files/postcss-v8-in-devDependencies/package.json
@@ -1,6 +1,5 @@
{
- "dependencies": {},
"devDependencies": {
"postcss": "^8.0.0"
}
-}
\ No newline at end of file
+}
diff --git a/test/helpers/astLoader.js b/test/helpers/astLoader.js
index e41c3d7b..c246b31e 100644
--- a/test/helpers/astLoader.js
+++ b/test/helpers/astLoader.js
@@ -1,4 +1,4 @@
-import Module from "module";
+import Module from "node:module";
const postcss = require("postcss");
@@ -9,11 +9,9 @@ function exec(code, loaderContext) {
const module = new Module(resource, parentModule);
- // eslint-disable-next-line no-underscore-dangle
module.paths = Module._nodeModulePaths(context);
module.filename = resource;
- // eslint-disable-next-line no-underscore-dangle
module._compile(code, resource);
return module.exports;
@@ -21,10 +19,9 @@ function exec(code, loaderContext) {
module.exports = function astLoader(content) {
const callback = this.async();
- const { spy = jest.fn(), execute } = this.query;
+ const { spy = globalThis.jest.fn(), execute } = this.query;
if (execute) {
- // eslint-disable-next-line no-param-reassign
content = exec(content, this);
}
diff --git a/test/helpers/execute.js b/test/helpers/execute.js
index 7e1a94e6..bc7717f8 100644
--- a/test/helpers/execute.js
+++ b/test/helpers/execute.js
@@ -1,21 +1,20 @@
-import Module from "module";
-import path from "path";
+import Module from "node:module";
+import path from "node:path";
const parentModule = module;
export default (code) => {
const resource = "test.js";
const module = new Module(resource, parentModule);
- // eslint-disable-next-line no-underscore-dangle
+
module.paths = Module._nodeModulePaths(
- path.resolve(__dirname, "../fixtures")
+ path.resolve(__dirname, "../fixtures"),
);
module.filename = resource;
- // eslint-disable-next-line no-underscore-dangle
module._compile(
`let __export__;${code};module.exports = __export__;`,
- resource
+ resource,
);
return module.exports;
diff --git a/test/helpers/getCodeFromBundle.js b/test/helpers/getCodeFromBundle.js
index 0cb7598f..2d0146be 100644
--- a/test/helpers/getCodeFromBundle.js
+++ b/test/helpers/getCodeFromBundle.js
@@ -3,17 +3,16 @@ export default (id, stats) => {
const module = modules.find((m) => m.id.endsWith(id));
const { _source } = module;
- // eslint-disable-next-line no-underscore-dangle
const code = (_source._value || _source._valueAsString).replace(
"module.exports = ",
- ""
+ "",
);
let result;
try {
result = JSON.parse(code);
- } catch (error) {
+ } catch {
result = { css: code };
}
diff --git a/test/helpers/getCompiler.js b/test/helpers/getCompiler.js
index 639c29d3..631fa666 100644
--- a/test/helpers/getCompiler.js
+++ b/test/helpers/getCompiler.js
@@ -1,7 +1,7 @@
-import path from "path";
+import path from "node:path";
+import { Volume, createFsFromVolume } from "memfs";
import webpack from "webpack";
-import { createFsFromVolume, Volume } from "memfs";
export default (fixture, loaderOptions = {}, config = {}) => {
const fullConfig = {
diff --git a/test/helpers/getExecutedCode.js b/test/helpers/getExecutedCode.js
index aa52bddc..79bfec60 100644
--- a/test/helpers/getExecutedCode.js
+++ b/test/helpers/getExecutedCode.js
@@ -6,8 +6,8 @@ export default (asset, compiler, stats) => {
if (Array.isArray(executed)) {
executed = executed.map((module) => {
// Todo remove after drop webpack@4
- // eslint-disable-next-line no-param-reassign
- module[0] = module[0].replace(/\?.*!/g, "?[ident]!");
+
+ module[0] = module[0].replaceAll(/\?.*!/g, "?[ident]!");
return module;
});
diff --git a/test/helpers/index.js b/test/helpers/index.js
index f2303795..99fca117 100644
--- a/test/helpers/index.js
+++ b/test/helpers/index.js
@@ -1,23 +1,10 @@
-import compile from "./compile";
-import execute from "./execute";
-import getCompiler from "./getCompiler";
-import getErrors from "./getErrors";
-import getExecutedCode from "./getExecutedCode";
-import getCodeFromBundle from "./getCodeFromBundle";
-import getWarnings from "./getWarnings";
-import normalizeErrors from "./normalizeErrors";
-import readAsset from "./readAsset";
-import readsAssets from "./readAssets";
-
-export {
- compile,
- execute,
- getCompiler,
- getErrors,
- getExecutedCode,
- getCodeFromBundle,
- getWarnings,
- normalizeErrors,
- readAsset,
- readsAssets,
-};
+export { default as readsAssets } from "./readAssets";
+export { default as compile } from "./compile";
+export { default as normalizeErrors } from "./normalizeErrors";
+export { default as execute } from "./execute";
+export { default as getCompiler } from "./getCompiler";
+export { default as getCodeFromBundle } from "./getCodeFromBundle";
+export { default as getExecutedCode } from "./getExecutedCode";
+export { default as getErrors } from "./getErrors";
+export { default as readAsset } from "./readAsset";
+export { default as getWarnings } from "./getWarnings";
diff --git a/test/helpers/normalizeErrors.js b/test/helpers/normalizeErrors.js
index bbadb8bd..1f73b63b 100644
--- a/test/helpers/normalizeErrors.js
+++ b/test/helpers/normalizeErrors.js
@@ -5,15 +5,14 @@ function removeCWD(str) {
let cwd = process.cwd();
if (isWin) {
- // eslint-disable-next-line no-param-reassign
- str = str.replace(/\\/g, "/");
- // eslint-disable-next-line no-param-reassign
- cwd = cwd.replace(/\\/g, "/");
+ str = str.replaceAll("\\", "/");
+
+ cwd = cwd.replaceAll("\\", "/");
}
return stripAnsi(str)
.replace(/\(from .*?\)/, "(from `replaced original path`)")
- .replace(new RegExp(cwd, "g"), "");
+ .replaceAll(new RegExp(cwd, "g"), "");
}
export default (errors, shortError) =>
diff --git a/test/helpers/readAsset.js b/test/helpers/readAsset.js
index fde3ff39..ea0597f6 100644
--- a/test/helpers/readAsset.js
+++ b/test/helpers/readAsset.js
@@ -1,4 +1,4 @@
-import path from "path";
+import path from "node:path";
export default (asset, compiler, stats) => {
const usedFs = compiler.outputFileSystem;
@@ -10,7 +10,7 @@ export default (asset, compiler, stats) => {
const queryStringIdx = targetFile.indexOf("?");
if (queryStringIdx >= 0) {
- targetFile = targetFile.substr(0, queryStringIdx);
+ targetFile = targetFile.slice(0, queryStringIdx);
}
try {
diff --git a/test/helpers/readAssets.js b/test/helpers/readAssets.js
index 15b9dca2..4d6393e3 100644
--- a/test/helpers/readAssets.js
+++ b/test/helpers/readAssets.js
@@ -3,9 +3,9 @@ import readAsset from "./readAsset";
export default function readAssets(compiler, stats) {
const assets = {};
- Object.keys(stats.compilation.assets).forEach((asset) => {
+ for (const asset of Object.keys(stats.compilation.assets)) {
assets[asset] = readAsset(asset, compiler, stats);
- });
+ }
return assets;
}
diff --git a/test/implementation.test.js b/test/implementation.test.js
index f1378c66..a58b00bb 100644
--- a/test/implementation.test.js
+++ b/test/implementation.test.js
@@ -2,9 +2,9 @@ import postcss from "postcss";
import {
compile,
+ getCodeFromBundle,
getCompiler,
getErrors,
- getCodeFromBundle,
getWarnings,
} from "./helpers";
@@ -28,7 +28,7 @@ describe('"implementation" option', () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
});
it("should work with a custom instance of PostCSS", async () => {
diff --git a/test/loader.test.js b/test/loader.test.js
index d8549fbf..bb708da2 100644
--- a/test/loader.test.js
+++ b/test/loader.test.js
@@ -1,15 +1,14 @@
-import path from "path";
+import path from "node:path";
import postcss from "postcss";
-// eslint-disable-next-line import/no-namespace
import * as utils from "../src/utils";
import {
compile,
+ getCodeFromBundle,
getCompiler,
getErrors,
- getCodeFromBundle,
getWarnings,
} from "./helpers/index";
@@ -78,7 +77,6 @@ describe("loader", () => {
});
const stats = await compile(compiler);
- // eslint-disable-next-line no-underscore-dangle
expect(stats.compilation.assets["sprite.svg"]).toBeDefined();
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
@@ -110,7 +108,7 @@ describe("loader", () => {
dir: path.resolve(__dirname, "fixtures", "deps2"),
content: "",
plugin,
- }
+ },
);
};
@@ -126,16 +124,16 @@ describe("loader", () => {
stats.compilation;
expect(contextDependencies).toContain(
- path.resolve(__dirname, "fixtures", "deps")
+ path.resolve(__dirname, "fixtures", "deps"),
);
expect(contextDependencies).toContain(
- path.resolve(__dirname, "fixtures", "deps2")
+ path.resolve(__dirname, "fixtures", "deps2"),
);
expect(missingDependencies).toContain(
- path.resolve(__dirname, "fixtures", "missing-dep.html")
+ path.resolve(__dirname, "fixtures", "missing-dep.html"),
);
expect(buildDependencies).toContain(
- path.resolve(__dirname, "fixtures", "build-dep.html")
+ path.resolve(__dirname, "fixtures", "build-dep.html"),
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
@@ -171,7 +169,7 @@ describe("loader", () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
@@ -204,7 +202,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
- path.resolve(__dirname, "./fixtures/package-json-files/no-postcss")
+ path.resolve(__dirname, "./fixtures/package-json-files/no-postcss"),
);
const compiler = getCompiler("./css/index.js", {
@@ -221,7 +219,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
spy.mockRestore();
});
@@ -232,8 +230,8 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
.mockReturnValue(
path.resolve(
__dirname,
- "./fixtures/package-json-files/postcss-v8-in-dependencies"
- )
+ "./fixtures/package-json-files/postcss-v8-in-dependencies",
+ ),
);
const compiler = getCompiler("./css/index.js", {
@@ -250,7 +248,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
spy.mockRestore();
});
@@ -261,8 +259,8 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
.mockReturnValue(
path.resolve(
__dirname,
- "./fixtures/package-json-files/postcss-v8-in-devDependencies"
- )
+ "./fixtures/package-json-files/postcss-v8-in-devDependencies",
+ ),
);
const compiler = getCompiler("./css/index.js", {
@@ -279,7 +277,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
spy.mockRestore();
});
@@ -288,7 +286,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
- path.resolve(__dirname, "./fixtures/package-json-files/unknown")
+ path.resolve(__dirname, "./fixtures/package-json-files/unknown"),
);
const compiler = getCompiler("./css/index.js", {
@@ -305,7 +303,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
spy.mockRestore();
});
@@ -314,7 +312,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const spy = jest
.spyOn(utils, "findPackageJSONDir")
.mockReturnValue(
- path.resolve(__dirname, "./fixtures/package-json-files/no-postcss")
+ path.resolve(__dirname, "./fixtures/package-json-files/no-postcss"),
);
const compiler = getCompiler("./css/index.js", {
@@ -325,7 +323,7 @@ describe("check postcss versions to avoid using PostCSS 7", () => {
const stats = await compile(compiler);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
- expect(getErrors(stats)).toMatchSnapshot("errors");
+ expect(getErrors(stats, true)).toMatchSnapshot("errors");
spy.mockRestore();
});
diff --git a/test/postcssOptions.test.js b/test/postcssOptions.test.js
index 67d0af13..b7899bee 100644
--- a/test/postcssOptions.test.js
+++ b/test/postcssOptions.test.js
@@ -1,13 +1,13 @@
-import path from "path";
+import path from "node:path";
+import myPostcssPlugin from "./fixtures/plugin/plugin";
import {
compile,
+ getCodeFromBundle,
getCompiler,
getErrors,
- getCodeFromBundle,
getWarnings,
} from "./helpers";
-import myPostcssPlugin from "./fixtures/plugin/plugin";
jest.setTimeout(30000);
@@ -36,9 +36,9 @@ describe('"postcssOptions" option', () => {
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
const toIsWork = codeFromBundle.sourceMap.file.endsWith("to.css");
- const fromIsWork =
- codeFromBundle.sourceMap.sources.filter((i) => i.endsWith("from.css"))
- .length > 0;
+ const fromIsWork = codeFromBundle.sourceMap.sources.some((i) =>
+ i.endsWith("from.css"),
+ );
expect(toIsWork).toBe(true);
expect(fromIsWork).toBe(true);
@@ -59,9 +59,9 @@ describe('"postcssOptions" option', () => {
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
const toIsWork = codeFromBundle.sourceMap.file.endsWith("style.css");
- const fromIsWork =
- codeFromBundle.sourceMap.sources.filter((i) => i.endsWith("style.css"))
- .length > 0;
+ const fromIsWork = codeFromBundle.sourceMap.sources.some((i) =>
+ i.endsWith("style.css"),
+ );
expect(toIsWork).toBe(true);
expect(fromIsWork).toBe(true);
@@ -88,12 +88,9 @@ describe('"postcssOptions" option', () => {
it('should work "Function" value', async () => {
const compiler = getCompiler("./css/index.js", {
- postcssOptions: () => {
- return {
- // eslint-disable-next-line global-require
- plugins: [require("./fixtures/config-scope/config/plugin")()],
- };
- },
+ postcssOptions: () => ({
+ plugins: [require("./fixtures/config-scope/config/plugin")()],
+ }),
});
const stats = await compile(compiler);
@@ -106,12 +103,9 @@ describe('"postcssOptions" option', () => {
it('should work "Function" value and with "Array" syntax of the "plugins" option', async () => {
const compiler = getCompiler("./css/index.js", {
- postcssOptions: () => {
- return {
- // eslint-disable-next-line global-require
- plugins: [require("./fixtures/config-scope/config/plugin")()],
- };
- },
+ postcssOptions: () => ({
+ plugins: [require("./fixtures/config-scope/config/plugin")()],
+ }),
});
const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
@@ -123,12 +117,9 @@ describe('"postcssOptions" option', () => {
it('should work "Function" value and with "Object" syntax of the "plugins" option', async () => {
const compiler = getCompiler("./css/index.js", {
- postcssOptions: () => {
- return {
- // eslint-disable-next-line global-require
- plugins: [require("./fixtures/config-scope/config/plugin")()],
- };
- },
+ postcssOptions: () => ({
+ plugins: [require("./fixtures/config-scope/config/plugin")()],
+ }),
});
const stats = await compile(compiler);
@@ -157,7 +148,6 @@ describe('"postcssOptions" option', () => {
it('should work with the "parser" option with "Object" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
- // eslint-disable-next-line global-require,import/no-dynamic-require
parser: require("sugarss"),
},
});
@@ -171,6 +161,7 @@ describe('"postcssOptions" option', () => {
});
// TODO jest have not good support for ES modules for testing it, tested manually
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip('should work with the "parser" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
@@ -187,6 +178,7 @@ describe('"postcssOptions" option', () => {
});
// TODO jest have not good support for ES modules for testing it, tested manually
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip('should work with the "stringifier" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
@@ -203,6 +195,7 @@ describe('"postcssOptions" option', () => {
});
// TODO jest have not good support for ES modules for testing it, tested manually
+ // eslint-disable-next-line jest/no-disabled-tests
it.skip('should work with the "syntax" option with "Object" value with ESM', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
@@ -221,7 +214,6 @@ describe('"postcssOptions" option', () => {
it('should work with the "parser" option with "Function" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
- // eslint-disable-next-line global-require,import/no-dynamic-require
parser: require("sugarss").parse,
},
});
@@ -265,7 +257,6 @@ describe('"postcssOptions" option', () => {
it('should work with the "stringifier" option with "Object" value', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
- // eslint-disable-next-line global-require
stringifier: require("sugarss"),
},
});
@@ -279,8 +270,8 @@ describe('"postcssOptions" option', () => {
});
it('should work with the "stringifier" option with "Function" value', async () => {
- // eslint-disable-next-line global-require
const Midas = require("midas");
+
const midas = new Midas();
const compiler = getCompiler("./css/index.js", {
@@ -327,7 +318,6 @@ describe('"postcssOptions" option', () => {
it('should work with the "syntax" option with "Object" value', async () => {
const compiler = getCompiler("./sss/index.js", {
postcssOptions: {
- // eslint-disable-next-line global-require
syntax: require("sugarss"),
},
});
@@ -354,8 +344,8 @@ describe('"postcssOptions" option', () => {
getErrors(stats, true).map((item) =>
item
.replace("property 'parse'", "properties")
- .replace(/undefined$/, "undefined (reading 'parse')")
- )
+ .replace(/undefined$/, "undefined (reading 'parse')"),
+ ),
).toMatchSnapshot("errors");
});
@@ -375,7 +365,6 @@ describe('"postcssOptions" option', () => {
(root) => {
root.walkDecls((decl) => {
if (decl.value === "red") {
- // eslint-disable-next-line no-param-reassign
decl.value = "rgba(255, 0, 0, 1.0)";
}
});
@@ -388,7 +377,6 @@ describe('"postcssOptions" option', () => {
postcss: (root) => {
root.walkDecls((decl) => {
if (decl.value === "green") {
- // eslint-disable-next-line no-param-reassign
decl.value = "rgba(0, 255, 0, 1.0)";
}
});
@@ -599,7 +587,6 @@ describe('"postcssOptions" option', () => {
it('should work with the "plugins" option with "Array" value and not throw an error on falsy plugin', async () => {
const compiler = getCompiler("./css/index.js", {
postcssOptions: {
- // eslint-disable-next-line no-undefined
plugins: [undefined, null, "", 0],
},
});
@@ -632,7 +619,7 @@ describe('"postcssOptions" option', () => {
[
path.resolve(
__dirname,
- "./fixtures/plugin/default-other-plugin.js"
+ "./fixtures/plugin/default-other-plugin.js",
),
{ alpha: 0.5, color: "red" },
],
@@ -682,7 +669,7 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/css/custom.config.js"
+ "./fixtures/config-scope/css/custom.config.js",
),
},
});
@@ -761,7 +748,7 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/all-options/postcss.config.js"
+ "./fixtures/config-scope/all-options/postcss.config.js",
),
},
});
@@ -779,7 +766,7 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/css/unresolve.js"
+ "./fixtures/config-scope/css/unresolve.js",
),
},
});
@@ -794,7 +781,7 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/css/invalid.config.js"
+ "./fixtures/config-scope/css/invalid.config.js",
),
},
});
@@ -809,7 +796,7 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/from-to/postcss.config.js"
+ "./fixtures/config-scope/from-to/postcss.config.js",
),
},
});
@@ -822,7 +809,7 @@ describe('"postcssOptions" option', () => {
expect(path.isAbsolute(source)).toBe(false);
expect(source).toBe(path.normalize(source));
- return source.replace(/\\/g, "/");
+ return source.replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -836,14 +823,53 @@ describe('"postcssOptions" option', () => {
postcssOptions: {
config: path.resolve(
__dirname,
- "./fixtures/config-scope/api/postcss.config.js"
+ "./fixtures/config-scope/api/postcss.config.js",
),
},
});
const stats = await compile(compiler);
+ const codeFromBundle = getCodeFromBundle("style.css", stats);
+
+ expect(codeFromBundle.css).toMatchSnapshot("css");
+ expect(getWarnings(stats)).toMatchSnapshot("warnings");
+ expect(getErrors(stats)).toMatchSnapshot("errors");
+ });
+ it("should work and don't modify postcss options", async () => {
+ const postcssOptions = {
+ config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
+ from: "from.css",
+ map: {
+ inline: true,
+ },
+ parser: "postcss/lib/parse",
+ stringifier: "postcss/lib/stringify",
+ to: "to.css",
+ plugins: [require.resolve("./fixtures/plugin/new-api.plugin")],
+ };
+ const compiler = getCompiler(
+ "./config-scope/css/index.js",
+ {
+ postcssOptions,
+ },
+ {
+ devtool: "source-map",
+ },
+ );
+ const stats = await compile(compiler);
const codeFromBundle = getCodeFromBundle("style.css", stats);
+ expect(postcssOptions).toEqual({
+ config: path.resolve(__dirname, "./fixtures/css/plugins.config.js"),
+ from: "from.css",
+ map: {
+ inline: true,
+ },
+ parser: "postcss/lib/parse",
+ stringifier: "postcss/lib/stringify",
+ to: "to.css",
+ plugins: [require.resolve("./fixtures/plugin/new-api.plugin")],
+ });
expect(codeFromBundle.css).toMatchSnapshot("css");
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
diff --git a/test/sourceMap.test.js b/test/sourceMap.test.js
index 7be29d2c..0175415b 100644
--- a/test/sourceMap.test.js
+++ b/test/sourceMap.test.js
@@ -2,14 +2,14 @@
* @jest-environment node
*/
-import path from "path";
-import fs from "fs";
+import fs from "node:fs";
+import path from "node:path";
import {
compile,
+ getCodeFromBundle,
getCompiler,
getErrors,
- getCodeFromBundle,
getWarnings,
} from "./helpers";
@@ -23,7 +23,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: false,
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -33,12 +33,12 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
- true
+ true,
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
- .replace(/\\/g, "/");
+ .replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -56,7 +56,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: "source-map",
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -66,12 +66,12 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
- true
+ true,
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
- .replace(/\\/g, "/");
+ .replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -88,7 +88,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: "source-map",
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -98,12 +98,12 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
- true
+ true,
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
- .replace(/\\/g, "/");
+ .replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -128,7 +128,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: false,
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -138,10 +138,10 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(false);
expect(source).toBe(path.normalize(source));
expect(
- fs.existsSync(path.resolve(__dirname, "./fixtures/css", source))
+ fs.existsSync(path.resolve(__dirname, "./fixtures/css", source)),
).toBe(true);
- return source.replace(/\\/g, "/");
+ return source.replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -177,17 +177,16 @@ describe('"sourceMap" option', () => {
{
loader: "sass-loader",
options: {
- // eslint-disable-next-line global-require
implementation: require("sass"),
sassOptions: {
sourceMap: true,
sourceMapRoot: path.resolve(
__dirname,
- "./fixtures/scss/"
+ "./fixtures/scss/",
),
outFile: path.resolve(
__dirname,
- "./fixtures/scss/style.css.map"
+ "./fixtures/scss/style.css.map",
),
sourceMapContents: true,
omitSourceMapUrl: true,
@@ -199,7 +198,7 @@ describe('"sourceMap" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
@@ -241,17 +240,16 @@ describe('"sourceMap" option', () => {
{
loader: "sass-loader",
options: {
- // eslint-disable-next-line global-require
implementation: require("sass"),
sassOptions: {
sourceMap: true,
sourceMapRoot: path.resolve(
__dirname,
- "./fixtures/scss/"
+ "./fixtures/scss/",
),
outFile: path.resolve(
__dirname,
- "./fixtures/scss/style.css.map"
+ "./fixtures/scss/style.css.map",
),
sourceMapContents: true,
omitSourceMapUrl: true,
@@ -263,7 +261,7 @@ describe('"sourceMap" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
@@ -272,10 +270,10 @@ describe('"sourceMap" option', () => {
sourceMap.sources = sourceMap.sources.map((source) => {
expect(path.isAbsolute(source)).toBe(false);
expect(
- fs.existsSync(path.resolve(__dirname, "./fixtures/scss", source))
+ fs.existsSync(path.resolve(__dirname, "./fixtures/scss", source)),
).toBe(true);
- return source.replace(/\\/g, "/");
+ return source.replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -293,7 +291,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: false,
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -313,7 +311,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: "source-map",
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -332,7 +330,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: false,
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.css", stats);
@@ -366,7 +364,6 @@ describe('"sourceMap" option', () => {
{
loader: "sass-loader",
options: {
- // eslint-disable-next-line global-require
implementation: require("sass"),
},
},
@@ -374,7 +371,7 @@ describe('"sourceMap" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.scss", stats);
@@ -384,12 +381,12 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
- true
+ true,
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
- .replace(/\\/g, "/");
+ .replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -426,7 +423,7 @@ describe('"sourceMap" option', () => {
},
],
},
- }
+ },
);
const stats = await compile(compiler);
const { css, sourceMap } = getCodeFromBundle("style.less", stats);
@@ -436,12 +433,12 @@ describe('"sourceMap" option', () => {
expect(path.isAbsolute(source)).toBe(true);
expect(source).toBe(path.normalize(source));
expect(fs.existsSync(path.resolve(sourceMap.sourceRoot, source))).toBe(
- true
+ true,
);
return path
.relative(path.resolve(__dirname, "./fixtures"), source)
- .replace(/\\/g, "/");
+ .replaceAll("\\", "/");
});
expect(css).toMatchSnapshot("css");
@@ -464,7 +461,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: false,
- }
+ },
);
const stats = await compile(compiler);
const { css } = getCodeFromBundle("style.css", stats);
@@ -488,7 +485,7 @@ describe('"sourceMap" option', () => {
},
{
devtool: "source-map",
- }
+ },
);
const stats = await compile(compiler);
const { css } = getCodeFromBundle("style.css", stats);
diff --git a/test/validate-options.test.js b/test/validate-options.test.js
index 8122f5bf..ad500fa5 100644
--- a/test/validate-options.test.js
+++ b/test/validate-options.test.js
@@ -1,7 +1,6 @@
-/* eslint-disable global-require */
-import path from "path";
+import path from "node:path";
-import { getCompiler, compile } from "./helpers/index";
+import { compile, getCompiler } from "./helpers/index";
describe("validate options", () => {
const tests = {
@@ -40,7 +39,7 @@ describe("validate options", () => {
{
config: path.resolve(
__dirname,
- "./fixtures/config-scope/config/postcss.config.js"
+ "./fixtures/config-scope/config/postcss.config.js",
),
},
],
@@ -99,7 +98,7 @@ describe("validate options", () => {
},
],
},
- }
+ },
);
} else {
compiler = getCompiler("./css/index.js", { [key]: value });