diff --git a/.eslintrc.js b/.eslintrc.js index 095ce2a5..29e7717f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,4 @@ module.exports = { root: true, - extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'], + extends: ["@webpack-contrib/eslint-config-webpack", "prettier"], }; diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 4f14003f..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = { singleQuote: true }; diff --git a/README.md b/README.md index 5fc3f129..5200ce4c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Then add the plugin to your `webpack` config. For example: **file.js** ```js -import css from 'file.css'; +import css from "file.css"; ``` **webpack.config.js** @@ -43,7 +43,7 @@ module.exports = { rules: [ { test: /\.css$/i, - use: ['style-loader', 'css-loader'], + use: ["style-loader", "css-loader"], }, ], }, @@ -66,7 +66,7 @@ module.exports = { rules: [ { test: /\.css$/i, - use: ['to-string-loader', 'css-loader'], + use: ["to-string-loader", "css-loader"], }, ], }, @@ -76,7 +76,7 @@ module.exports = { or ```js -const css = require('./test.css').toString(); +const css = require("./test.css").toString(); console.log(css); // {String} ``` @@ -97,9 +97,9 @@ module.exports = { { test: /\.css$/i, use: [ - 'handlebars-loader', // handlebars loader expects raw resource string - 'extract-loader', - 'css-loader', + "handlebars-loader", // handlebars loader expects raw resource string + "extract-loader", + "css-loader", ], }, ], @@ -157,7 +157,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { url: true, }, @@ -179,13 +179,13 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { url: (url, resourcePath) => { // resourcePath - path to css file // Don't handle `img.png` urls - if (url.includes('img.png')) { + if (url.includes("img.png")) { return false; } @@ -238,7 +238,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { import: true, }, @@ -260,13 +260,13 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { import: (url, media, resourcePath) => { // resourcePath - path to css file // Don't handle `style.css` import - if (url.includes('style.css')) { + if (url.includes("style.css")) { return false; } @@ -298,7 +298,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: true, }, @@ -362,8 +362,8 @@ The loader replaces local selectors with unique identifiers. The chosen unique i ```js exports.locals = { - className: '_23_aKvs-b8bW2Vg3fwHozO', - subClass: '_13LGdX8RMStbBE9w-t0gZ1', + className: "_23_aKvs-b8bW2Vg3fwHozO", + subClass: "_13LGdX8RMStbBE9w-t0gZ1", }; ``` @@ -391,8 +391,8 @@ This doesn't result in any change to the CSS itself but exports multiple classna ```js exports.locals = { - className: '_23_aKvs-b8bW2Vg3fwHozO', - subClass: '_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO', + className: "_23_aKvs-b8bW2Vg3fwHozO", + subClass: "_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO", }; ``` @@ -415,14 +415,14 @@ To import a local classname from another module. ```css :local(.continueButton) { - composes: button from 'library/button.css'; + composes: button from "library/button.css"; background: red; } ``` ```css :local(.nameEdit) { - composes: edit highlight from './edit.css'; + composes: edit highlight from "./edit.css"; background: red; } ``` @@ -431,8 +431,8 @@ To import from multiple modules use multiple `composes:` rules. ```css :local(.className) { - composes: edit hightlight from './edit.css'; - composes: button from 'module/button.css'; + composes: edit hightlight from "./edit.css"; + composes: button from "module/button.css"; composes: classFromThisModule; background: red; } @@ -477,7 +477,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: true, }, @@ -499,10 +499,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { // Using `local` value has same effect like using `modules: true` - modules: 'global', + modules: "global", }, }, ], @@ -522,18 +522,18 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - compileType: 'module', - mode: 'local', + compileType: "module", + mode: "local", auto: true, exportGlobals: true, - localIdentName: '[path][name]__[local]--[hash:base64:5]', - localIdentContext: path.resolve(__dirname, 'src'), - localIdentHashPrefix: 'my-custom-hash', + localIdentName: "[path][name]__[local]--[hash:base64:5]", + localIdentContext: path.resolve(__dirname, "src"), + localIdentHashPrefix: "my-custom-hash", namedExport: true, - exportLocalsConvention: 'camelCase', + exportLocalsConvention: "camelCase", exportOnlyLocals: false, }, }, @@ -563,10 +563,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - compileType: 'icss', + compileType: "icss", }, }, }, @@ -597,7 +597,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { auto: true, @@ -621,7 +621,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { auto: /\.custom-module\.\w+$/i, @@ -645,10 +645,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - auto: (resourcePath) => resourcePath.endsWith('.custom-module.css'), + auto: (resourcePath) => resourcePath.endsWith(".custom-module.css"), }, }, }, @@ -676,10 +676,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - mode: 'global', + mode: "global", }, }, }, @@ -702,20 +702,20 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { // Callback must return "local", "global", or "pure" values mode: (resourcePath) => { if (/pure.css$/i.test(resourcePath)) { - return 'pure'; + return "pure"; } if (/global.css$/i.test(resourcePath)) { - return 'global'; + return "global"; } - return 'local'; + return "local"; }, }, }, @@ -750,10 +750,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - localIdentName: '[path][name]__[local]--[hash:base64:5]', + localIdentName: "[path][name]__[local]--[hash:base64:5]", }, }, }, @@ -777,10 +777,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - localIdentContext: path.resolve(__dirname, 'src'), + localIdentContext: path.resolve(__dirname, "src"), }, }, }, @@ -804,10 +804,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { - localIdentHashPrefix: 'hash', + localIdentHashPrefix: "hash", }, }, }, @@ -829,7 +829,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { localIdentRegExp: /page-(.*)\.css/i, @@ -859,11 +859,11 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { getLocalIdent: (context, localIdentName, localName, options) => { - return 'whatever_random_class_name'; + return "whatever_random_class_name"; }, }, }, @@ -898,7 +898,7 @@ Enables/disables ES modules named export for locals. **index.js** ```js -import { fooBaz, bar } from './styles.css'; +import { fooBaz, bar } from "./styles.css"; console.log(fooBaz, bar); ``` @@ -913,7 +913,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { esModule: true, modules: { @@ -941,7 +941,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { exportGlobals: true, @@ -982,7 +982,7 @@ By default, the exported JSON keys mirror the class names (i.e `asIs` value). **file.js** ```js -import { className } from 'file.css'; +import { className } from "file.css"; ``` **webpack.config.js** @@ -993,10 +993,10 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { - mode: 'local', - localsConvention: 'camelCase', + mode: "local", + localsConvention: "camelCase", }, }, ], @@ -1023,7 +1023,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { modules: { exportOnlyLocals: true, @@ -1050,7 +1050,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { sourceMap: true, }, @@ -1078,9 +1078,9 @@ module.exports = { { test: /\.css$/i, use: [ - 'style-loader', + "style-loader", { - loader: 'css-loader', + loader: "css-loader", options: { importLoaders: 2, // 0 => no loaders (default); @@ -1088,8 +1088,8 @@ module.exports = { // 2 => postcss-loader, sass-loader }, }, - 'postcss-loader', - 'sass-loader', + "postcss-loader", + "sass-loader", ], }, ], @@ -1117,7 +1117,7 @@ module.exports = { rules: [ { test: /\.css$/i, - loader: 'css-loader', + loader: "css-loader", options: { esModule: false, }, @@ -1141,11 +1141,11 @@ module.exports = { rules: [ { test: /\.css$/i, - use: ['style-loader', 'css-loader'], + use: ["style-loader", "css-loader"], }, { test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'url-loader', + loader: "url-loader", options: { limit: 8192, }, @@ -1179,9 +1179,9 @@ module.exports = { // For Less - /\.((c|le)ss)$/i, test: /\.((c|sa|sc)ss)$/i, use: [ - 'style-loader', + "style-loader", { - loader: 'css-loader', + loader: "css-loader", options: { // Run `postcss-loader` on each CSS `@import`, do not forget that `sass-loader` compile non CSS `@import`'s into a single file // If you need run `sass-loader` and `postcss-loader` on each CSS `@import` please set it to `2` @@ -1191,18 +1191,18 @@ module.exports = { }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { plugins: () => [postcssPresetEnv({ stage: 0 })] }, }, // Can be `less-loader` { - loader: 'sass-loader', + loader: "sass-loader", }, ], }, { test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'url-loader', + loader: "url-loader", options: { limit: 8192, }, @@ -1230,15 +1230,15 @@ module.exports = { rules: [ { test: /\.css$/i, - use: ['style-loader', 'css-loader'], + use: ["style-loader", "css-loader"], }, ], }, resolve: { alias: { - '/assets/unresolved/img.png': path.resolve( + "/assets/unresolved/img.png": path.resolve( __dirname, - 'assets/real-path-to-img/img.png' + "assets/real-path-to-img/img.png" ), }, }, @@ -1326,7 +1326,7 @@ $colorBackground: red; File treated as `CSS Module`. ```scss -@import 'variables.scss'; +@import "variables.scss"; .componentClass { background-color: $colorBackground; } @@ -1337,8 +1337,8 @@ File treated as `CSS Module`. Using both `CSS Module` functionality as well as SCSS variables directly in JavaScript. ```jsx -import svars from 'variables.scss'; -import styles from 'Component.module.scss'; +import svars from "variables.scss"; +import styles from "Component.module.scss"; // Render DOM with CSS modules class name //
diff --git a/babel.config.js b/babel.config.js index 2cfa79c8..baa26c5e 100644 --- a/babel.config.js +++ b/babel.config.js @@ -7,23 +7,23 @@ module.exports = (api) => { return { presets: [ [ - '@babel/preset-env', + "@babel/preset-env", { targets: { - node: '10.13.0', + node: "10.13.0", }, }, ], ], overrides: [ { - test: './src/runtime', + test: "./src/runtime", presets: [ [ - '@babel/preset-env', + "@babel/preset-env", { targets: { - node: '0.12', + node: "0.12", }, }, ], diff --git a/commitlint.config.js b/commitlint.config.js index 84dcb122..69b4242c 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1,3 @@ module.exports = { - extends: ['@commitlint/config-conventional'], + extends: ["@commitlint/config-conventional"], }; diff --git a/husky.config.js b/husky.config.js index 4c2ec3ae..6cf9b3fc 100644 --- a/husky.config.js +++ b/husky.config.js @@ -1,6 +1,6 @@ module.exports = { hooks: { - 'pre-commit': 'lint-staged', - 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS', + "pre-commit": "lint-staged", + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", }, }; diff --git a/jest.config.js b/jest.config.js index 25c9bac5..5da099d9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,3 @@ module.exports = { - testEnvironment: 'node', + testEnvironment: "node", }; diff --git a/lint-staged.config.js b/lint-staged.config.js index c417cb1b..dc1bf519 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,4 +1,4 @@ module.exports = { - '*.js': ['prettier --write', 'eslint --fix'], - '*.{json,md,yml,css,ts}': ['prettier --write'], + "*.js": ["eslint --fix", "prettier --write"], + "*.{json,md,yml,css,ts}": ["prettier --write"], }; diff --git a/package-lock.json b/package-lock.json index 74f45b16..30e2f212 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2262,9 +2262,9 @@ } }, "@types/babel__template": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.0.3.tgz", - "integrity": "sha512-uCoznIPDmnickEi6D0v11SBpW0OuVqHJCa7syXqQHy5uktSCreIlt0iglsCnmvz8yCb38hGcWeseA8cWJSwv5Q==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.0.tgz", + "integrity": "sha512-NTPErx4/FiPCGScH7foPyr+/1Dkzkni+rHiYHHoTjvwou7AQzJkNeD60A9CXRy+ZEN2B1bggmkTMCDb+Mv5k+A==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -2367,15 +2367,15 @@ "dev": true }, "@types/minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.1.tgz", + "integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==", "dev": true }, "@types/node": { - "version": "14.14.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.6.tgz", - "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==", + "version": "14.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz", + "integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==", "dev": true }, "@types/normalize-package-data": { @@ -3349,15 +3349,16 @@ "dev": true }, "browserslist": { - "version": "4.14.6", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.6.tgz", - "integrity": "sha512-zeFYcUo85ENhc/zxHbiIp0LGzzTrE2Pv2JhxvS7kpUb9Q9D38kUX6Bie7pGutJ/5iF5rOxE7CepAuWD56xJ33A==", + "version": "4.14.7", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.7.tgz", + "integrity": "sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30001154", - "electron-to-chromium": "^1.3.585", + "caniuse-lite": "^1.0.30001157", + "colorette": "^1.2.1", + "electron-to-chromium": "^1.3.591", "escalade": "^3.1.1", - "node-releases": "^1.1.65" + "node-releases": "^1.1.66" } }, "bser": { @@ -3441,9 +3442,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001154", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001154.tgz", - "integrity": "sha512-y9DvdSti8NnYB9Be92ddMZQrcOe04kcQtcxtBx4NkB04+qZ+JUWotnXBJTmxlKudhxNTQ3RRknMwNU2YQl/Org==", + "version": "1.0.30001157", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001157.tgz", + "integrity": "sha512-gOerH9Wz2IRZ2ZPdMfBvyOi3cjaz4O4dgNwPGzx8EhqAs4+2IL/O+fJsbt+znSigujoZG8bVcIAUM/I/E5K3MA==", "dev": true }, "caporal": { @@ -3919,9 +3920,9 @@ } }, "conventional-changelog-angular": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.11.tgz", - "integrity": "sha512-nSLypht/1yEflhuTogC03i7DX7sOrXGsRn14g131Potqi6cbGbGEE9PSDEHKldabB6N76HiSyw9Ph+kLmC04Qw==", + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.12.tgz", + "integrity": "sha512-5GLsbnkR/7A89RyHLvvoExbiGbd9xKdKqDTrArnPbOqBqG/2wIosu0fHwpeIRI8Tl94MhVNBXcLJZl92ZQ5USw==", "dev": true, "requires": { "compare-func": "^2.0.0", @@ -3929,18 +3930,18 @@ } }, "conventional-changelog-atom": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-2.0.7.tgz", - "integrity": "sha512-7dOREZwzB+tCEMjRTDfen0OHwd7vPUdmU0llTy1eloZgtOP4iSLVzYIQqfmdRZEty+3w5Jz+AbhfTJKoKw1JeQ==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-2.0.8.tgz", + "integrity": "sha512-xo6v46icsFTK3bb7dY/8m2qvc8sZemRgdqLb/bjpBsH2UyOS8rKNTgcb5025Hri6IpANPApbXMg15QLb1LJpBw==", "dev": true, "requires": { "q": "^1.5.1" } }, "conventional-changelog-codemirror": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-2.0.7.tgz", - "integrity": "sha512-Oralk1kiagn3Gb5cR5BffenWjVu59t/viE6UMD/mQa1hISMPkMYhJIqX+CMeA1zXgVBO+YHQhhokEj99GP5xcg==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-2.0.8.tgz", + "integrity": "sha512-z5DAsn3uj1Vfp7po3gpt2Boc+Bdwmw2++ZHa5Ak9k0UKsYAO5mH1UBTN0qSCuJZREIhX6WU4E1p3IW2oRCNzQw==", "dev": true, "requires": { "q": "^1.5.1" @@ -3953,9 +3954,9 @@ "dev": true }, "conventional-changelog-conventionalcommits": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.4.0.tgz", - "integrity": "sha512-ybvx76jTh08tpaYrYn/yd0uJNLt5yMrb1BphDe4WBredMlvPisvMghfpnJb6RmRNcqXeuhR6LfGZGewbkRm9yA==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.5.0.tgz", + "integrity": "sha512-buge9xDvjjOxJlyxUnar/+6i/aVEVGA7EEh4OafBCXPlLUQPGbRUBhBUveWRxzvR8TEjhKEP4BdepnpG2FSZXw==", "dev": true, "requires": { "compare-func": "^2.0.0", @@ -3964,26 +3965,26 @@ } }, "conventional-changelog-core": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.2.0.tgz", - "integrity": "sha512-8+xMvN6JvdDtPbGBqA7oRNyZD4od1h/SIzrWqHcKZjitbVXrFpozEeyn4iI4af1UwdrabQpiZMaV07fPUTGd4w==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.2.1.tgz", + "integrity": "sha512-8cH8/DEoD3e5Q6aeogdR5oaaKs0+mG6+f+Om0ZYt3PNv7Zo0sQhu4bMDRsqAF+UTekTAtP1W/C41jH/fkm8Jtw==", "dev": true, "requires": { "add-stream": "^1.0.0", - "conventional-changelog-writer": "^4.0.17", - "conventional-commits-parser": "^3.1.0", + "conventional-changelog-writer": "^4.0.18", + "conventional-commits-parser": "^3.2.0", "dateformat": "^3.0.0", "get-pkg-repo": "^1.0.0", "git-raw-commits": "2.0.0", "git-remote-origin-url": "^2.0.0", - "git-semver-tags": "^4.1.0", + "git-semver-tags": "^4.1.1", "lodash": "^4.17.15", - "normalize-package-data": "^2.3.5", + "normalize-package-data": "^3.0.0", "q": "^1.5.1", "read-pkg": "^3.0.0", "read-pkg-up": "^3.0.0", "shelljs": "^0.8.3", - "through2": "^3.0.0" + "through2": "^4.0.0" }, "dependencies": { "camelcase": { @@ -4046,6 +4047,12 @@ } } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "indent-string": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", @@ -4095,6 +4102,20 @@ "read-pkg-up": "^3.0.0", "redent": "^2.0.0", "trim-newlines": "^2.0.0" + }, + "dependencies": { + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + } } }, "minimist-options": { @@ -4177,6 +4198,20 @@ "load-json-file": "^4.0.0", "normalize-package-data": "^2.3.2", "path-type": "^3.0.0" + }, + "dependencies": { + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + } } }, "read-pkg-up": { @@ -4199,6 +4234,12 @@ "strip-indent": "^2.0.0" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "strip-indent": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", @@ -4214,45 +4255,45 @@ } }, "conventional-changelog-ember": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-2.0.8.tgz", - "integrity": "sha512-JEMEcUAMg4Q9yxD341OgWlESQ4gLqMWMXIWWUqoQU8yvTJlKnrvcui3wk9JvnZQyONwM2g1MKRZuAjKxr8hAXA==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-2.0.9.tgz", + "integrity": "sha512-ulzIReoZEvZCBDhcNYfDIsLTHzYHc7awh+eI44ZtV5cx6LVxLlVtEmcO+2/kGIHGtw+qVabJYjdI5cJOQgXh1A==", "dev": true, "requires": { "q": "^1.5.1" } }, "conventional-changelog-eslint": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-3.0.8.tgz", - "integrity": "sha512-5rTRltgWG7TpU1PqgKHMA/2ivjhrB+E+S7OCTvj0zM/QGg4vmnVH67Vq/EzvSNYtejhWC+OwzvDrLk3tqPry8A==", + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-3.0.9.tgz", + "integrity": "sha512-6NpUCMgU8qmWmyAMSZO5NrRd7rTgErjrm4VASam2u5jrZS0n38V7Y9CzTtLT2qwz5xEChDR4BduoWIr8TfwvXA==", "dev": true, "requires": { "q": "^1.5.1" } }, "conventional-changelog-express": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-2.0.5.tgz", - "integrity": "sha512-pW2hsjKG+xNx/Qjof8wYlAX/P61hT5gQ/2rZ2NsTpG+PgV7Rc8RCfITvC/zN9K8fj0QmV6dWmUefCteD9baEAw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-2.0.6.tgz", + "integrity": "sha512-SDez2f3iVJw6V563O3pRtNwXtQaSmEfTCaTBPCqn0oG0mfkq0rX4hHBq5P7De2MncoRixrALj3u3oQsNK+Q0pQ==", "dev": true, "requires": { "q": "^1.5.1" } }, "conventional-changelog-jquery": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-3.0.10.tgz", - "integrity": "sha512-QCW6wF8QgPkq2ruPaxc83jZxoWQxLkt/pNxIDn/oYjMiVgrtqNdd7lWe3vsl0hw5ENHNf/ejXuzDHk6suKsRpg==", + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-3.0.11.tgz", + "integrity": "sha512-x8AWz5/Td55F7+o/9LQ6cQIPwrCjfJQ5Zmfqi8thwUEKHstEn4kTIofXub7plf1xvFA2TqhZlq7fy5OmV6BOMw==", "dev": true, "requires": { "q": "^1.5.1" } }, "conventional-changelog-jshint": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-2.0.8.tgz", - "integrity": "sha512-hB/iI0IiZwnZ+seYI+qEQ4b+EMQSEC8jGIvhO2Vpz1E5p8FgLz75OX8oB1xJWl+s4xBMB6f8zJr0tC/BL7YOjw==", + "version": "2.0.9", + "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-2.0.9.tgz", + "integrity": "sha512-wMLdaIzq6TNnMHMy31hql02OEQ8nCQfExw1SE0hYL5KvU+JCTuPaDO+7JiogGT2gJAxiUGATdtYYfh+nT+6riA==", "dev": true, "requires": { "compare-func": "^2.0.0", @@ -4266,21 +4307,21 @@ "dev": true }, "conventional-changelog-writer": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.17.tgz", - "integrity": "sha512-IKQuK3bib/n032KWaSb8YlBFds+aLmzENtnKtxJy3+HqDq5kohu3g/UdNbIHeJWygfnEbZjnCKFxAW0y7ArZAw==", + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-4.0.18.tgz", + "integrity": "sha512-mAQDCKyB9HsE8Ko5cCM1Jn1AWxXPYV0v8dFPabZRkvsiWUul2YyAqbIaoMKF88Zf2ffnOPSvKhboLf3fnjo5/A==", "dev": true, "requires": { "compare-func": "^2.0.0", - "conventional-commits-filter": "^2.0.6", + "conventional-commits-filter": "^2.0.7", "dateformat": "^3.0.0", "handlebars": "^4.7.6", "json-stringify-safe": "^5.0.1", "lodash": "^4.17.15", - "meow": "^7.0.0", + "meow": "^8.0.0", "semver": "^6.0.0", "split": "^1.0.0", - "through2": "^3.0.0" + "through2": "^4.0.0" }, "dependencies": { "semver": { @@ -4292,9 +4333,9 @@ } }, "conventional-commits-filter": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-2.0.6.tgz", - "integrity": "sha512-4g+sw8+KA50/Qwzfr0hL5k5NWxqtrOVw4DDk3/h6L85a9Gz0/Eqp3oP+CWCNfesBvZZZEFHF7OTEbRe+yYSyKw==", + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-2.0.7.tgz", + "integrity": "sha512-ASS9SamOP4TbCClsRHxIHXRfcGCnIoQqkvAzCSbZzTFLfcTqJVugB0agRgsEELsqaeWgsXv513eS116wnlSSPA==", "dev": true, "requires": { "lodash.ismatch": "^4.4.0", @@ -4302,17 +4343,17 @@ } }, "conventional-commits-parser": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.1.0.tgz", - "integrity": "sha512-RSo5S0WIwXZiRxUGTPuYFbqvrR4vpJ1BDdTlthFgvHt5kEdnd1+pdvwWphWn57/oIl4V72NMmOocFqqJ8mFFhA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-3.2.0.tgz", + "integrity": "sha512-XmJiXPxsF0JhAKyfA2Nn+rZwYKJ60nanlbSWwwkGwLQFbugsc0gv1rzc7VbbUWAzJfR1qR87/pNgv9NgmxtBMQ==", "dev": true, "requires": { "JSONStream": "^1.0.4", "is-text-path": "^1.0.1", "lodash": "^4.17.15", - "meow": "^7.0.0", + "meow": "^8.0.0", "split2": "^2.0.0", - "through2": "^3.0.0", + "through2": "^4.0.0", "trim-off-newlines": "^1.0.0" } }, @@ -4411,6 +4452,12 @@ } } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "indent-string": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", @@ -4445,6 +4492,198 @@ "integrity": "sha1-plzSkIepJZi4eRJXpSPgISIqwfk=", "dev": true }, + "meow": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/meow/-/meow-7.1.1.tgz", + "integrity": "sha512-GWHvA5QOcS412WCo8vwKDlTelGLsCGBVevQB5Kva961rmNfun0PCbv5+xta2kUMFJyR8/oWnn7ddeKdosbAPbA==", + "dev": true, + "requires": { + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.0", + "normalize-package-data": "^2.5.0", + "read-pkg-up": "^7.0.1", + "redent": "^3.0.0", + "trim-newlines": "^3.0.0", + "type-fest": "^0.13.1", + "yargs-parser": "^18.1.3" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "camelcase-keys": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", + "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "map-obj": "^4.0.0", + "quick-lru": "^4.0.1" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "map-obj": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.1.0.tgz", + "integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==", + "dev": true + }, + "minimist-options": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", + "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", + "dev": true, + "requires": { + "arrify": "^1.0.1", + "is-plain-obj": "^1.1.0", + "kind-of": "^6.0.3" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-json": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.1.0.tgz", + "integrity": "sha512-+mi/lmVVNKFNVyLXV31ERiy2CY5E1/F6QtJFEzoChPRwwngMNXRDQ9GJ5WdE2Z2P4AujsOi0/+2qHID68KwfIQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "quick-lru": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", + "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "dev": true + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, + "read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + }, + "dependencies": { + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + } + } + }, + "redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "requires": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + } + }, + "strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "requires": { + "min-indent": "^1.0.0" + } + }, + "trim-newlines": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.0.tgz", + "integrity": "sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==", + "dev": true + } + } + }, "minimist-options": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-3.0.2.tgz", @@ -4455,6 +4694,18 @@ "is-plain-obj": "^1.1.0" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -4558,6 +4809,12 @@ "strip-indent": "^2.0.0" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "strip-indent": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-2.0.0.tgz", @@ -4596,6 +4853,30 @@ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=", "dev": true + }, + "type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + } + } } } }, @@ -4615,18 +4896,18 @@ "dev": true }, "core-js": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz", - "integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.7.0.tgz", + "integrity": "sha512-NwS7fI5M5B85EwpWuIwJN4i/fbisQUwLwiSNUWeXlkAZ0sbBjLEvLvFLf1uzAUV66PcEPt4xCGCmOZSxVf3xzA==", "dev": true }, "core-js-compat": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.6.5.tgz", - "integrity": "sha512-7ItTKOhOZbznhXAQ2g/slGg1PJV5zDO/WdkTwi7UEOJmkvsE32PWvx6mKtDjiMpjnR2CNf6BAD6sSxIlv7ptng==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.7.0.tgz", + "integrity": "sha512-V8yBI3+ZLDVomoWICO6kq/CD28Y4r1M7CWeO4AGpMdMfseu8bkSubBmUPySMGKRTS+su4XQ07zUkAsiu9FCWTg==", "dev": true, "requires": { - "browserslist": "^4.8.5", + "browserslist": "^4.14.6", "semver": "7.0.0" }, "dependencies": { @@ -5102,6 +5383,12 @@ "meow": "^6.1.1" }, "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, "del": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/del/-/del-5.1.0.tgz", @@ -5134,6 +5421,12 @@ "slash": "^3.0.0" } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "meow": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/meow/-/meow-6.1.1.tgz", @@ -5153,6 +5446,18 @@ "yargs-parser": "^18.1.3" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "p-map": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", @@ -5162,11 +5467,33 @@ "aggregate-error": "^3.0.0" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true + }, + "type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -5318,18 +5645,34 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, + "lru-cache": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "dev": true, + "requires": { + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" + } + }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true } } }, "electron-to-chromium": { - "version": "1.3.587", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.587.tgz", - "integrity": "sha512-8XFNxzNj0R8HpTQslWAw6UWpGSuOKSP3srhyFHVbGUGb8vTHckZGCyWi+iQlaXJx5DNeTQTQLd6xN11WSckkmA==", + "version": "1.3.595", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.595.tgz", + "integrity": "sha512-JpaBIhdBkF9FLG7x06ONfe0f5bxPrxRcq0X+Sc8vsCt+OPWIzxOD+qM71NEHLGbDfN9Q6hbtHRv4/dnvcOxo6g==", "dev": true }, "emittery": { @@ -5510,9 +5853,9 @@ } }, "eslint": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.12.1.tgz", - "integrity": "sha512-HlMTEdr/LicJfN08LB3nM1rRYliDXOmfoO4vj39xN6BLpFzF00hbwBoqHk8UcJ2M/3nlARZWy/mslvGEuZFvsg==", + "version": "7.13.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.13.0.tgz", + "integrity": "sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -5774,6 +6117,12 @@ "locate-path": "^2.0.0" } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", @@ -5784,6 +6133,18 @@ "path-exists": "^3.0.0" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -5849,6 +6210,12 @@ "find-up": "^2.0.0", "read-pkg": "^2.0.0" } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true } } }, @@ -6598,6 +6965,12 @@ "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", "dev": true }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", @@ -6644,6 +7017,18 @@ "trim-newlines": "^1.0.0" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -6710,6 +7095,12 @@ "strip-indent": "^1.0.1" } }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", @@ -6799,16 +7190,16 @@ } }, "git-raw-commits": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.7.tgz", - "integrity": "sha512-SkwrTqrDxw8y0G1uGJ9Zw13F7qu3LF8V4BifyDeiJCxSnjRGZD9SaoMiMqUvvXMXh6S3sOQ1DsBN7L2fMUZW/g==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-2.0.8.tgz", + "integrity": "sha512-6Gk7tQHGMLEL1bSnrMJTCVt2AQl4EmCcJDtzs/JJacCb2+TNEyHM67Gp7Ri9faF7OcGpjGGRjHLvs/AG7QKZ2Q==", "dev": true, "requires": { "dargs": "^7.0.0", "lodash.template": "^4.0.2", - "meow": "^7.0.0", + "meow": "^8.0.0", "split2": "^2.0.0", - "through2": "^3.0.0" + "through2": "^4.0.0" } }, "git-remote-origin-url": { @@ -6830,12 +7221,12 @@ } }, "git-semver-tags": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.1.0.tgz", - "integrity": "sha512-TcxAGeo03HdErzKzi4fDD+xEL7gi8r2Y5YSxH6N2XYdVSV5UkBwfrt7Gqo1b+uSHCjy/sa9Y6BBBxxFLxfbhTg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-4.1.1.tgz", + "integrity": "sha512-OWyMt5zBe7xFs8vglMmhM9lRQzCWL3WjHtxNNfJTMngGym7pC1kh8sP6jevfydJ6LP3ZvGxfb6ABYgPUM0mtsA==", "dev": true, "requires": { - "meow": "^7.0.0", + "meow": "^8.0.0", "semver": "^6.0.0" }, "dependencies": { @@ -7088,10 +7479,13 @@ } }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", - "dev": true + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.7.tgz", + "integrity": "sha512-fWqc0IcuXs+BmE9orLDyVykAG9GJtGLGuZAAqgcckPgv5xad4AcXGIv8galtQvlwutxSlaMcdw7BUtq2EIvqCQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } }, "html-encoding-sniffer": { "version": "2.0.1", @@ -7468,9 +7862,9 @@ } }, "is-core-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.0.0.tgz", - "integrity": "sha512-jq1AH6C8MuteOoBPwkxHafmByhL9j5q4OaPGdbuD+ZtQJVzH+i6E3BJDQcBA09k57i2Hh2yQbEG8yObZ0jdlWw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.1.0.tgz", + "integrity": "sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA==", "dev": true, "requires": { "has": "^1.0.3" @@ -8374,9 +8768,9 @@ } }, "fsevents": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.2.0.tgz", - "integrity": "sha512-pKnaUh2TNvk+/egJdBw1h46LwyLx8BzEq+MGCf/RMCVfEHHsGOCWG00dqk91kUPPArIIwMBg9T/virxwzP03cA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.2.1.tgz", + "integrity": "sha512-bTLYHSeC0UH/EFXS9KqWnXuOl/wHK5Z/d+ghd5AsFMYN7wIGkUCOJyzy88+wJKkZPGON8u4Z9f6U4FdgURE9qA==", "dev": true, "optional": true }, @@ -9525,9 +9919,9 @@ } }, "less-loader": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-7.0.2.tgz", - "integrity": "sha512-7MKlgjnkCf63E3Lv6w2FvAEgLMx3d/tNBExITcanAq7ys5U8VPWT3F6xcRjYmdNfkoQ9udoVFb1r2azSiTnD6w==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/less-loader/-/less-loader-7.1.0.tgz", + "integrity": "sha512-EHbnRaTzHgsxnd3RK6OXSiygcCJs72+2ezXVLg+Hgl/ijUTtthKZXZh4MvQkWJr3h/SSKvxGZr7IIHzuS2KbVQ==", "dev": true, "requires": { "klona": "^2.0.4", @@ -10179,13 +10573,12 @@ } }, "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" + "yallist": "^4.0.0" } }, "make-dir": { @@ -10252,9 +10645,9 @@ "dev": true }, "meow": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/meow/-/meow-7.1.1.tgz", - "integrity": "sha512-GWHvA5QOcS412WCo8vwKDlTelGLsCGBVevQB5Kva961rmNfun0PCbv5+xta2kUMFJyR8/oWnn7ddeKdosbAPbA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-8.0.0.tgz", + "integrity": "sha512-nbsTRz2fwniJBFgUkcdISq8y/q9n9VbiHYbfwklFh5V4V2uAcxtKQkDc0yCLPM/kP0d+inZBewn3zJqewHE7kg==", "dev": true, "requires": { "@types/minimist": "^1.2.0", @@ -10262,12 +10655,12 @@ "decamelize-keys": "^1.1.0", "hard-rejection": "^2.1.0", "minimist-options": "4.1.0", - "normalize-package-data": "^2.5.0", + "normalize-package-data": "^3.0.0", "read-pkg-up": "^7.0.1", "redent": "^3.0.0", "trim-newlines": "^3.0.0", - "type-fest": "^0.13.1", - "yargs-parser": "^18.1.3" + "type-fest": "^0.18.0", + "yargs-parser": "^20.2.3" } }, "merge-stream": { @@ -10347,9 +10740,9 @@ "dev": true }, "mini-css-extract-plugin": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-1.2.1.tgz", - "integrity": "sha512-G3yw7/TQaPfkuiR73MDcyiqhyP8SnbmLhUbpC76H+wtQxA6wfKhMCQOCb6wnPK0dQbjORAeOILQqEesg4/wF7A==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-1.3.1.tgz", + "integrity": "sha512-jIOheqh9EU98rqj6ZaFTYNNDSFqdakNqaUZfkYwaXPjI9batmXVXX+K71NrqRAgtoGefELBMld1EQ7dqSAD5SQ==", "dev": true, "requires": { "loader-utils": "^2.0.0", @@ -10620,29 +11013,21 @@ } }, "node-releases": { - "version": "1.1.65", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.65.tgz", - "integrity": "sha512-YpzJOe2WFIW0V4ZkJQd/DGR/zdVwc/pI4Nl1CZrBO19FdRcSTmsuhdttw9rsTzzJLrNcSloLiBbEYx1C4f6gpA==", + "version": "1.1.66", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.66.tgz", + "integrity": "sha512-JHEQ1iWPGK+38VLB2H9ef2otU4l8s3yAMt9Xf934r6+ojCYDMHPMqvCc9TnzfeFSP1QEOeU6YZEd3+De0LTCgg==", "dev": true }, "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.0.tgz", + "integrity": "sha512-6lUjEI0d3v6kFrtgA/lOx4zHCWULXsFNIjHolnZCKCTLA6m/G625cdn3O7eNmT0iD3jfo6HZ9cdImGZwf21prw==", "dev": true, "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", + "hosted-git-info": "^3.0.6", + "resolve": "^1.17.0", + "semver": "^7.3.2", "validate-npm-package-license": "^3.0.1" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } } }, "normalize-path": { @@ -10674,6 +11059,12 @@ "string.prototype.padend": "^3.0.0" }, "dependencies": { + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", @@ -10686,6 +11077,18 @@ "strip-bom": "^3.0.0" } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -10721,6 +11124,12 @@ "normalize-package-data": "^2.3.2", "path-type": "^3.0.0" } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true } } }, @@ -11208,13 +11617,13 @@ "dev": true }, "postcss": { - "version": "8.1.4", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.1.4.tgz", - "integrity": "sha512-LfqcwgMq9LOd8pX7K2+r2HPitlIGC5p6PoZhVELlqhh2YGDVcXKpkCseqan73Hrdik6nBd2OvoDPUaP/oMj9hQ==", + "version": "8.1.7", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.1.7.tgz", + "integrity": "sha512-llCQW1Pz4MOPwbZLmOddGM9eIJ8Bh7SZ2Oj5sxZva77uVaotYDsYTch1WBTNu7fUY0fpWp0fdt7uW40D4sRiiQ==", "requires": { "colorette": "^1.2.1", "line-column": "^1.0.2", - "nanoid": "^3.1.15", + "nanoid": "^3.1.16", "source-map": "^0.6.1" } }, @@ -12517,6 +12926,30 @@ "type-fest": "^0.6.0" }, "dependencies": { + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "type-fest": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", @@ -12809,12 +13242,12 @@ "dev": true }, "resolve": { - "version": "1.18.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", - "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", "dev": true, "requires": { - "is-core-module": "^2.0.0", + "is-core-module": "^2.1.0", "path-parse": "^1.0.6" } }, @@ -12951,18 +13384,18 @@ } }, "sass": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.28.0.tgz", - "integrity": "sha512-9FWX/0wuE1KxwfiP02chZhHaPzu6adpx9+wGch7WMOuHy5npOo0UapRI3FNSHva2CczaYJu2yNUBN8cCSqHz/A==", + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.29.0.tgz", + "integrity": "sha512-ZpwAUFgnvAUCdkjwPREny+17BpUj8nh5Yr6zKPGtLNTLrmtoRYIjm7njP24COhjJldjwW1dcv52Lpf4tNZVVRA==", "dev": true, "requires": { "chokidar": ">=2.0.0 <4.0.0" } }, "sass-loader": { - "version": "10.0.5", - "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-10.0.5.tgz", - "integrity": "sha512-2LqoNPtKkZq/XbXNQ4C64GFEleSEHKv6NPSI+bMC/l+jpEXGJhiRYkAQToO24MR7NU4JRY2RpLpJ/gjo2Uf13w==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/sass-loader/-/sass-loader-10.1.0.tgz", + "integrity": "sha512-ZCKAlczLBbFd3aGAhowpYEy69Te3Z68cg8bnHHl6WnSCvnKpbM6pQrz957HWMa8LKVuhnD9uMplmMAHwGQtHeg==", "dev": true, "requires": { "klona": "^2.0.4", @@ -13458,6 +13891,17 @@ "yargs": "^15.3.1" }, "dependencies": { + "conventional-changelog-conventionalcommits": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.4.0.tgz", + "integrity": "sha512-ybvx76jTh08tpaYrYn/yd0uJNLt5yMrb1BphDe4WBredMlvPisvMghfpnJb6RmRNcqXeuhR6LfGZGewbkRm9yA==", + "dev": true, + "requires": { + "compare-func": "^2.0.0", + "lodash": "^4.17.15", + "q": "^1.5.1" + } + }, "detect-indent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.0.0.tgz", @@ -13735,9 +14179,9 @@ } }, "stylus-loader": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/stylus-loader/-/stylus-loader-4.2.0.tgz", - "integrity": "sha512-n2zrq+rwUcK3DMX396XoxUYoQE+2DatqMId9RId79hOEYI7DVzsMKlQHcH7jkezvAD22SIks3YxgDhPUoRZ8ZQ==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/stylus-loader/-/stylus-loader-4.3.0.tgz", + "integrity": "sha512-S6j5Onp4AJJIXZomHYknFEnV6/4zhPoEKxMPu0iExPgJLlGO7CeBGu+xpYCup1hiZmDBnC3BKRswADKN9goLfw==", "dev": true, "requires": { "fast-glob": "^3.2.4", @@ -13858,9 +14302,9 @@ } }, "tapable": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.0.0.tgz", - "integrity": "sha512-bjzn0C0RWoffnNdTzNi7rNDhs1Zlwk2tRXgk8EiHKAOX1Mag3d6T0Y5zNa7l9CJ+EoUne/0UHdwS8tMbkh9zDg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.1.1.tgz", + "integrity": "sha512-Wib1S8m2wdpLbmQz0RBEVosIyvb/ykfKXf3ZIDqvWoMg/zTNm6G/tDSuUM61J1kNCDXWJrLHGSFeMhAG+gAGpQ==", "dev": true }, "terminal-link": { @@ -13976,13 +14420,25 @@ "dev": true }, "through2": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz", - "integrity": "sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", "dev": true, "requires": { - "inherits": "^2.0.4", - "readable-stream": "2 || 3" + "readable-stream": "3" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "tmp": { @@ -14140,9 +14596,9 @@ "dev": true }, "type-fest": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", - "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz", + "integrity": "sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==", "dev": true }, "typedarray": { @@ -14636,9 +15092,9 @@ } }, "ws": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", - "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz", + "integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==", "dev": true }, "xml-name-validator": { @@ -14666,9 +15122,9 @@ "dev": true }, "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, "yaml": { @@ -14694,16 +15150,6 @@ "which-module": "^2.0.0", "y18n": "^4.0.0", "yargs-parser": "^18.1.2" - } - }, - "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" }, "dependencies": { "camelcase": { @@ -14711,8 +15157,24 @@ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true } } } diff --git a/package.json b/package.json index e6fe4566..7ca56d06 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "cssesc": "^3.0.0", "icss-utils": "^5.0.0", "loader-utils": "^2.0.0", - "postcss": "^8.1.4", + "postcss": "^8.1.7", "postcss-modules-extract-imports": "^3.0.0", "postcss-modules-local-by-default": "^4.0.0", "postcss-modules-scope": "^3.0.0", @@ -69,28 +69,28 @@ "del": "^6.0.0", "del-cli": "^3.0.1", "es-check": "^5.1.2", - "eslint": "^7.12.1", + "eslint": "^7.13.0", "eslint-config-prettier": "^6.15.0", "eslint-plugin-import": "^2.22.1", "file-loader": "^6.2.0", "husky": "^4.3.0", "jest": "^26.6.3", "less": "^3.12.2", - "less-loader": "^7.0.2", + "less-loader": "^7.1.0", "lint-staged": "^10.5.1", "memfs": "^3.2.0", - "mini-css-extract-plugin": "^1.2.1", + "mini-css-extract-plugin": "^1.3.1", "npm-run-all": "^4.1.5", "postcss-loader": "^4.0.4", "postcss-preset-env": "^6.7.0", "prettier": "^2.1.2", - "sass": "^1.28.0", - "sass-loader": "^10.0.5", + "sass": "^1.29.0", + "sass-loader": "^10.1.0", "standard-version": "^9.0.0", "strip-ansi": "^6.0.0", "style-loader": "^2.0.0", "stylus": "^0.54.8", - "stylus-loader": "^4.2.0", + "stylus-loader": "^4.3.0", "url-loader": "^4.1.1", "webpack": "^5.4.0" }, diff --git a/src/CssSyntaxError.js b/src/CssSyntaxError.js index e39eb82d..385ef929 100644 --- a/src/CssSyntaxError.js +++ b/src/CssSyntaxError.js @@ -4,17 +4,17 @@ export default class CssSyntaxError extends Error { const { reason, line, column, file } = error; - this.name = 'CssSyntaxError'; + this.name = "CssSyntaxError"; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132 // We don't need `plugin` and `file` properties. this.message = `${this.name}\n\n`; - if (typeof line !== 'undefined') { + if (typeof line !== "undefined") { this.message += `(${line}:${column}) `; } - this.message += file ? `${file} ` : ' '; + this.message += file ? `${file} ` : " "; this.message += `${reason}`; const code = error.showSourceCode(); diff --git a/src/Warning.js b/src/Warning.js index 93b86399..f3b18c7a 100644 --- a/src/Warning.js +++ b/src/Warning.js @@ -2,13 +2,13 @@ export default class Warning extends Error { constructor(warning) { super(warning); const { text, line, column } = warning; - this.name = 'Warning'; + this.name = "Warning"; // Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74 // We don't need `plugin` properties. this.message = `${this.name}\n\n`; - if (typeof line !== 'undefined') { + if (typeof line !== "undefined") { this.message += `(${line}:${column}) `; } diff --git a/src/cjs.js b/src/cjs.js index 90fe4df1..e45ad5d1 100644 --- a/src/cjs.js +++ b/src/cjs.js @@ -1,3 +1,3 @@ -const loader = require('./index'); +const loader = require("./index"); module.exports = loader.default; diff --git a/src/index.js b/src/index.js index c8a647cb..8cd1f7bc 100644 --- a/src/index.js +++ b/src/index.js @@ -2,16 +2,16 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -import { getOptions, stringifyRequest } from 'loader-utils'; -import postcss from 'postcss'; -import postcssPkg from 'postcss/package.json'; -import { validate } from 'schema-utils'; -import { satisfies } from 'semver'; - -import CssSyntaxError from './CssSyntaxError'; -import Warning from './Warning'; -import schema from './options.json'; -import { icssParser, importParser, urlParser } from './plugins'; +import { getOptions, stringifyRequest } from "loader-utils"; +import postcss from "postcss"; +import postcssPkg from "postcss/package.json"; +import { validate } from "schema-utils"; +import { satisfies } from "semver"; + +import CssSyntaxError from "./CssSyntaxError"; +import Warning from "./Warning"; +import schema from "./options.json"; +import { icssParser, importParser, urlParser } from "./plugins"; import { normalizeOptions, shouldUseModulesPlugins, @@ -26,14 +26,14 @@ import { getModulesPlugins, normalizeSourceMap, sort, -} from './utils'; +} from "./utils"; export default async function loader(content, map, meta) { const rawOptions = getOptions(this); validate(schema, rawOptions, { - name: 'CSS Loader', - baseDataPath: 'options', + name: "CSS Loader", + baseDataPath: "options", }); const plugins = []; @@ -61,10 +61,10 @@ export default async function loader(content, map, meta) { if (shouldUseImportPlugin(options)) { const resolver = this.getResolve({ - conditionNames: ['style'], - extensions: ['.css'], - mainFields: ['css', 'style', 'main', '...'], - mainFiles: ['index', '...'], + conditionNames: ["style"], + extensions: [".css"], + mainFields: ["css", "style", "main", "..."], + mainFiles: ["index", "..."], restrictions: [/\.css$/i], }); @@ -89,8 +89,8 @@ export default async function loader(content, map, meta) { if (shouldUseURLPlugin(options)) { const urlResolver = this.getResolve({ - conditionNames: ['asset'], - mainFields: ['asset'], + conditionNames: ["asset"], + mainFields: ["asset"], mainFiles: [], extensions: [], }); @@ -113,10 +113,10 @@ export default async function loader(content, map, meta) { if (shouldUseIcssPlugin(options)) { const icssResolver = this.getResolve({ - conditionNames: ['style'], + conditionNames: ["style"], extensions: [], - mainFields: ['css', 'style', 'main', '...'], - mainFiles: ['index', '...'], + mainFields: ["css", "style", "main", "..."], + mainFiles: ["index", "..."], }); plugins.push( @@ -143,7 +143,7 @@ export default async function loader(content, map, meta) { if ( ast && - ast.type === 'postcss' && + ast.type === "postcss" && satisfies(ast.version, `^${postcssPkg.version}`) ) { // eslint-disable-next-line no-param-reassign @@ -174,7 +174,7 @@ export default async function loader(content, map, meta) { } callback( - error.name === 'CssSyntaxError' ? new CssSyntaxError(error) : error + error.name === "CssSyntaxError" ? new CssSyntaxError(error) : error ); return; @@ -194,16 +194,16 @@ export default async function loader(content, map, meta) { if (options.modules.exportOnlyLocals !== true) { imports.unshift({ - importName: '___CSS_LOADER_API_IMPORT___', - url: stringifyRequest(this, require.resolve('./runtime/api')), + importName: "___CSS_LOADER_API_IMPORT___", + url: stringifyRequest(this, require.resolve("./runtime/api")), }); if (options.sourceMap) { imports.unshift({ - importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___', + importName: "___CSS_LOADER_API_SOURCEMAP_IMPORT___", url: stringifyRequest( this, - require.resolve('./runtime/cssWithMappingToString') + require.resolve("./runtime/cssWithMappingToString") ), }); } diff --git a/src/plugins/index.js b/src/plugins/index.js index 21e47631..22e1bf60 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -1,5 +1,5 @@ -import importParser from './postcss-import-parser'; -import icssParser from './postcss-icss-parser'; -import urlParser from './postcss-url-parser'; +import importParser from "./postcss-import-parser"; +import icssParser from "./postcss-icss-parser"; +import urlParser from "./postcss-url-parser"; export { importParser, icssParser, urlParser }; diff --git a/src/plugins/postcss-icss-parser.js b/src/plugins/postcss-icss-parser.js index 7e77d703..c1bdb55c 100644 --- a/src/plugins/postcss-icss-parser.js +++ b/src/plugins/postcss-icss-parser.js @@ -1,10 +1,10 @@ -import { extractICSS, replaceValueSymbols, replaceSymbols } from 'icss-utils'; +import { extractICSS, replaceValueSymbols, replaceSymbols } from "icss-utils"; -import { normalizeUrl, resolveRequests, requestify } from '../utils'; +import { normalizeUrl, resolveRequests, requestify } from "../utils"; const plugin = (options = {}) => { return { - postcssPlugin: 'postcss-icss-parser', + postcssPlugin: "postcss-icss-parser", async OnceExit(root) { const importReplacements = Object.create(null); const { icssImports, icssExports } = extractICSS(root); @@ -21,13 +21,13 @@ const plugin = (options = {}) => { } let normalizedUrl = url; - let prefix = ''; + let prefix = ""; - const queryParts = normalizedUrl.split('!'); + const queryParts = normalizedUrl.split("!"); if (queryParts.length > 1) { normalizedUrl = queryParts.pop(); - prefix = queryParts.join('!'); + prefix = queryParts.join("!"); } const request = requestify( diff --git a/src/plugins/postcss-import-parser.js b/src/plugins/postcss-import-parser.js index c7633ec9..b0698a6d 100644 --- a/src/plugins/postcss-import-parser.js +++ b/src/plugins/postcss-import-parser.js @@ -1,15 +1,15 @@ -import valueParser from 'postcss-value-parser'; +import valueParser from "postcss-value-parser"; import { normalizeUrl, resolveRequests, isUrlRequestable, requestify, -} from '../utils'; +} from "../utils"; function visitor(result, parsedResults, node, key) { // Convert only top-level @import - if (node.parent.type !== 'root') { + if (node.parent.type !== "root") { return; } @@ -29,7 +29,7 @@ function visitor(result, parsedResults, node, key) { // Invalid type - `@import foo-bar;` if ( paramsNodes.length === 0 || - (paramsNodes[0].type !== 'string' && paramsNodes[0].type !== 'function') + (paramsNodes[0].type !== "string" && paramsNodes[0].type !== "function") ) { result.warn(`Unable to find uri in "${node.toString()}"`, { node }); @@ -39,12 +39,12 @@ function visitor(result, parsedResults, node, key) { let isStringValue; let url; - if (paramsNodes[0].type === 'string') { + if (paramsNodes[0].type === "string") { isStringValue = true; url = paramsNodes[0].value; } else { // Invalid function - `@import nourl(test.css);` - if (paramsNodes[0].value.toLowerCase() !== 'url') { + if (paramsNodes[0].value.toLowerCase() !== "url") { result.warn(`Unable to find uri in "${node.toString()}"`, { node }); return; @@ -52,7 +52,7 @@ function visitor(result, parsedResults, node, key) { isStringValue = paramsNodes[0].nodes.length !== 0 && - paramsNodes[0].nodes[0].type === 'string'; + paramsNodes[0].nodes[0].type === "string"; url = isStringValue ? paramsNodes[0].nodes[0].value : valueParser.stringify(paramsNodes[0].nodes); @@ -75,14 +75,14 @@ function visitor(result, parsedResults, node, key) { const plugin = (options = {}) => { return { - postcssPlugin: 'postcss-import-parser', + postcssPlugin: "postcss-import-parser", prepare(result) { const parsedResults = []; return { AtRule: { import(atRule) { - visitor(result, parsedResults, atRule, 'params'); + visitor(result, parsedResults, atRule, "params"); }, }, async OnceExit() { @@ -97,16 +97,16 @@ const plugin = (options = {}) => { const { node, url, isStringValue, mediaNodes } = parsedResult; let normalizedUrl = url; - let prefix = ''; + let prefix = ""; const isRequestable = isUrlRequestable(normalizedUrl); if (isRequestable) { - const queryParts = normalizedUrl.split('!'); + const queryParts = normalizedUrl.split("!"); if (queryParts.length > 1) { normalizedUrl = queryParts.pop(); - prefix = queryParts.join('!'); + prefix = queryParts.join("!"); } normalizedUrl = normalizeUrl(normalizedUrl, isStringValue); diff --git a/src/plugins/postcss-url-parser.js b/src/plugins/postcss-url-parser.js index 3816d430..fad11584 100644 --- a/src/plugins/postcss-url-parser.js +++ b/src/plugins/postcss-url-parser.js @@ -1,11 +1,11 @@ -import valueParser from 'postcss-value-parser'; +import valueParser from "postcss-value-parser"; import { normalizeUrl, requestify, resolveRequests, isUrlRequestable, -} from '../utils'; +} from "../utils"; const isUrlFunc = /url/i; const isImageSetFunc = /^(?:-webkit-)?image-set$/i; @@ -17,7 +17,7 @@ function getNodeFromUrlFunc(node) { function shouldHandleRule(rule, node, result) { // https://www.w3.org/TR/css-syntax-3/#typedef-url-token - if (rule.url.replace(/^[\s]+|[\s]+$/g, '').length === 0) { + if (rule.url.replace(/^[\s]+|[\s]+$/g, "").length === 0) { result.warn(`Unable to find uri in '${node.toString()}'`, { node }); return false; @@ -38,13 +38,13 @@ function visitor(result, parsedResults, node, key) { const parsed = valueParser(node[key]); parsed.walk((valueNode) => { - if (valueNode.type !== 'function') { + if (valueNode.type !== "function") { return; } if (isUrlFunc.test(valueNode.value)) { const { nodes } = valueNode; - const isStringValue = nodes.length !== 0 && nodes[0].type === 'string'; + const isStringValue = nodes.length !== 0 && nodes[0].type === "string"; const url = isStringValue ? nodes[0].value : valueParser.stringify(nodes); const rule = { @@ -65,10 +65,10 @@ function visitor(result, parsedResults, node, key) { for (const nNode of valueNode.nodes) { const { type, value } = nNode; - if (type === 'function' && isUrlFunc.test(value)) { + if (type === "function" && isUrlFunc.test(value)) { const { nodes } = nNode; const isStringValue = - nodes.length !== 0 && nodes[0].type === 'string'; + nodes.length !== 0 && nodes[0].type === "string"; const url = isStringValue ? nodes[0].value : valueParser.stringify(nodes); @@ -87,7 +87,7 @@ function visitor(result, parsedResults, node, key) { parsed, }); } - } else if (type === 'string') { + } else if (type === "string") { const rule = { node: nNode, url: value, @@ -114,13 +114,13 @@ function visitor(result, parsedResults, node, key) { const plugin = (options = {}) => { return { - postcssPlugin: 'postcss-url-parser', + postcssPlugin: "postcss-url-parser", prepare(result) { const parsedResults = []; return { Declaration(declaration) { - visitor(result, parsedResults, declaration, 'value'); + visitor(result, parsedResults, declaration, "value"); }, async OnceExit() { if (parsedResults.length === 0) { @@ -137,13 +137,13 @@ const plugin = (options = {}) => { const { url, isStringValue } = parsedResult.rule; let normalizedUrl = url; - let prefix = ''; + let prefix = ""; - const queryParts = normalizedUrl.split('!'); + const queryParts = normalizedUrl.split("!"); if (queryParts.length > 1) { normalizedUrl = queryParts.pop(); - prefix = queryParts.join('!'); + prefix = queryParts.join("!"); } normalizedUrl = normalizeUrl(normalizedUrl, isStringValue); @@ -155,9 +155,9 @@ const plugin = (options = {}) => { if (!hasUrlImportHelper) { options.imports.push({ - importName: '___CSS_LOADER_GET_URL_IMPORT___', + importName: "___CSS_LOADER_GET_URL_IMPORT___", url: options.urlHandler( - require.resolve('../runtime/getUrl.js') + require.resolve("../runtime/getUrl.js") ), index: -1, }); @@ -168,8 +168,8 @@ const plugin = (options = {}) => { const splittedUrl = normalizedUrl.split(/(\?)?#/); const [pathname, query, hashOrQuery] = splittedUrl; - let hash = query ? '?' : ''; - hash += hashOrQuery ? `#${hashOrQuery}` : ''; + let hash = query ? "?" : ""; + hash += hashOrQuery ? `#${hashOrQuery}` : ""; const request = requestify(pathname, options.rootContext); @@ -226,7 +226,7 @@ const plugin = (options = {}) => { } // eslint-disable-next-line no-param-reassign - rule.node.type = 'word'; + rule.node.type = "word"; // eslint-disable-next-line no-param-reassign rule.node.value = replacementName; diff --git a/src/runtime/api.js b/src/runtime/api.js index 6afc3f74..1888424c 100644 --- a/src/runtime/api.js +++ b/src/runtime/api.js @@ -17,15 +17,15 @@ module.exports = function (cssWithMappingToString) { } return content; - }).join(''); + }).join(""); }; // import a list of modules into the list // eslint-disable-next-line func-names list.i = function (modules, mediaQuery, dedupe) { - if (typeof modules === 'string') { + if (typeof modules === "string") { // eslint-disable-next-line no-param-reassign - modules = [[null, modules, '']]; + modules = [[null, modules, ""]]; } const alreadyImportedModules = {}; diff --git a/src/runtime/cssWithMappingToString.js b/src/runtime/cssWithMappingToString.js index 4c8181e9..2a7fda69 100644 --- a/src/runtime/cssWithMappingToString.js +++ b/src/runtime/cssWithMappingToString.js @@ -1,7 +1,7 @@ module.exports = function cssWithMappingToString(item) { const [, content, , cssMapping] = item; - if (typeof btoa === 'function') { + if (typeof btoa === "function") { // eslint-disable-next-line no-undef const base64 = btoa( unescape(encodeURIComponent(JSON.stringify(cssMapping))) @@ -10,11 +10,11 @@ module.exports = function cssWithMappingToString(item) { const sourceMapping = `/*# ${data} */`; const sourceURLs = cssMapping.sources.map( - (source) => `/*# sourceURL=${cssMapping.sourceRoot || ''}${source} */` + (source) => `/*# sourceURL=${cssMapping.sourceRoot || ""}${source} */` ); - return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); + return [content].concat(sourceURLs).concat([sourceMapping]).join("\n"); } - return [content].join('\n'); + return [content].join("\n"); }; diff --git a/src/runtime/getUrl.js b/src/runtime/getUrl.js index 1ae687a3..0d2e0931 100644 --- a/src/runtime/getUrl.js +++ b/src/runtime/getUrl.js @@ -7,7 +7,7 @@ module.exports = (url, options) => { // eslint-disable-next-line no-underscore-dangle, no-param-reassign url = url && url.__esModule ? url.default : url; - if (typeof url !== 'string') { + if (typeof url !== "string") { return url; } @@ -25,7 +25,7 @@ module.exports = (url, options) => { // Should url be wrapped? // See https://drafts.csswg.org/css-values-3/#urls if (/["'() \t\n]/.test(url) || options.needQuotes) { - return `"${url.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`; + return `"${url.replace(/"/g, '\\"').replace(/\n/g, "\\n")}"`; } return url; diff --git a/src/utils.js b/src/utils.js index 2410eb10..a3aa1046 100644 --- a/src/utils.js +++ b/src/utils.js @@ -2,21 +2,21 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -import { fileURLToPath } from 'url'; -import path from 'path'; - -import { urlToRequest, interpolateName } from 'loader-utils'; -import cssesc from 'cssesc'; -import modulesValues from 'postcss-modules-values'; -import localByDefault from 'postcss-modules-local-by-default'; -import extractImports from 'postcss-modules-extract-imports'; -import modulesScope from 'postcss-modules-scope'; -import camelCase from 'camelcase'; - -const whitespace = '[\\x20\\t\\r\\n\\f]'; +import { fileURLToPath } from "url"; +import path from "path"; + +import { urlToRequest, interpolateName } from "loader-utils"; +import cssesc from "cssesc"; +import modulesValues from "postcss-modules-values"; +import localByDefault from "postcss-modules-local-by-default"; +import extractImports from "postcss-modules-extract-imports"; +import modulesScope from "postcss-modules-scope"; +import camelCase from "camelcase"; + +const whitespace = "[\\x20\\t\\r\\n\\f]"; const unescapeRegExp = new RegExp( `\\\\([\\da-f]{1,6}${whitespace}?|(${whitespace})|.)`, - 'ig' + "ig" ); const matchNativeWin32Path = /^[A-Z]:[/\\]|^\\\\/i; @@ -41,7 +41,7 @@ function unescape(str) { } function normalizePath(file) { - return path.sep === '\\' ? file.replace(/\\/g, '/') : file; + return path.sep === "\\" ? file.replace(/\\/g, "/") : file; } // eslint-disable-next-line no-control-regex @@ -53,10 +53,10 @@ function escapeLocalIdent(localident) { return cssesc( localident // For `[hash]` placeholder - .replace(/^((-?[0-9])|--)/, '_$1') - .replace(filenameReservedRegex, '-') - .replace(reControlChars, '-') - .replace(/\./g, '-'), + .replace(/^((-?[0-9])|--)/, "_$1") + .replace(filenameReservedRegex, "-") + .replace(reControlChars, "-") + .replace(/\./g, "-"), { isIdentifier: true } ); } @@ -81,7 +81,7 @@ function normalizeUrl(url, isStringValue) { let normalizedUrl = url; if (isStringValue && /\\(\n|\r\n|\r|\f)/.test(normalizedUrl)) { - normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, ''); + normalizedUrl = normalizedUrl.replace(/\\(\n|\r\n|\r|\f)/g, ""); } if (matchNativeWin32Path.test(url)) { @@ -96,14 +96,14 @@ function requestify(url, rootContext) { return fileURLToPath(url); } - return url.charAt(0) === '/' + return url.charAt(0) === "/" ? urlToRequest(url, rootContext) : urlToRequest(url); } function getFilter(filter, resourcePath) { return (...args) => { - if (typeof filter === 'function') { + if (typeof filter === "function") { return filter(...args, resourcePath); } @@ -112,7 +112,7 @@ function getFilter(filter, resourcePath) { } function getValidLocalName(localName, exportLocalsConvention) { - if (exportLocalsConvention === 'dashesOnly') { + if (exportLocalsConvention === "dashesOnly") { return dashesCamelCase(localName); } @@ -126,7 +126,7 @@ function getModulesOptions(rawOptions, loaderContext) { const { resourcePath } = loaderContext; let isIcss; - if (typeof rawOptions.modules === 'undefined') { + if (typeof rawOptions.modules === "undefined") { const isModules = moduleRegExp.test(resourcePath); if (!isModules) { @@ -137,38 +137,38 @@ function getModulesOptions(rawOptions, loaderContext) { return false; } } else if ( - typeof rawOptions.modules === 'boolean' && + typeof rawOptions.modules === "boolean" && rawOptions.modules === false ) { return false; } let modulesOptions = { - compileType: isIcss ? 'icss' : 'module', + compileType: isIcss ? "icss" : "module", auto: true, - mode: 'local', + mode: "local", exportGlobals: false, - localIdentName: '[hash:base64]', + localIdentName: "[hash:base64]", localIdentContext: loaderContext.rootContext, - localIdentHashPrefix: '', + localIdentHashPrefix: "", // eslint-disable-next-line no-undefined localIdentRegExp: undefined, // eslint-disable-next-line no-undefined getLocalIdent: undefined, namedExport: false, - exportLocalsConvention: 'asIs', + exportLocalsConvention: "asIs", exportOnlyLocals: false, }; if ( - typeof rawOptions.modules === 'boolean' || - typeof rawOptions.modules === 'string' + typeof rawOptions.modules === "boolean" || + typeof rawOptions.modules === "string" ) { modulesOptions.mode = - typeof rawOptions.modules === 'string' ? rawOptions.modules : 'local'; + typeof rawOptions.modules === "string" ? rawOptions.modules : "local"; } else { if (rawOptions.modules) { - if (typeof rawOptions.modules.auto === 'boolean') { + if (typeof rawOptions.modules.auto === "boolean") { const isModules = rawOptions.modules.auto && moduleRegExp.test(resourcePath); @@ -181,7 +181,7 @@ function getModulesOptions(rawOptions, loaderContext) { if (!isModules) { return false; } - } else if (typeof rawOptions.modules.auto === 'function') { + } else if (typeof rawOptions.modules.auto === "function") { const isModule = rawOptions.modules.auto(resourcePath); if (!isModule) { @@ -191,16 +191,16 @@ function getModulesOptions(rawOptions, loaderContext) { if ( rawOptions.modules.namedExport === true && - typeof rawOptions.modules.exportLocalsConvention === 'undefined' + typeof rawOptions.modules.exportLocalsConvention === "undefined" ) { - modulesOptions.exportLocalsConvention = 'camelCaseOnly'; + modulesOptions.exportLocalsConvention = "camelCaseOnly"; } } modulesOptions = { ...modulesOptions, ...(rawOptions.modules || {}) }; } - if (typeof modulesOptions.mode === 'function') { + if (typeof modulesOptions.mode === "function") { modulesOptions.mode = modulesOptions.mode(loaderContext.resourcePath); } @@ -212,8 +212,8 @@ function getModulesOptions(rawOptions, loaderContext) { } if ( - modulesOptions.exportLocalsConvention !== 'camelCaseOnly' && - modulesOptions.exportLocalsConvention !== 'dashesOnly' + modulesOptions.exportLocalsConvention !== "camelCaseOnly" && + modulesOptions.exportLocalsConvention !== "dashesOnly" ) { throw new Error( 'The "modules.namedExport" option requires the "modules.exportLocalsConvention" option to be "camelCaseOnly" or "dashesOnly"' @@ -223,7 +223,7 @@ function getModulesOptions(rawOptions, loaderContext) { if (/\[emoji(?::(\d+))?\]/i.test(modulesOptions.localIdentName)) { loaderContext.emitWarning( - 'Emoji is deprecated and will be removed in next major release.' + "Emoji is deprecated and will be removed in next major release." ); } @@ -234,19 +234,19 @@ function normalizeOptions(rawOptions, loaderContext) { const modulesOptions = getModulesOptions(rawOptions, loaderContext); return { - url: typeof rawOptions.url === 'undefined' ? true : rawOptions.url, - import: typeof rawOptions.import === 'undefined' ? true : rawOptions.import, + url: typeof rawOptions.url === "undefined" ? true : rawOptions.url, + import: typeof rawOptions.import === "undefined" ? true : rawOptions.import, modules: modulesOptions, sourceMap: - typeof rawOptions.sourceMap === 'boolean' + typeof rawOptions.sourceMap === "boolean" ? rawOptions.sourceMap : loaderContext.sourceMap, importLoaders: - typeof rawOptions.importLoaders === 'string' + typeof rawOptions.importLoaders === "string" ? parseInt(rawOptions.importLoaders, 10) : rawOptions.importLoaders, esModule: - typeof rawOptions.esModule === 'undefined' ? true : rawOptions.esModule, + typeof rawOptions.esModule === "undefined" ? true : rawOptions.esModule, }; } @@ -255,7 +255,7 @@ function shouldUseImportPlugin(options) { return false; } - if (typeof options.import === 'boolean') { + if (typeof options.import === "boolean") { return options.import; } @@ -267,7 +267,7 @@ function shouldUseURLPlugin(options) { return false; } - if (typeof options.url === 'boolean') { + if (typeof options.url === "boolean") { return options.url; } @@ -275,7 +275,7 @@ function shouldUseURLPlugin(options) { } function shouldUseModulesPlugins(options) { - return options.modules.compileType === 'module'; + return options.modules.compileType === "module"; } function shouldUseIcssPlugin(options) { @@ -303,7 +303,7 @@ function getModulesPlugins(options, loaderContext) { generateScopedName(exportName) { let localIdent; - if (typeof getLocalIdent !== 'undefined') { + if (typeof getLocalIdent !== "undefined") { localIdent = getLocalIdent( loaderContext, localIdentName, @@ -318,7 +318,7 @@ function getModulesPlugins(options, loaderContext) { // A null/undefined value signals that we should invoke the default // getLocalIdent method. - if (typeof localIdent === 'undefined' || localIdent === null) { + if (typeof localIdent === "undefined" || localIdent === null) { localIdent = defaultGetLocalIdent( loaderContext, localIdentName, @@ -352,19 +352,19 @@ const IS_NATIVE_WIN32_PATH = /^[a-z]:[/\\]|^\\\\/i; const ABSOLUTE_SCHEME = /^[a-z0-9+\-.]+:/i; function getURLType(source) { - if (source[0] === '/') { - if (source[1] === '/') { - return 'scheme-relative'; + if (source[0] === "/") { + if (source[1] === "/") { + return "scheme-relative"; } - return 'path-absolute'; + return "path-absolute"; } if (IS_NATIVE_WIN32_PATH.test(source)) { - return 'path-absolute'; + return "path-absolute"; } - return ABSOLUTE_SCHEME.test(source) ? 'absolute' : 'path-relative'; + return ABSOLUTE_SCHEME.test(source) ? "absolute" : "path-relative"; } function normalizeSourceMap(map, resourcePath) { @@ -372,7 +372,7 @@ function normalizeSourceMap(map, resourcePath) { // Some loader emit source map as string // Strip any JSON XSSI avoidance prefix from the string (as documented in the source maps specification), and then parse the string as JSON. - if (typeof newMap === 'string') { + if (typeof newMap === "string") { newMap = JSON.parse(newMap); } @@ -387,16 +387,16 @@ function normalizeSourceMap(map, resourcePath) { // We should normalize path because previous loaders like `sass-loader` using backslash when generate source map newMap.sources = newMap.sources.map((source) => { // Non-standard syntax from `postcss` - if (source.indexOf('<') === 0) { + if (source.indexOf("<") === 0) { return source; } const sourceType = getURLType(source); // Do no touch `scheme-relative` and `absolute` URLs - if (sourceType === 'path-relative' || sourceType === 'path-absolute') { + if (sourceType === "path-relative" || sourceType === "path-absolute") { const absoluteSource = - sourceType === 'path-relative' && sourceRoot + sourceType === "path-relative" && sourceRoot ? path.resolve(sourceRoot, normalizePath(source)) : normalizePath(source); @@ -419,15 +419,15 @@ function getPreRequester({ loaders, loaderIndex }) { } if (number === false) { - cache[number] = ''; + cache[number] = ""; } else { const loadersRequest = loaders .slice( loaderIndex, - loaderIndex + 1 + (typeof number !== 'number' ? 0 : number) + loaderIndex + 1 + (typeof number !== "number" ? 0 : number) ) .map((x) => x.request) - .join('!'); + .join("!"); cache[number] = `-!${loadersRequest}!`; } @@ -437,7 +437,7 @@ function getPreRequester({ loaders, loaderIndex }) { } function getImportCode(imports, options) { - let code = ''; + let code = ""; for (const item of imports) { const { importName, url, icss } = item; @@ -445,7 +445,7 @@ function getImportCode(imports, options) { if (options.esModule) { if (icss && options.modules.namedExport) { code += `import ${ - options.modules.exportOnlyLocals ? '' : `${importName}, ` + options.modules.exportOnlyLocals ? "" : `${importName}, ` }* as ${importName}_NAMED___ from ${url};\n`; } else { code += `import ${importName} from ${url};\n`; @@ -455,7 +455,7 @@ function getImportCode(imports, options) { } } - return code ? `// Imports\n${code}` : ''; + return code ? `// Imports\n${code}` : ""; } function normalizeSourceMapForRuntime(map, loaderContext) { @@ -464,17 +464,17 @@ function normalizeSourceMapForRuntime(map, loaderContext) { if (resultMap) { delete resultMap.file; - resultMap.sourceRoot = ''; + resultMap.sourceRoot = ""; resultMap.sources = resultMap.sources.map((source) => { // Non-standard syntax from `postcss` - if (source.indexOf('<') === 0) { + if (source.indexOf("<") === 0) { return source; } const sourceType = getURLType(source); - if (sourceType !== 'path-relative') { + if (sourceType !== "path-relative") { return source; } @@ -493,19 +493,19 @@ function normalizeSourceMapForRuntime(map, loaderContext) { function getModuleCode(result, api, replacements, options, loaderContext) { if (options.modules.exportOnlyLocals === true) { - return ''; + return ""; } const sourceMapValue = options.sourceMap ? `,${normalizeSourceMapForRuntime(result.map, loaderContext)}` - : ''; + : ""; let code = JSON.stringify(result.css); let beforeCode = `var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${ options.sourceMap - ? '___CSS_LOADER_API_SOURCEMAP_IMPORT___' - : 'function(i){return i[1]}' + ? "___CSS_LOADER_API_SOURCEMAP_IMPORT___" + : "function(i){return i[1]}" });\n`; for (const item of api) { @@ -514,17 +514,17 @@ function getModuleCode(result, api, replacements, options, loaderContext) { beforeCode += url ? `___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify( `@import url(${url});` - )}${media ? `, ${JSON.stringify(media)}` : ''}]);\n` + )}${media ? `, ${JSON.stringify(media)}` : ""}]);\n` : `___CSS_LOADER_EXPORT___.i(${item.importName}${ - media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : '' - }${dedupe ? ', true' : ''});\n`; + media ? `, ${JSON.stringify(media)}` : dedupe ? ', ""' : "" + }${dedupe ? ", true" : ""});\n`; } for (const item of replacements) { const { replacementName, importName, localName } = item; if (localName) { - code = code.replace(new RegExp(replacementName, 'g'), () => + code = code.replace(new RegExp(replacementName, "g"), () => options.modules.namedExport ? `" + ${importName}_NAMED___[${JSON.stringify( getValidLocalName( @@ -538,13 +538,13 @@ function getModuleCode(result, api, replacements, options, loaderContext) { const { hash, needQuotes } = item; const getUrlOptions = [] .concat(hash ? [`hash: ${JSON.stringify(hash)}`] : []) - .concat(needQuotes ? 'needQuotes: true' : []); + .concat(needQuotes ? "needQuotes: true" : []); const preparedOptions = - getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(', ')} }` : ''; + getUrlOptions.length > 0 ? `, { ${getUrlOptions.join(", ")} }` : ""; beforeCode += `var ${replacementName} = ___CSS_LOADER_GET_URL_IMPORT___(${importName}${preparedOptions});\n`; code = code.replace( - new RegExp(replacementName, 'g'), + new RegExp(replacementName, "g"), () => `" + ${replacementName} + "` ); } @@ -560,8 +560,8 @@ function dashesCamelCase(str) { } function getExportCode(exports, replacements, options) { - let code = '// Exports\n'; - let localsCode = ''; + let code = "// Exports\n"; + let localsCode = ""; const addExportToLocalsCode = (name, value) => { if (options.modules.namedExport) { @@ -577,7 +577,7 @@ function getExportCode(exports, replacements, options) { for (const { name, value } of exports) { switch (options.modules.exportLocalsConvention) { - case 'camelCase': { + case "camelCase": { addExportToLocalsCode(name, value); const modifiedName = camelCase(name); @@ -587,11 +587,11 @@ function getExportCode(exports, replacements, options) { } break; } - case 'camelCaseOnly': { + case "camelCaseOnly": { addExportToLocalsCode(camelCase(name), value); break; } - case 'dashes': { + case "dashes": { addExportToLocalsCode(name, value); const modifiedName = dashesCamelCase(name); @@ -601,11 +601,11 @@ function getExportCode(exports, replacements, options) { } break; } - case 'dashesOnly': { + case "dashesOnly": { addExportToLocalsCode(dashesCamelCase(name), value); break; } - case 'asIs': + case "asIs": default: addExportToLocalsCode(name, value); break; @@ -618,7 +618,7 @@ function getExportCode(exports, replacements, options) { if (localName) { const { importName } = item; - localsCode = localsCode.replace(new RegExp(replacementName, 'g'), () => { + localsCode = localsCode.replace(new RegExp(replacementName, "g"), () => { if (options.modules.namedExport) { return `" + ${importName}_NAMED___[${JSON.stringify( getValidLocalName(localName, options.modules.exportLocalsConvention) @@ -631,7 +631,7 @@ function getExportCode(exports, replacements, options) { }); } else { localsCode = localsCode.replace( - new RegExp(replacementName, 'g'), + new RegExp(replacementName, "g"), () => `" + ${replacementName} + "` ); } @@ -641,7 +641,7 @@ function getExportCode(exports, replacements, options) { code += options.modules.namedExport ? localsCode : `${ - options.esModule ? 'export default' : 'module.exports =' + options.esModule ? "export default" : "module.exports =" } {\n${localsCode}\n};\n`; return code; @@ -654,7 +654,7 @@ function getExportCode(exports, replacements, options) { } code += `${ - options.esModule ? 'export default' : 'module.exports =' + options.esModule ? "export default" : "module.exports =" } ___CSS_LOADER_EXPORT___;\n`; return code; diff --git a/test/cjs.test.js b/test/cjs.test.js index 8aba6ba8..dc8321a3 100644 --- a/test/cjs.test.js +++ b/test/cjs.test.js @@ -1,8 +1,8 @@ -import src from '../src'; -import cjs from '../src/cjs'; +import src from "../src"; +import cjs from "../src/cjs"; -describe('cjs', () => { - it('should exported', () => { +describe("cjs", () => { + it("should exported", () => { expect(cjs).toEqual(src); }); }); diff --git a/test/esModule-option.test.js b/test/esModule-option.test.js index 8dcdf3e0..985562d5 100644 --- a/test/esModule-option.test.js +++ b/test/esModule-option.test.js @@ -2,9 +2,9 @@ * @jest-environment jsdom */ -import path from 'path'; +import path from "path"; -import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +import MiniCssExtractPlugin from "mini-css-extract-plugin"; import { compile, @@ -14,133 +14,133 @@ import { getModuleSource, getWarnings, readAsset, -} from './helpers/index'; +} from "./helpers/index"; describe('"esModule" option', () => { - it('should work when not specified', async () => { - const compiler = getCompiler('./es-module/source.js'); + it("should work when not specified", async () => { + const compiler = getCompiler("./es-module/source.js"); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true"', async () => { - const compiler = getCompiler('./es-module/source.js', { esModule: true }); + const compiler = getCompiler("./es-module/source.js", { esModule: true }); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true" and the "mode" value equal to "local"', async () => { - const compiler = getCompiler('./es-module/source.js', { + const compiler = getCompiler("./es-module/source.js", { esModule: true, - modules: 'local', + modules: "local", }); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true" and the "mode" value equal to "global"', async () => { - const compiler = getCompiler('./es-module/source.js', { + const compiler = getCompiler("./es-module/source.js", { esModule: true, - modules: 'global', + modules: "global", }); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true" and the "mode" value equal to "pure"', async () => { - const compiler = getCompiler('./es-module/source.js', { + const compiler = getCompiler("./es-module/source.js", { esModule: true, - modules: 'pure', + modules: "pure", }); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "false"', async () => { - const compiler = getCompiler('./es-module/source.js', { esModule: false }); + const compiler = getCompiler("./es-module/source.js", { esModule: false }); const stats = await compile(compiler); - expect(getModuleSource('./es-module/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./es-module/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); const styleLoaderTests = [ { - localLoaderMode: 'commonjs', - extractLoaderMode: 'commonjs', + localLoaderMode: "commonjs", + extractLoaderMode: "commonjs", }, { - localLoaderMode: 'esModule', - extractLoaderMode: 'esModule', + localLoaderMode: "esModule", + extractLoaderMode: "esModule", }, { - localLoaderMode: 'commonjs', - extractLoaderMode: 'esModule', + localLoaderMode: "commonjs", + extractLoaderMode: "esModule", }, { - localLoaderMode: 'esModule', - extractLoaderMode: 'commonjs', + localLoaderMode: "esModule", + extractLoaderMode: "commonjs", }, ]; for (const test of styleLoaderTests) { it(`should work with ${test.localLoaderMode} css-loader + ${test.extractLoaderMode} style-loader`, async () => { const compiler = getCompiler( - './es-module/template/index.js', + "./es-module/template/index.js", {}, { output: { - path: path.resolve(__dirname, './outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', - libraryTarget: 'commonjs2', + path: path.resolve(__dirname, "./outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", + libraryTarget: "commonjs2", }, module: { rules: [ @@ -148,15 +148,15 @@ describe('"esModule" option', () => { test: /\.css$/i, use: [ { - loader: 'style-loader', + loader: "style-loader", options: { - esModule: test.extractLoaderMode === 'esModule', + esModule: test.extractLoaderMode === "esModule", }, }, { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { - esModule: test.localLoaderMode === 'esModule', + esModule: test.localLoaderMode === "esModule", modules: true, }, }, @@ -169,38 +169,38 @@ describe('"esModule" option', () => { const stats = await compile(compiler); // eslint-disable-next-line no-eval - const result = eval(readAsset('main.bundle.js', compiler, stats)); + const result = eval(readAsset("main.bundle.js", compiler, stats)); - expect(result.default || result).toMatchSnapshot('result'); + expect(result.default || result).toMatchSnapshot("result"); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); } const miniCssExtractPluginTests = [ { - localLoaderMode: 'commonjs', - extractLoaderMode: 'commonjs', + localLoaderMode: "commonjs", + extractLoaderMode: "commonjs", }, { - localLoaderMode: 'esModule', - extractLoaderMode: 'esModule', + localLoaderMode: "esModule", + extractLoaderMode: "esModule", }, { - localLoaderMode: 'commonjs', - extractLoaderMode: 'esModule', + localLoaderMode: "commonjs", + extractLoaderMode: "esModule", }, { - localLoaderMode: 'esModule', - extractLoaderMode: 'commonjs', + localLoaderMode: "esModule", + extractLoaderMode: "commonjs", }, ]; for (const test of miniCssExtractPluginTests) { it(`should work with ${test.localLoaderMode} css-loader + ${test.extractLoaderMode} mini-css-extract-plugin`, async () => { const compiler = getCompiler( - './es-module/template/index.js', + "./es-module/template/index.js", {}, { module: { @@ -211,13 +211,13 @@ describe('"esModule" option', () => { { loader: MiniCssExtractPlugin.loader, options: { - esModule: test.extractLoaderMode === 'esModule', + esModule: test.extractLoaderMode === "esModule", }, }, { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { - esModule: test.localLoaderMode === 'esModule', + esModule: test.localLoaderMode === "esModule", modules: true, }, }, @@ -227,8 +227,8 @@ describe('"esModule" option', () => { }, plugins: [ new MiniCssExtractPlugin({ - filename: '[name].css', - chunkFilename: '[id].css', + filename: "[name].css", + chunkFilename: "[id].css", }), ], } @@ -236,10 +236,10 @@ describe('"esModule" option', () => { const stats = await compile(compiler); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); } }); diff --git a/test/helpers/ast-loader.js b/test/helpers/ast-loader.js index 14b6f837..1e1ba3aa 100644 --- a/test/helpers/ast-loader.js +++ b/test/helpers/ast-loader.js @@ -1,9 +1,9 @@ -import postcss from 'postcss'; -import postcssPresetEnv from 'postcss-preset-env'; -import postcssPkg from 'postcss/package.json'; -import semver from 'semver'; +import postcss from "postcss"; +import postcssPresetEnv from "postcss-preset-env"; +import postcssPkg from "postcss/package.json"; +import semver from "semver"; -const incomingVersion = semver.inc(postcssPkg.version, 'minor'); +const incomingVersion = semver.inc(postcssPkg.version, "minor"); export default function astLoader(content) { const callback = this.async(); @@ -17,11 +17,11 @@ export default function astLoader(content) { }) .then(({ css, map, root, messages }) => { const ast = { - type: 'postcss', + type: "postcss", version: incomingVersion, }; - Object.defineProperty(ast, 'root', { + Object.defineProperty(ast, "root", { get: spy.mockReturnValue(root), }); diff --git a/test/helpers/execute.js b/test/helpers/execute.js index 8ae07d81..0861df5d 100644 --- a/test/helpers/execute.js +++ b/test/helpers/execute.js @@ -1,14 +1,14 @@ -import Module from 'module'; -import path from 'path'; +import Module from "module"; +import path from "path"; const parentModule = module; export default (code) => { - const resource = 'test.js'; + 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; diff --git a/test/helpers/getCompiler.js b/test/helpers/getCompiler.js index 7c20108a..2dc8b1e4 100644 --- a/test/helpers/getCompiler.js +++ b/test/helpers/getCompiler.js @@ -1,19 +1,19 @@ -import path from 'path'; +import path from "path"; -import webpack from 'webpack'; -import { createFsFromVolume, Volume } from 'memfs'; +import webpack from "webpack"; +import { createFsFromVolume, Volume } from "memfs"; export default (fixture, loaderOptions = {}, config = {}) => { const fullConfig = { - mode: 'development', + mode: "development", devtool: config.devtool || false, - context: path.resolve(__dirname, '../fixtures'), - entry: path.resolve(__dirname, '../fixtures', fixture), + context: path.resolve(__dirname, "../fixtures"), + entry: path.resolve(__dirname, "../fixtures", fixture), output: { - path: path.resolve(__dirname, '../outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', + path: path.resolve(__dirname, "../outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", }, module: { rules: [ @@ -21,15 +21,15 @@ export default (fixture, loaderOptions = {}, config = {}) => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../../src'), + loader: path.resolve(__dirname, "../../src"), options: loaderOptions || {}, }, ], }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'file-loader', - options: { name: '[name].[ext]' }, + loader: "file-loader", + options: { name: "[name].[ext]" }, }, ], }, @@ -37,15 +37,15 @@ export default (fixture, loaderOptions = {}, config = {}) => { alias: { aliasesPackage: path.resolve( __dirname, - '../fixtures/import/node_modules/package/tilde.css' + "../fixtures/import/node_modules/package/tilde.css" ), - aliasesImg: path.resolve(__dirname, '../fixtures/url'), - aliasesImport: path.resolve(__dirname, '../fixtures/import'), + aliasesImg: path.resolve(__dirname, "../fixtures/url"), + aliasesImport: path.resolve(__dirname, "../fixtures/import"), aliasesComposes: path.resolve( __dirname, - '../fixtures/modules/composes' + "../fixtures/modules/composes" ), - '/img.png': path.resolve(__dirname, '../fixtures/url/img.png'), + "/img.png": path.resolve(__dirname, "../fixtures/url/img.png"), }, }, optimization: { diff --git a/test/helpers/getErrors.js b/test/helpers/getErrors.js index 55ae008b..a67263d5 100644 --- a/test/helpers/getErrors.js +++ b/test/helpers/getErrors.js @@ -1,4 +1,4 @@ -import normalizeErrors from './normalizeErrors'; +import normalizeErrors from "./normalizeErrors"; export default (stats, shortError, type) => { return normalizeErrors(stats.compilation.errors, shortError, type).sort(); diff --git a/test/helpers/getExecutedCode.js b/test/helpers/getExecutedCode.js index d2d0b24d..aa52bddc 100644 --- a/test/helpers/getExecutedCode.js +++ b/test/helpers/getExecutedCode.js @@ -1,4 +1,4 @@ -import { execute, readAsset } from './index'; +import { execute, readAsset } from "./index"; export default (asset, compiler, stats) => { let executed = execute(readAsset(asset, compiler, stats)); @@ -7,7 +7,7 @@ export default (asset, compiler, stats) => { 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].replace(/\?.*!/g, "?[ident]!"); return module; }); diff --git a/test/helpers/getModuleSource.js b/test/helpers/getModuleSource.js index 547a2e1c..69d1da67 100644 --- a/test/helpers/getModuleSource.js +++ b/test/helpers/getModuleSource.js @@ -4,7 +4,7 @@ export default (id, stats) => { let { source } = module; // Todo remove after drop webpack@4 support - source = source.replace(/\?\?.*!/g, '??[ident]!'); + source = source.replace(/\?\?.*!/g, "??[ident]!"); return source; }; diff --git a/test/helpers/getWarnings.js b/test/helpers/getWarnings.js index 9e09c82b..5f173498 100644 --- a/test/helpers/getWarnings.js +++ b/test/helpers/getWarnings.js @@ -1,4 +1,4 @@ -import normalizeErrors from './normalizeErrors'; +import normalizeErrors from "./normalizeErrors"; export default (stats) => { return normalizeErrors(stats.compilation.warnings).sort(); diff --git a/test/helpers/index.js b/test/helpers/index.js index 1dbb72f0..76621bdd 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -1,13 +1,13 @@ -import compile from './compile'; -import execute from './execute'; -import getCompiler from './getCompiler'; -import getErrors from './getErrors'; -import getExecutedCode from './getExecutedCode'; -import getModuleSource from './getModuleSource'; -import getWarnings from './getWarnings'; -import normalizeErrors from './normalizeErrors'; -import readAsset from './readAsset'; -import readsAssets from './readAssets'; +import compile from "./compile"; +import execute from "./execute"; +import getCompiler from "./getCompiler"; +import getErrors from "./getErrors"; +import getExecutedCode from "./getExecutedCode"; +import getModuleSource from "./getModuleSource"; +import getWarnings from "./getWarnings"; +import normalizeErrors from "./normalizeErrors"; +import readAsset from "./readAsset"; +import readsAssets from "./readAssets"; export { compile, diff --git a/test/helpers/normalizeErrors.js b/test/helpers/normalizeErrors.js index c844eb95..890173ff 100644 --- a/test/helpers/normalizeErrors.js +++ b/test/helpers/normalizeErrors.js @@ -1,30 +1,30 @@ -import stripAnsi from 'strip-ansi'; +import stripAnsi from "strip-ansi"; function removeCWD(str) { - const isWin = process.platform === 'win32'; + const isWin = process.platform === "win32"; let cwd = process.cwd(); if (isWin) { - if (str.split('\n').length > 3) { + if (str.split("\n").length > 3) { // @import '\ // \ // \ // '; return stripAnsi(str) - .replace(/\(from .*?\)/, '(from `replaced original path`)') - .replace(new RegExp(cwd, 'g'), ''); + .replace(/\(from .*?\)/, "(from `replaced original path`)") + .replace(new RegExp(cwd, "g"), ""); } // eslint-disable-next-line no-param-reassign - str = str.replace(/\\/g, '/'); + str = str.replace(/\\/g, "/"); // eslint-disable-next-line no-param-reassign - cwd = cwd.replace(/\\/g, '/'); + cwd = cwd.replace(/\\/g, "/"); } return stripAnsi(str) - .replace(/\(from .*?\)/, '(from `replaced original path`)') - .replace(new RegExp(cwd, 'g'), ''); + .replace(/\(from .*?\)/, "(from `replaced original path`)") + .replace(new RegExp(cwd, "g"), ""); } export default (errors, shortError, type) => { @@ -32,12 +32,12 @@ export default (errors, shortError, type) => { let errorMessage = error.toString(); if (shortError) { - errorMessage = errorMessage.split('\n').slice(0, 2).join('\n'); + errorMessage = errorMessage.split("\n").slice(0, 2).join("\n"); } - if (type === 'postcss') { + if (type === "postcss") { errorMessage = errorMessage - .split('\n') + .split("\n") .map((str) => { if (/^\(/i.test(str)) { return removeCWD(str); @@ -45,9 +45,9 @@ export default (errors, shortError, type) => { return str; }) - .join('\n'); + .join("\n"); } - return removeCWD(errorMessage.split('\n').slice(0, 12).join('\n')); + return removeCWD(errorMessage.split("\n").slice(0, 12).join("\n")); }); }; diff --git a/test/helpers/preLoader.js b/test/helpers/preLoader.js index 8e624432..1585e7f2 100644 --- a/test/helpers/preLoader.js +++ b/test/helpers/preLoader.js @@ -1,5 +1,5 @@ export default function loader(content, map) { const callback = this.async(); - return callback(null, content, map, 'non-ast-meta'); + return callback(null, content, map, "non-ast-meta"); } diff --git a/test/helpers/readAsset.js b/test/helpers/readAsset.js index 8f4699f0..fde3ff39 100644 --- a/test/helpers/readAsset.js +++ b/test/helpers/readAsset.js @@ -1,13 +1,13 @@ -import path from 'path'; +import path from "path"; export default (asset, compiler, stats) => { const usedFs = compiler.outputFileSystem; const outputPath = stats.compilation.outputOptions.path; - let data = ''; + let data = ""; let targetFile = asset; - const queryStringIdx = targetFile.indexOf('?'); + const queryStringIdx = targetFile.indexOf("?"); if (queryStringIdx >= 0) { targetFile = targetFile.substr(0, queryStringIdx); diff --git a/test/helpers/readAssets.js b/test/helpers/readAssets.js index a2fb7837..15b9dca2 100644 --- a/test/helpers/readAssets.js +++ b/test/helpers/readAssets.js @@ -1,4 +1,4 @@ -import readAsset from './readAsset'; +import readAsset from "./readAsset"; export default function readAssets(compiler, stats) { const assets = {}; diff --git a/test/helpers/string-loader.js b/test/helpers/string-loader.js index a7b4a66c..2d82e7f6 100644 --- a/test/helpers/string-loader.js +++ b/test/helpers/string-loader.js @@ -1,5 +1,5 @@ function loader() { - return 'a { color: red };'; + return "a { color: red };"; } module.exports = loader; diff --git a/test/import-option.test.js b/test/import-option.test.js index fdee36c5..ecc84563 100644 --- a/test/import-option.test.js +++ b/test/import-option.test.js @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import fs from "fs"; +import path from "path"; import { compile, @@ -8,64 +8,64 @@ import { getExecutedCode, getModuleSource, getWarnings, -} from './helpers/index'; +} from "./helpers/index"; describe('"import" option', () => { - it('should work when not specified', async () => { - const compiler = getCompiler('./import/import.js'); + it("should work when not specified", async () => { + const compiler = getCompiler("./import/import.js"); const stats = await compile(compiler); - expect(getModuleSource('./import/import.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/import.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true"', async () => { - const compiler = getCompiler('./import/import.js', { import: true }); + const compiler = getCompiler("./import/import.js", { import: true }); const stats = await compile(compiler); - expect(getModuleSource('./import/import.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/import.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "false"', async () => { - const compiler = getCompiler('./import/import.js', { import: false }); + const compiler = getCompiler("./import/import.js", { import: false }); const stats = await compile(compiler); - expect(getModuleSource('./import/import.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/import.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work when "Function"', async () => { - const compiler = getCompiler('./import/import.js', { + const compiler = getCompiler("./import/import.js", { import: (url, media, resourcePath) => { expect(url).toBeDefined(); - if (url === 'test-nested-media.css') { + if (url === "test-nested-media.css") { expect(media).toBeDefined(); } expect(resourcePath).toBeDefined(); // Don't handle `test.css` - if (url.includes('test.css')) { + if (url.includes("test.css")) { return false; } @@ -74,133 +74,133 @@ describe('"import" option', () => { }); const stats = await compile(compiler); - expect(getModuleSource('./import/import.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/import.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should keep original order', async () => { - const compiler = getCompiler('./import/order.js'); + it("should keep original order", async () => { + const compiler = getCompiler("./import/order.js"); const stats = await compile(compiler); - expect(getModuleSource('./import/order.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/order.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should respect style field in package.json', async () => { - const compiler = getCompiler('./import/issue-683.js'); + it("should respect style field in package.json", async () => { + const compiler = getCompiler("./import/issue-683.js"); const stats = await compile(compiler); - expect(getModuleSource('test.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("test.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should respect conditionNames', async () => { - const compiler = getCompiler('./import/import-conditionNames.js'); + it("should respect conditionNames", async () => { + const compiler = getCompiler("./import/import-conditionNames.js"); const stats = await compile(compiler); - expect(getModuleSource('import-conditionNames.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("import-conditionNames.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should resolve server-relative url relative rootContext', async () => { - const compiler = getCompiler('./import/import-server-relative-url.js'); + it("should resolve server-relative url relative rootContext", async () => { + const compiler = getCompiler("./import/import-server-relative-url.js"); const stats = await compile(compiler); expect( - getModuleSource('./import/import-server-relative-url.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./import/import-server-relative-url.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work resolve order: local -> node_modules -> alias', async () => { - const compiler = getCompiler('./import/import-order.js'); + it("should work resolve order: local -> node_modules -> alias", async () => { + const compiler = getCompiler("./import/import-order.js"); const stats = await compile(compiler); - expect(getModuleSource('./import/import-order.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./import/import-order.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should resolve absolute path', async () => { + it("should resolve absolute path", async () => { // Create the file with absolute path - const fileDirectory = path.resolve(__dirname, 'fixtures', 'import'); - const file = path.resolve(fileDirectory, 'import-absolute.css'); - const absolutePath = path.resolve(fileDirectory, 'test.css'); + const fileDirectory = path.resolve(__dirname, "fixtures", "import"); + const file = path.resolve(fileDirectory, "import-absolute.css"); + const absolutePath = path.resolve(fileDirectory, "test.css"); fs.writeFileSync(file, `@import "${absolutePath}";`); - const compiler = getCompiler('./import/import-absolute.js'); + const compiler = getCompiler("./import/import-absolute.js"); const stats = await compile(compiler); expect( - getModuleSource('./import/import-absolute.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./import/import-absolute.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should resolve "file" protocol', async () => { // Create the file with absolute path - const fileDirectory = path.resolve(__dirname, 'fixtures', 'import'); - const file = path.resolve(fileDirectory, 'import-file-protocol.css'); + const fileDirectory = path.resolve(__dirname, "fixtures", "import"); + const file = path.resolve(fileDirectory, "import-file-protocol.css"); const absolutePath = path - .resolve(fileDirectory, 'test.css') - .replace(/\\/g, '/'); + .resolve(fileDirectory, "test.css") + .replace(/\\/g, "/"); fs.writeFileSync(file, `@import "file://${absolutePath}";`); - const compiler = getCompiler('./import/import-file-protocol.js'); + const compiler = getCompiler("./import/import-file-protocol.js"); const stats = await compile(compiler); expect( - getModuleSource('./import/import-file-protocol.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./import/import-file-protocol.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throw an error on unresolved import', async () => { - const compiler = getCompiler('./import/unresolved.js'); + it("should throw an error on unresolved import", async () => { + const compiler = getCompiler("./import/unresolved.js"); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); }); diff --git a/test/importLoaders-option.test.js b/test/importLoaders-option.test.js index 364b2616..11071f6f 100644 --- a/test/importLoaders-option.test.js +++ b/test/importLoaders-option.test.js @@ -1,6 +1,6 @@ -import path from 'path'; +import path from "path"; -import postcssPresetEnv from 'postcss-preset-env'; +import postcssPresetEnv from "postcss-preset-env"; import { compile, @@ -9,12 +9,12 @@ import { getExecutedCode, getModuleSource, getWarnings, -} from './helpers/index'; +} from "./helpers/index"; describe('"importLoaders" option', () => { - it('should work when not specified', async () => { + it("should work when not specified", async () => { const compiler = getCompiler( - './nested-import/source.js', + "./nested-import/source.js", {}, { module: { @@ -22,9 +22,9 @@ describe('"importLoaders" option', () => { { test: /\.css$/i, rules: [ - { loader: path.resolve(__dirname, '../src') }, + { loader: path.resolve(__dirname, "../src") }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -40,18 +40,18 @@ describe('"importLoaders" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "0" (`postcss-loader` before)', async () => { const compiler = getCompiler( - './nested-import/source.js', + "./nested-import/source.js", {}, { module: { @@ -60,11 +60,11 @@ describe('"importLoaders" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: 0 }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -80,32 +80,32 @@ describe('"importLoaders" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "1" (no loaders before)', async () => { - const compiler = getCompiler('./nested-import/source.js'); + const compiler = getCompiler("./nested-import/source.js"); const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "1" ("postcss-loader" before)', async () => { const compiler = getCompiler( - './nested-import/source.js', + "./nested-import/source.js", {}, { module: { @@ -114,11 +114,11 @@ describe('"importLoaders" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: 1 }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -134,18 +134,18 @@ describe('"importLoaders" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "2" ("postcss-loader" before)', async () => { const compiler = getCompiler( - './nested-import/source.js', + "./nested-import/source.js", {}, { module: { @@ -154,11 +154,11 @@ describe('"importLoaders" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: 2 }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -174,18 +174,18 @@ describe('"importLoaders" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to ""1"" ("postcss-loader" before)', async () => { const compiler = getCompiler( - './nested-import/source.js', + "./nested-import/source.js", {}, { module: { @@ -194,11 +194,11 @@ describe('"importLoaders" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), - options: { importLoaders: '1' }, + loader: path.resolve(__dirname, "../src"), + options: { importLoaders: "1" }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -214,12 +214,12 @@ describe('"importLoaders" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./nested-import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./nested-import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); diff --git a/test/loader.test.js b/test/loader.test.js index 0f30422e..e072f719 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -1,8 +1,8 @@ -import path from 'path'; +import path from "path"; -import { version } from 'webpack'; +import { version } from "webpack"; -import postcssPresetEnv from 'postcss-preset-env'; +import postcssPresetEnv from "postcss-preset-env"; import { compile, @@ -11,49 +11,49 @@ import { getExecutedCode, getModuleSource, getWarnings, -} from './helpers/index'; +} from "./helpers/index"; jest.setTimeout(10000); -describe('loader', () => { - it('should work', async () => { - const compiler = getCompiler('./basic.js'); +describe("loader", () => { + it("should work", async () => { + const compiler = getCompiler("./basic.js"); const stats = await compile(compiler); - expect(getModuleSource('./basic.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./basic.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with empty css', async () => { - const compiler = getCompiler('./empty.js'); + it("should work with empty css", async () => { + const compiler = getCompiler("./empty.js"); const stats = await compile(compiler); - expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./empty.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with empty options', async () => { - const compiler = getCompiler('./basic.js', {}); + it("should work with empty options", async () => { + const compiler = getCompiler("./basic.js", {}); const stats = await compile(compiler); - expect(getModuleSource('./basic.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./basic.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "asset" module type', async () => { - const isWebpack5 = version[0] === '5'; + const isWebpack5 = version[0] === "5"; const config = { module: { rules: [ @@ -61,19 +61,19 @@ describe('loader', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), }, ], }, isWebpack5 ? { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/i, - type: 'asset', + type: "asset", } : { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'file-loader', - options: { name: '[name].[ext]' }, + loader: "file-loader", + options: { name: "[name].[ext]" }, }, ], }, @@ -82,35 +82,35 @@ describe('loader', () => { if (isWebpack5) { config.experiments = { asset: true }; config.output = { - path: path.resolve(__dirname, 'outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', - assetModuleFilename: '[name][ext]', + path: path.resolve(__dirname, "outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", + assetModuleFilename: "[name][ext]", }; } - const compiler = getCompiler('./basic.js', {}, config); + const compiler = getCompiler("./basic.js", {}, config); const stats = await compile(compiler); - expect(getModuleSource('./basic.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./basic.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throws error when no loader(s) for assets', async () => { + it("should throws error when no loader(s) for assets", async () => { const compiler = getCompiler( - './basic.js', + "./basic.js", {}, { module: { rules: [ { test: /\.css$/i, - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), }, ], }, @@ -118,27 +118,27 @@ describe('loader', () => { ); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throw error on invalid css syntax', async () => { - const compiler = getCompiler('./error.js', {}); + it("should throw error on invalid css syntax", async () => { + const compiler = getCompiler("./error.js", {}); const stats = await compile(compiler); expect( stats.compilation.fileDependencies.has( - path.resolve('./test/fixtures/error.css') + path.resolve("./test/fixtures/error.css") ) ).toBe(true); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, false, 'postcss')).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, false, "postcss")).toMatchSnapshot("errors"); }); it('should reuse `ast` from "postcss-loader"', async () => { const spy = jest.fn(); const compiler = getCompiler( - './postcss-present-env/source.js', + "./postcss-present-env/source.js", {}, { module: { @@ -147,19 +147,19 @@ describe('loader', () => { test: /\.css$/i, rules: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: 1 }, }, { - loader: require.resolve('./helpers/ast-loader'), + loader: require.resolve("./helpers/ast-loader"), options: { spy }, }, ], }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, - loader: 'file-loader', - options: { name: '[name].[ext]' }, + loader: "file-loader", + options: { name: "[name].[ext]" }, }, ], }, @@ -170,18 +170,18 @@ describe('loader', () => { expect(spy).toHaveBeenCalledTimes(1); expect( - getModuleSource('./postcss-present-env/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./postcss-present-env/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "sass-loader"', async () => { const compiler = getCompiler( - './scss/source.js', + "./scss/source.js", {}, { module: { @@ -189,12 +189,12 @@ describe('loader', () => { { test: /\.s[ca]ss$/i, rules: [ - { loader: path.resolve(__dirname, '../src') }, + { loader: path.resolve(__dirname, "../src") }, { - loader: 'sass-loader', + loader: "sass-loader", options: { // eslint-disable-next-line global-require - implementation: require('sass'), + implementation: require("sass"), }, }, ], @@ -205,37 +205,37 @@ describe('loader', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./scss/source.scss', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./scss/source.scss", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with ModuleConcatenationPlugin', async () => { + it("should work with ModuleConcatenationPlugin", async () => { const compiler = getCompiler( - './basic.js', + "./basic.js", {}, { - mode: 'production', + mode: "production", module: { rules: [ { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { esModule: true }, }, ], }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, - loader: 'file-loader', - options: { name: '[name].[ext]', esModule: true }, + loader: "file-loader", + options: { name: "[name].[ext]", esModule: true }, }, ], }, @@ -249,26 +249,26 @@ describe('loader', () => { expect(stats.compilation.modules.length).toBe(6); } - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with ModuleConcatenationPlugin (file-loader)', async () => { + it("should work with ModuleConcatenationPlugin (file-loader)", async () => { const compiler = getCompiler( - './basic.js', + "./basic.js", {}, { - mode: 'production', + mode: "production", module: { rules: [ { test: /\.css$/i, - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, - loader: 'file-loader', - options: { name: '[name].[ext]', esModule: true }, + loader: "file-loader", + options: { name: "[name].[ext]", esModule: true }, }, ], }, @@ -282,26 +282,26 @@ describe('loader', () => { expect(stats.compilation.modules.length).toBe(6); } - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with ModuleConcatenationPlugin (url-loader)', async () => { + it("should work with ModuleConcatenationPlugin (url-loader)", async () => { const compiler = getCompiler( - './basic.js', + "./basic.js", {}, { - mode: 'production', + mode: "production", module: { rules: [ { test: /\.css$/i, - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), }, { test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/, - loader: 'url-loader', - options: { name: '[name].[ext]', limit: true, esModule: true }, + loader: "url-loader", + options: { name: "[name].[ext]", limit: true, esModule: true }, }, ], }, @@ -315,57 +315,57 @@ describe('loader', () => { expect(stats.compilation.modules.length).toBe(6); } - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #1033', async () => { - const compiler = getCompiler('./modules/issue-1033/issue-1033.js', { + it("issue #1033", async () => { + const compiler = getCompiler("./modules/issue-1033/issue-1033.js", { modules: { - mode: 'local', - localIdentName: '_[local]', + mode: "local", + localIdentName: "_[local]", exportOnlyLocals: true, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1033/issue-1033.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1033/issue-1033.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #1033 (2)', async () => { - const compiler = getCompiler('./modules/issue-1033/issue-1033.js', { - modules: { mode: 'local', localIdentName: '_[local]' }, + it("issue #1033 (2)", async () => { + const compiler = getCompiler("./modules/issue-1033/issue-1033.js", { + modules: { mode: "local", localIdentName: "_[local]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1033/issue-1033.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1033/issue-1033.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throw an error on invisible spaces', async () => { - const compiler = getCompiler('./invisible-space.js'); + it("should throw an error on invisible spaces", async () => { + const compiler = getCompiler("./invisible-space.js"); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, false, 'postcss')).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, false, "postcss")).toMatchSnapshot("errors"); }); it('should work with the "modules.auto" option and the "importLoaders" option', async () => { const compiler = getCompiler( - './integration/index.js', + "./integration/index.js", {}, { module: { @@ -374,7 +374,7 @@ describe('loader', () => { test: /\.((c|sa|sc)ss)$/i, rules: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { // Run only `postcss-loader` on each `@import` // If you need run `sass-loader` and `postcss-loader` please set it to `2` @@ -384,7 +384,7 @@ describe('loader', () => { }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -395,13 +395,13 @@ describe('loader', () => { // The `test` property should be `\.less/i` { test: /\.s[ac]ss$/i, - loader: 'sass-loader', + loader: "sass-loader", }, ], }, { test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'url-loader', + loader: "url-loader", options: { limit: 8192, }, @@ -412,16 +412,16 @@ describe('loader', () => { ); const stats = await compile(compiler); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with none AST metadata', async () => { + it("should work with none AST metadata", async () => { const compiler = getCompiler( - './simple.js', + "./simple.js", {}, { module: { @@ -430,10 +430,10 @@ describe('loader', () => { test: /\.css$/i, rules: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), }, { - loader: path.resolve(__dirname, '../test/helpers/preLoader'), + loader: path.resolve(__dirname, "../test/helpers/preLoader"), }, ], }, @@ -443,17 +443,17 @@ describe('loader', () => { ); const stats = await compile(compiler); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should not generate console.warn when plugins disabled and hideNothingWarning is "true"', async () => { - jest.spyOn(console, 'warn').mockImplementation(() => {}); + jest.spyOn(console, "warn").mockImplementation(() => {}); - const compiler = getCompiler('./empty.js', { + const compiler = getCompiler("./empty.js", { import: false, url: false, }); @@ -461,15 +461,15 @@ describe('loader', () => { // eslint-disable-next-line no-console expect(console.warn).not.toHaveBeenCalledWith( - 'You did not set any plugins, parser, or stringifier. ' + - 'Right now, PostCSS does nothing. Pick plugins for your case ' + - 'on https://www.postcss.parts/ and use them in postcss.config.js.' + "You did not set any plugins, parser, or stringifier. " + + "Right now, PostCSS does nothing. Pick plugins for your case " + + "on https://www.postcss.parts/ and use them in postcss.config.js." ); - expect(getModuleSource('./empty.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./empty.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); diff --git a/test/modules-option.test.js b/test/modules-option.test.js index 6116a689..ad1fad25 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -1,5 +1,5 @@ -import path from 'path'; -import fs from 'fs'; +import path from "path"; +import fs from "fs"; import { compile, @@ -8,9 +8,9 @@ import { getExecutedCode, getModuleSource, getWarnings, -} from './helpers/index'; +} from "./helpers/index"; -const testCasesPath = path.join(__dirname, 'fixtures/modules/tests-cases'); +const testCasesPath = path.join(__dirname, "fixtures/modules/tests-cases"); const testCases = fs.readdirSync(testCasesPath); jest.setTimeout(60000); @@ -19,10 +19,10 @@ describe('"modules" option', () => { [ true, false, - 'local', - 'global', - { mode: 'local' }, - { mode: 'global' }, + "local", + "global", + { mode: "local" }, + { mode: "global" }, ].forEach((modulesValue) => { testCases.forEach((name) => { it(`should work with case \`${name}\` (\`modules\` value is \`${ @@ -34,318 +34,318 @@ describe('"modules" option', () => { const moduleId = `./modules/tests-cases/${name}/source.css`; const compiler = getCompiler(pathToTest, { modules: modulesValue.mode - ? { mode: modulesValue.mode, localIdentName: '_[local]' } + ? { mode: modulesValue.mode, localIdentName: "_[local]" } : modulesValue, }); const stats = await compile(compiler); - expect(getModuleSource(moduleId, stats)).toMatchSnapshot('module'); + expect(getModuleSource(moduleId, stats)).toMatchSnapshot("module"); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); }); it('should work and support "pure" mode', async () => { - const compiler = getCompiler('./modules/pure/pure.js', { modules: 'pure' }); + const compiler = getCompiler("./modules/pure/pure.js", { modules: "pure" }); const stats = await compile(compiler); - expect(getModuleSource('./modules/pure/pure.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/pure/pure.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and support "pure" mode #2', async () => { - const compiler = getCompiler('./modules/pure/pure.js', { - modules: { mode: 'pure' }, + const compiler = getCompiler("./modules/pure/pure.js", { + modules: { mode: "pure" }, }); const stats = await compile(compiler); - expect(getModuleSource('./modules/pure/pure.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/pure/pure.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "[local]" placeholder for the "localIdentName" option', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { - modules: { localIdentName: '[local]' }, + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { + modules: { localIdentName: "[local]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "localIdentName" option', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { - localIdentName: '[name]--[local]--[hash:base64:5]', + localIdentName: "[name]--[local]--[hash:base64:5]", localIdentContext: path.resolve(__dirname), }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "context" option', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { - localIdentName: '[hash:base64:8]', + localIdentName: "[hash:base64:8]", localIdentContext: path.resolve(__dirname), }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "path" placeholder', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { - localIdentName: '[path][name]__[local]', + localIdentName: "[path][name]__[local]", localIdentContext: path.resolve(__dirname), }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "hashPrefix" option', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { - localIdentName: '[local]--[hash]', - localIdentHashPrefix: 'x', + localIdentName: "[local]--[hash]", + localIdentHashPrefix: "x", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work and prefix leading hyphen when digit is first', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { - modules: { localIdentName: '-1[local]' }, + it("should work and prefix leading hyphen when digit is first", async () => { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { + modules: { localIdentName: "-1[local]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should should work with two leading hyphens', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { - modules: { localIdentName: '--[local]' }, + it("should should work with two leading hyphens", async () => { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { + modules: { localIdentName: "--[local]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should should work with two leading underscore', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { - modules: { localIdentName: '__[local]' }, + it("should should work with two leading underscore", async () => { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { + modules: { localIdentName: "__[local]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work and correctly replace escaped symbols', async () => { - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { - modules: { localIdentName: '[local]--[hash:base64:4]' }, + it("should work and correctly replace escaped symbols", async () => { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { + modules: { localIdentName: "[local]--[hash:base64:4]" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "getLocalIdent" option', async () => { expect.assertions(382); - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { - localIdentRegExp: 'regExp', - localIdentContext: 'context', - localIdentHashPrefix: 'hash', + localIdentRegExp: "regExp", + localIdentContext: "context", + localIdentHashPrefix: "hash", getLocalIdent(loaderContext, localIdentName, localName, options) { expect(loaderContext).toBeDefined(); - expect(typeof localIdentName).toBe('string'); - expect(typeof localName).toBe('string'); + expect(typeof localIdentName).toBe("string"); + expect(typeof localName).toBe("string"); expect(options).toBeDefined(); - expect(options.regExp).toBe('regExp'); - expect(options.context).toBe('context'); - expect(options.hashPrefix).toBe('hash'); + expect(options.regExp).toBe("regExp"); + expect(options.context).toBe("context"); + expect(options.hashPrefix).toBe("hash"); - return 'foo'; + return "foo"; }, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and has "undefined" context if no context was given', async () => { expect.assertions(58); - const compiler = getCompiler('./modules/localIdentName/localIdentName.js', { + const compiler = getCompiler("./modules/localIdentName/localIdentName.js", { modules: { getLocalIdent(loaderContext, localIdentName, localName, options) { expect(options.context).toBeDefined(); - return 'foo'; + return "foo"; }, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/localIdentName/localIdentName.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localIdentName/localIdentName.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should support resolving in composes', async () => { - const compiler = getCompiler('./modules/composes/composes.js', { + it("should support resolving in composes", async () => { + const compiler = getCompiler("./modules/composes/composes.js", { modules: true, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should resolve absolute path in composes', async () => { + it("should resolve absolute path in composes", async () => { // Create the file with absolute path const fileDirectory = path.resolve( __dirname, - 'fixtures', - 'modules', - 'composes' + "fixtures", + "modules", + "composes" ); - const file = path.resolve(fileDirectory, 'composes-absolute.css'); - const absolutePath = path.resolve(fileDirectory, 'imported-simple.css'); + const file = path.resolve(fileDirectory, "composes-absolute.css"); + const absolutePath = path.resolve(fileDirectory, "imported-simple.css"); fs.writeFileSync( file, `.simple { color: red; composes: imported-simple from '${absolutePath}'; }` ); - const compiler = getCompiler('./modules/composes/composes-absolute.js', { + const compiler = getCompiler("./modules/composes/composes-absolute.js", { modules: true, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes-absolute.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes-absolute.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should support resolving in composes preprocessor files with extensions', async () => { + it("should support resolving in composes preprocessor files with extensions", async () => { const compiler = getCompiler( - './modules/composes/composes-preprocessors.js', + "./modules/composes/composes-preprocessors.js", { modules: { - mode: 'local', + mode: "local", exportGlobals: true, }, } @@ -353,39 +353,39 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes-preprocessors.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes-preprocessors.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #286', async () => { + it("issue #286", async () => { const compiler = getCompiler( - './modules/issue-286/source.js', + "./modules/issue-286/source.js", {}, { module: { rules: [ { test: /source\.css$/, - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: false, modules: { - localIdentName: 'b--[local]', + localIdentName: "b--[local]", }, }, }, { test: /dep\.css$/, - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { importLoaders: false, modules: { - localIdentName: 'a--[local]', + localIdentName: "a--[local]", }, }, }, @@ -396,18 +396,18 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-286/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-286/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #636', async () => { + it("issue #636", async () => { const compiler = getCompiler( - './modules/issue-636/source.js', + "./modules/issue-636/source.js", {}, { module: { @@ -416,10 +416,10 @@ describe('"modules" option', () => { test: /\.s[ca]ss$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { modules: { - localIdentName: '[local]', + localIdentName: "[local]", getLocalIdent: (context, localIdentName, localName) => `prefix-${localName}`, }, @@ -427,10 +427,10 @@ describe('"modules" option', () => { }, }, { - loader: 'sass-loader', + loader: "sass-loader", options: { // eslint-disable-next-line global-require - implementation: require('sass'), + implementation: require("sass"), }, }, ], @@ -442,18 +442,18 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-636/source.scss', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-636/source.scss", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #861', async () => { + it("issue #861", async () => { const compiler = getCompiler( - './modules/issue-861/resolving-from-node_modules.js', + "./modules/issue-861/resolving-from-node_modules.js", { modules: true, } @@ -462,19 +462,19 @@ describe('"modules" option', () => { expect( getModuleSource( - './modules/issue-861/resolving-from-node_modules.css', + "./modules/issue-861/resolving-from-node_modules.css", stats ) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #966', async () => { - const compiler = getCompiler('./modules/issue-966/button.js', { + it("issue #966", async () => { + const compiler = getCompiler("./modules/issue-966/button.js", { modules: { getLocalIdent: (ctx, localIdentName, localName) => `${localName}.hey`, }, @@ -482,58 +482,58 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-966/button.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-966/button.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it("issue #966 - values in selectors aren't escaped properly", async () => { - const compiler = getCompiler('./modules/issue-966/issue-966.js', { + const compiler = getCompiler("./modules/issue-966/issue-966.js", { modules: { getLocalIdent: (loaderContext, localIdentName, localName) => { - if (localName === 'foo-class') { + if (localName === "foo-class") { return `7-${localName}`; } - if (localName === 'bar-class') { + if (localName === "bar-class") { return `>-${localName}`; } - if (localName === 'baz-class') { + if (localName === "baz-class") { return `\u0000-${localName}`; } - if (localName === 'fooBaz-class') { + if (localName === "fooBaz-class") { return `${localName}.continuation`; } return null; }, - localIdentName: '[local]', + localIdentName: "[local]", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-966/issue-966.css', stats) - ).toMatchSnapshot('module'); + getModuleSource("./modules/issue-966/issue-966.css", stats) + ).toMatchSnapshot("module"); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #967', async () => { - const compiler = getCompiler('./modules/issue-967/path-placeholder.js', { + it("issue #967", async () => { + const compiler = getCompiler("./modules/issue-967/path-placeholder.js", { modules: { - mode: 'local', + mode: "local", localIdentName: '[path][name]__[local]__/-sep-?-sep-<-sep->-sep-\\\\-sep-:-sep-*-sep-|-sep-"-sep-:', }, @@ -541,21 +541,21 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-967/path-placeholder.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-967/path-placeholder.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #980', async () => { + it("issue #980", async () => { const compiler = getCompiler( - './modules/issue-980/file.with.many.dots.in.name.js', + "./modules/issue-980/file.with.many.dots.in.name.js", { modules: { - localIdentName: '[name]_[local]_[hash:base64:5]', + localIdentName: "[name]_[local]_[hash:base64:5]", }, } ); @@ -563,167 +563,167 @@ describe('"modules" option', () => { expect( getModuleSource( - './modules/issue-980/file.with.many.dots.in.name.css', + "./modules/issue-980/file.with.many.dots.in.name.css", stats ) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #995', async () => { - const compiler = getCompiler('./modules/issue-995/issue-995.js', { + it("issue #995", async () => { + const compiler = getCompiler("./modules/issue-995/issue-995.js", { modules: { - mode: 'global', - localIdentName: '😀', + mode: "global", + localIdentName: "😀", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-995/issue-995.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-995/issue-995.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should avoid unnecessary "require"', async () => { - const compiler = getCompiler('./modules/composes/composes-duplicate.js', { + const compiler = getCompiler("./modules/composes/composes-duplicate.js", { modules: true, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes-duplicate.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes-duplicate.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should keep order', async () => { - const compiler = getCompiler('./modules/order/index.js', { modules: true }); + it("should keep order", async () => { + const compiler = getCompiler("./modules/order/index.js", { modules: true }); const stats = await compile(compiler); - expect(getModuleSource('./modules/order/index.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/order/index.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should dedupe same modules in one module (issue #1037)', async () => { - const compiler = getCompiler('./modules/dedupe/source.js', { + it("should dedupe same modules in one module (issue #1037)", async () => { + const compiler = getCompiler("./modules/dedupe/source.js", { modules: true, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/dedupe/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/dedupe/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #1063', async () => { - const compiler = getCompiler('./modules/issue-1063/issue-1063.js', { + it("issue #1063", async () => { + const compiler = getCompiler("./modules/issue-1063/issue-1063.js", { modules: { mode: (resourcePath) => { if (/pure.css$/i.test(resourcePath)) { - return 'pure'; + return "pure"; } if (/global.css$/i.test(resourcePath)) { - return 'global'; + return "global"; } - return 'local'; + return "local"; }, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1063/local.css', stats) - ).toMatchSnapshot('module with the `local` mode'); + getModuleSource("./modules/issue-1063/local.css", stats) + ).toMatchSnapshot("module with the `local` mode"); expect( - getModuleSource('./modules/issue-1063/global.css', stats) - ).toMatchSnapshot('module with the `global` mode'); + getModuleSource("./modules/issue-1063/global.css", stats) + ).toMatchSnapshot("module with the `global` mode"); expect( - getModuleSource('./modules/issue-1063/pure.css', stats) - ).toMatchSnapshot('module with the `pure` mode'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1063/pure.css", stats) + ).toMatchSnapshot("module with the `pure` mode"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #1063 throw error', async () => { - const compiler = getCompiler('./modules/issue-1063/issue-1063.js', { + it("issue #1063 throw error", async () => { + const compiler = getCompiler("./modules/issue-1063/issue-1063.js", { modules: { mode: () => { - return 'not local, global or pure'; + return "not local, global or pure"; }, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1063/local.css', stats) - ).toMatchSnapshot('module'); + getModuleSource("./modules/issue-1063/local.css", stats) + ).toMatchSnapshot("module"); expect( - getModuleSource('./modules/issue-1063/global.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1063/global.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('issue #1191 - fallback to default getLocalIdent', async () => { - const compiler = getCompiler('./modules/issue-1191/issue-1191.js', { + it("issue #1191 - fallback to default getLocalIdent", async () => { + const compiler = getCompiler("./modules/issue-1191/issue-1191.js", { modules: { getLocalIdent: (ctx, localIdentName, localName) => - ctx.resourcePath.includes('custom') ? `custom-${localName}` : null, - localIdentName: '[local]', + ctx.resourcePath.includes("custom") ? `custom-${localName}` : null, + localIdentName: "[local]", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1191/issue-1191.css', stats) - ).toMatchSnapshot('module'); + getModuleSource("./modules/issue-1191/issue-1191.css", stats) + ).toMatchSnapshot("module"); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with the `exportGlobals` option (the `mode` option is `global`)', async () => { + it("should work with the `exportGlobals` option (the `mode` option is `global`)", async () => { const compiler = getCompiler( - './modules/exportGlobals-global/exportGlobals.js', + "./modules/exportGlobals-global/exportGlobals.js", { modules: { - mode: 'local', + mode: "local", exportGlobals: true, }, } @@ -731,21 +731,21 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/exportGlobals-global/exportGlobals.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/exportGlobals-global/exportGlobals.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with the `exportGlobals` option (the `mode` option is `local`)', async () => { + it("should work with the `exportGlobals` option (the `mode` option is `local`)", async () => { const compiler = getCompiler( - './modules/exportGlobals-local/exportGlobals.js', + "./modules/exportGlobals-local/exportGlobals.js", { modules: { - mode: 'global', + mode: "global", exportGlobals: true, }, } @@ -753,21 +753,21 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/exportGlobals-local/exportGlobals.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/exportGlobals-local/exportGlobals.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with the `exportGlobals` option (the `mode` option is `pure`)', async () => { + it("should work with the `exportGlobals` option (the `mode` option is `pure`)", async () => { const compiler = getCompiler( - './modules/exportGlobals-pure/exportGlobals.js', + "./modules/exportGlobals-pure/exportGlobals.js", { modules: { - mode: 'pure', + mode: "pure", exportGlobals: true, }, } @@ -775,59 +775,59 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/exportGlobals-pure/exportGlobals.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/exportGlobals-pure/exportGlobals.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "auto" by default', async () => { - const compiler = getCompiler('./modules/mode/modules.js'); + const compiler = getCompiler("./modules/mode/modules.js"); const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "auto" by default with "modules" filename', async () => { - const compiler = getCompiler('./modules/mode/modules-2.js'); + const compiler = getCompiler("./modules/mode/modules-2.js"); const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.modules.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.modules.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "auto" by default for icss', async () => { - const compiler = getCompiler('./modules/mode/icss/icss.js'); + const compiler = getCompiler("./modules/mode/icss/icss.js"); const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/icss/relative.icss.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/icss/relative.icss.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "auto" when it is "false"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { auto: false, }, @@ -835,17 +835,17 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "auto" when it is "true"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { auto: true, }, @@ -853,17 +853,17 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a modules.auto RegExp that returns "true"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { auto: /relative\.module\.css$/, }, @@ -871,17 +871,17 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a modules.auto RegExp that returns "false"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { auto: /will no pass/, }, @@ -889,212 +889,212 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a modules.auto Function that returns "true"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { - auto: (relativePath) => relativePath.endsWith('module.css'), + auto: (relativePath) => relativePath.endsWith("module.css"), }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a modules.auto Function that returns "false"', async () => { - const compiler = getCompiler('./modules/mode/modules.js', { + const compiler = getCompiler("./modules/mode/modules.js", { modules: { - auto: (relativePath) => relativePath.endsWith('will no pass'), + auto: (relativePath) => relativePath.endsWith("will no pass"), }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/mode/relative.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/mode/relative.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should resolve package from node_modules with and without tilde', async () => { - const compiler = getCompiler('./modules/issue-914/source.js', { + it("should resolve package from node_modules with and without tilde", async () => { + const compiler = getCompiler("./modules/issue-914/source.js", { modules: true, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-914/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-914/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throw an error on unresolved import', async () => { - const compiler = getCompiler('./modules/unresolved/source.js', { + it("should throw an error on unresolved import", async () => { + const compiler = getCompiler("./modules/unresolved/source.js", { modules: true, }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); it('should work and respect the "localConvention" option with the "asIs" value', async () => { const compiler = getCompiler( - './modules/localsConvention/localsConvention.js', + "./modules/localsConvention/localsConvention.js", { modules: { - mode: 'local', - exportLocalsConvention: 'asIs', + mode: "local", + exportLocalsConvention: "asIs", }, } ); const stats = await compile(compiler); expect( - getModuleSource('./modules/localsConvention/localsConvention.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localsConvention/localsConvention.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "localConvention" option with the "camelCase" value', async () => { const compiler = getCompiler( - './modules/localsConvention/localsConvention.js', + "./modules/localsConvention/localsConvention.js", { modules: { - mode: 'local', - exportLocalsConvention: 'camelCase', + mode: "local", + exportLocalsConvention: "camelCase", }, } ); const stats = await compile(compiler); expect( - getModuleSource('./modules/localsConvention/localsConvention.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localsConvention/localsConvention.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "localConvention" option with the "camelCaseOnly" value', async () => { const compiler = getCompiler( - './modules/localsConvention/localsConvention.js', + "./modules/localsConvention/localsConvention.js", { modules: { - mode: 'local', - exportLocalsConvention: 'camelCaseOnly', + mode: "local", + exportLocalsConvention: "camelCaseOnly", }, } ); const stats = await compile(compiler); expect( - getModuleSource('./modules/localsConvention/localsConvention.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localsConvention/localsConvention.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "localConvention" option with the "dashes" value', async () => { const compiler = getCompiler( - './modules/localsConvention/localsConvention.js', + "./modules/localsConvention/localsConvention.js", { modules: { - mode: 'local', - exportLocalsConvention: 'dashes', + mode: "local", + exportLocalsConvention: "dashes", }, } ); const stats = await compile(compiler); expect( - getModuleSource('./modules/localsConvention/localsConvention.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localsConvention/localsConvention.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "localConvention" option with the "dashesOnly" value', async () => { const compiler = getCompiler( - './modules/localsConvention/localsConvention.js', + "./modules/localsConvention/localsConvention.js", { modules: { - mode: 'local', - exportLocalsConvention: 'dashesOnly', + mode: "local", + exportLocalsConvention: "dashesOnly", }, } ); const stats = await compile(compiler); expect( - getModuleSource('./modules/localsConvention/localsConvention.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/localsConvention/localsConvention.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work and respect the "exportOnlyLocals" option', async () => { - const compiler = getCompiler('./modules/composes/composes.js', { + const compiler = getCompiler("./modules/composes/composes.js", { modules: { - mode: 'local', - localIdentName: '_[local]', + mode: "local", + localIdentName: "_[local]", exportOnlyLocals: true, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "exportOnlyLocals" and "esModule" with "true" value options', async () => { - const compiler = getCompiler('./modules/composes/composes.js', { + const compiler = getCompiler("./modules/composes/composes.js", { modules: { - mode: 'local', - localIdentName: '_[local]', + mode: "local", + localIdentName: "_[local]", exportOnlyLocals: true, }, esModule: true, @@ -1102,20 +1102,20 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "exportOnlyLocals" and "esModule" with "false" value options', async () => { - const compiler = getCompiler('./modules/composes/composes.js', { + const compiler = getCompiler("./modules/composes/composes.js", { modules: { - mode: 'local', - localIdentName: '_[local]', + mode: "local", + localIdentName: "_[local]", exportOnlyLocals: true, }, esModule: false, @@ -1123,31 +1123,31 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with an empty object value', async () => { - const compiler = getCompiler('./modules/pure/pure.js', { modules: {} }); + it("should work with an empty object value", async () => { + const compiler = getCompiler("./modules/pure/pure.js", { modules: {} }); const stats = await compile(compiler); - expect(getModuleSource('./modules/pure/pure.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/pure/pure.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "namedExport" option', async () => { - const compiler = getCompiler('./modules/namedExport/base/index.js', { + const compiler = getCompiler("./modules/namedExport/base/index.js", { modules: { namedExport: true, }, @@ -1155,17 +1155,17 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/namedExport/base/index.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/namedExport/base/index.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "namedExport" option with nested import', async () => { - const compiler = getCompiler('./modules/namedExport/nested/index.js', { + const compiler = getCompiler("./modules/namedExport/nested/index.js", { esModule: true, modules: { namedExport: true, @@ -1174,91 +1174,91 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/namedExport/nested/index.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/namedExport/nested/index.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work js template with "namedExport" option', async () => { - const compiler = getCompiler('./modules/namedExport/template/index.js', { + const compiler = getCompiler("./modules/namedExport/template/index.js", { esModule: true, modules: { - localIdentName: '[local]', + localIdentName: "[local]", namedExport: true, }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/namedExport/template/index.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/namedExport/template/index.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work when the "namedExport" is enabled and the "exportLocalsConvention" options has "dashesOnly" value', async () => { - const compiler = getCompiler('./modules/namedExport/dashesOnly/index.js', { + const compiler = getCompiler("./modules/namedExport/dashesOnly/index.js", { modules: { - localIdentName: '[local]', + localIdentName: "[local]", namedExport: true, - exportLocalsConvention: 'dashesOnly', + exportLocalsConvention: "dashesOnly", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/namedExport/dashesOnly/index.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/namedExport/dashesOnly/index.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); it('should work with composes when the "namedExport" is enabled and "exportLocalsConvention" options has "dashesOnly" value', async () => { - const compiler = getCompiler('./modules/namedExport/composes/composes.js', { + const compiler = getCompiler("./modules/namedExport/composes/composes.js", { modules: { - localIdentName: '_[local]', + localIdentName: "_[local]", namedExport: true, - exportLocalsConvention: 'dashesOnly', + exportLocalsConvention: "dashesOnly", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/namedExport/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/namedExport/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should throw error with composes when the "namedExport" is enabled and "exportLocalsConvention" options has invalid value', async () => { - const compiler = getCompiler('./modules/namedExport/composes/composes.js', { + const compiler = getCompiler("./modules/namedExport/composes/composes.js", { modules: { - localIdentName: '_[local]', + localIdentName: "_[local]", namedExport: true, - exportLocalsConvention: 'dashes', + exportLocalsConvention: "dashes", }, }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); it('should throw an error when the "namedExport" option is "true", but the "esModule" is "false"', async () => { - const compiler = getCompiler('./modules/namedExport/base/index.js', { + const compiler = getCompiler("./modules/namedExport/base/index.js", { esModule: false, modules: { namedExport: true, @@ -1266,26 +1266,26 @@ describe('"modules" option', () => { }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); it('should throw an error when the "namedExport" is enabled and the "exportLocalsConvention" options has not "camelCaseOnly" value', async () => { - const compiler = getCompiler('./modules/namedExport/broken/index.js', { + const compiler = getCompiler("./modules/namedExport/broken/index.js", { esModule: true, modules: { namedExport: true, - exportLocalsConvention: 'dashes', + exportLocalsConvention: "dashes", }, }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); - it('should throw an error when class has unsupported name (JavaScript reserved words)', async () => { - const compiler = getCompiler('./modules/namedExport/broken/index.js', { + it("should throw an error when class has unsupported name (JavaScript reserved words)", async () => { + const compiler = getCompiler("./modules/namedExport/broken/index.js", { esModule: true, modules: { namedExport: true, @@ -1293,15 +1293,15 @@ describe('"modules" option', () => { }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); it('should work with "exportOnlyLocals" and "namedExport" option', async () => { - const compiler = getCompiler('./modules/composes/composes-named.js', { + const compiler = getCompiler("./modules/composes/composes-named.js", { modules: { - mode: 'local', - localIdentName: '_[local]', + mode: "local", + localIdentName: "_[local]", namedExport: true, exportOnlyLocals: true, }, @@ -1310,52 +1310,52 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "url" and "namedExport"', async () => { - const compiler = getCompiler('./modules/url/source.js', { + const compiler = getCompiler("./modules/url/source.js", { modules: { namedExport: true, }, }); const stats = await compile(compiler); - expect(getModuleSource('./modules/url/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/url/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with "url"', async () => { - const compiler = getCompiler('./modules/url/source.js', { + const compiler = getCompiler("./modules/url/source.js", { modules: true, }); const stats = await compile(compiler); - expect(getModuleSource('./modules/url/source.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./modules/url/source.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); const icssTestCasesPath = path.join( __dirname, - 'fixtures/modules/icss/tests-cases' + "fixtures/modules/icss/tests-cases" ); const icssTestCases = fs.readdirSync(icssTestCasesPath); @@ -1365,7 +1365,7 @@ describe('"modules" option', () => { `./modules/icss/tests-cases/${name}/source.js`, { modules: { - compileType: 'icss', + compileType: "icss", }, } ); @@ -1373,21 +1373,21 @@ describe('"modules" option', () => { expect( getModuleSource(`./modules/icss/tests-cases/${name}/source.css`, stats) - ).toMatchSnapshot('module'); + ).toMatchSnapshot("module"); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); it('show work with the "compileType" and "exportOnlyLocals" options', async () => { const compiler = getCompiler( - './modules/icss/tests-cases/import/source.js', + "./modules/icss/tests-cases/import/source.js", { modules: { - compileType: 'icss', + compileType: "icss", exportOnlyLocals: true, }, } @@ -1395,21 +1395,21 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/icss/tests-cases/import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/icss/tests-cases/import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('show work with the "compileType" and "namedExport" options', async () => { const compiler = getCompiler( - './modules/icss/tests-cases/import/source.js', + "./modules/icss/tests-cases/import/source.js", { modules: { - compileType: 'icss', + compileType: "icss", namedExport: true, }, } @@ -1417,76 +1417,76 @@ describe('"modules" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./modules/icss/tests-cases/import/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/icss/tests-cases/import/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('show work with the "compileType" option using the "module" value', async () => { - const compiler = getCompiler('./modules/composes/composes.js', { + const compiler = getCompiler("./modules/composes/composes.js", { modules: { - compileType: 'module', + compileType: "module", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/composes/composes.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/composes/composes.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should emit warning when localIdentName is emoji', async () => { - const compiler = getCompiler('./modules/pure/pure.js', { + it("should emit warning when localIdentName is emoji", async () => { + const compiler = getCompiler("./modules/pure/pure.js", { modules: { - localIdentName: '[emoji:0]', + localIdentName: "[emoji:0]", }, }); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should work with `@` character in scoped packages', async () => { - const compiler = getCompiler('./modules/issue-1223/issue-1223.js', { + it("should work with `@` character in scoped packages", async () => { + const compiler = getCompiler("./modules/issue-1223/issue-1223.js", { modules: { - localIdentName: '[path]-[local]', + localIdentName: "[path]-[local]", }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1223/@foo/bar/index.module.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1223/@foo/bar/index.module.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with the "animation" ', async () => { - const compiler = getCompiler('./modules/issue-1228/source.js', { - modules: { mode: 'local' }, + const compiler = getCompiler("./modules/issue-1228/source.js", { + modules: { mode: "local" }, }); const stats = await compile(compiler); expect( - getModuleSource('./modules/issue-1228/source.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./modules/issue-1228/source.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); diff --git a/test/runtime/api.test.js b/test/runtime/api.test.js index 6518ad6e..3dfac5a2 100644 --- a/test/runtime/api.test.js +++ b/test/runtime/api.test.js @@ -4,10 +4,10 @@ /* eslint-disable func-names */ -const api = require('../../src/runtime/api'); -const cssWithMappingToString = require('../../src/runtime/cssWithMappingToString'); +const api = require("../../src/runtime/api"); +const cssWithMappingToString = require("../../src/runtime/cssWithMappingToString"); -describe('api', () => { +describe("api", () => { beforeAll(() => { global.btoa = function btoa(str) { let buffer = null; @@ -15,10 +15,10 @@ describe('api', () => { if (str instanceof Buffer) { buffer = str; } else { - buffer = Buffer.from(str.toString(), 'binary'); + buffer = Buffer.from(str.toString(), "binary"); } - return buffer.toString('base64'); + return buffer.toString("base64"); }; }); @@ -26,92 +26,92 @@ describe('api', () => { global.btoa = null; }); - it('should toString a single module', () => { + it("should toString a single module", () => { const m = api(function (i) { return i[1]; }); - m.push([1, 'body { a: 1; }', '']); + m.push([1, "body { a: 1; }", ""]); expect(m.toString()).toMatchSnapshot(); }); - it('should toString multiple modules', () => { + it("should toString multiple modules", () => { const m = api(function (i) { return i[1]; }); - m.push([2, 'body { b: 2; }', '']); - m.push([1, 'body { a: 1; }', '']); + m.push([2, "body { b: 2; }", ""]); + m.push([1, "body { a: 1; }", ""]); expect(m.toString()).toMatchSnapshot(); }); - it('should toString with media query', () => { + it("should toString with media query", () => { const m = api(function (i) { return i[1]; }); - const m1 = [1, 'body { a: 1; }', 'screen']; - const m2 = [2, 'body { b: 2; }', '']; - const m3 = [3, 'body { c: 3; }', '']; - const m4 = [4, 'body { d: 4; }', '']; + const m1 = [1, "body { a: 1; }", "screen"]; + const m2 = [2, "body { b: 2; }", ""]; + const m3 = [3, "body { c: 3; }", ""]; + const m4 = [4, "body { d: 4; }", ""]; - m.i([m2, m3], ''); - m.i([m2], ''); - m.i([m2, m4], 'print'); + m.i([m2, m3], ""); + m.i([m2], ""); + m.i([m2, m4], "print"); m.push(m1); expect(m.toString()).toMatchSnapshot(); }); - it('should import modules', () => { + it("should import modules", () => { const m = api(function (i) { return i[1]; }); - const m1 = [1, 'body { a: 1; }', '(orientation:landscape)']; - const m2 = [2, 'body { b: 2; }', '']; - const m3 = [3, 'body { c: 3; }', '']; - const m4 = [4, 'body { d: 4; }', '']; - - m.i([m2, m3], ''); - m.i([m2], ''); - m.i([m2, m4], 'print'); - m.i([m1], 'screen'); + const m1 = [1, "body { a: 1; }", "(orientation:landscape)"]; + const m2 = [2, "body { b: 2; }", ""]; + const m3 = [3, "body { c: 3; }", ""]; + const m4 = [4, "body { d: 4; }", ""]; + + m.i([m2, m3], ""); + m.i([m2], ""); + m.i([m2, m4], "print"); + m.i([m1], "screen"); m.push(m1); expect(m.toString()).toMatchSnapshot(); }); - it('should import named modules', () => { + it("should import named modules", () => { const m = api(function (i) { return i[1]; }); - const m1 = ['./module1', 'body { a: 1; }', 'screen']; - const m2 = ['./module2', 'body { b: 2; }', '']; - const m3 = ['./module3', 'body { c: 3; }', '']; - const m4 = ['./module4', 'body { d: 4; }', '']; - - m.i([m2, m3], ''); - m.i([m2], ''); - m.i([m2, m4], 'print'); + const m1 = ["./module1", "body { a: 1; }", "screen"]; + const m2 = ["./module2", "body { b: 2; }", ""]; + const m3 = ["./module3", "body { c: 3; }", ""]; + const m4 = ["./module4", "body { d: 4; }", ""]; + + m.i([m2, m3], ""); + m.i([m2], ""); + m.i([m2, m4], "print"); m.push(m1); expect(m.toString()).toMatchSnapshot(); }); - it('should toString with source mapping', () => { + it("should toString with source mapping", () => { const m = api(cssWithMappingToString); m.push([ 1, - 'body { a: 1; }', - '', + "body { a: 1; }", + "", { - file: 'test.scss', - sources: ['./path/to/test.scss'], - mappings: 'AAAA;', - sourceRoot: 'webpack://', + file: "test.scss", + sources: ["./path/to/test.scss"], + mappings: "AAAA;", + sourceRoot: "webpack://", }, ]); @@ -123,64 +123,64 @@ describe('api', () => { m.push([ 1, - 'body { a: 1; }', - '', + "body { a: 1; }", + "", { - file: 'test.scss', - sources: ['./path/to/test.scss'], - mappings: 'AAAA;', + file: "test.scss", + sources: ["./path/to/test.scss"], + mappings: "AAAA;", }, ]); expect(m.toString()).toMatchSnapshot(); }); - it('should toString without source mapping if btoa not available', () => { + it("should toString without source mapping if btoa not available", () => { global.btoa = null; const m = api(cssWithMappingToString); m.push([ 1, - 'body { a: 1; }', - '', + "body { a: 1; }", + "", { - file: 'test.scss', - sources: ['./path/to/test.scss'], - mappings: 'AAAA;', - sourceRoot: 'webpack://', + file: "test.scss", + sources: ["./path/to/test.scss"], + mappings: "AAAA;", + sourceRoot: "webpack://", }, ]); expect(m.toString()).toMatchSnapshot(); }); - it('should import modules with dedupe', () => { + it("should import modules with dedupe", () => { const m = api(function (i) { return i[1]; }); - const m1 = [null, 'body { b: 1; }', '']; - const m2 = ['./module2', 'body { b: 2; }', '']; - const m3 = ['./module3', '.button { b: 3; }', '']; + const m1 = [null, "body { b: 1; }", ""]; + const m2 = ["./module2", "body { b: 2; }", ""]; + const m3 = ["./module3", ".button { b: 3; }", ""]; - m.i([m1], '', true); - m.i([m2], '', true); - m.i([m3], '', true); - m.i([m3], '', true); - m.i([m3], '', true); + m.i([m1], "", true); + m.i([m2], "", true); + m.i([m3], "", true); + m.i([m3], "", true); + m.i([m3], "", true); expect(m.toString()).toMatchSnapshot(); expect(m.length).toBe(3); }); - it('should import modules when module string', () => { + it("should import modules when module string", () => { const m = api(function (i) { return i[1]; }); - m.i('.button { b: 2; }'); - m.i(''); + m.i(".button { b: 2; }"); + m.i(""); expect(m.toString()).toMatchSnapshot(); }); diff --git a/test/runtime/getUrl.test.js b/test/runtime/getUrl.test.js index 809cd466..96b6149b 100644 --- a/test/runtime/getUrl.test.js +++ b/test/runtime/getUrl.test.js @@ -2,36 +2,36 @@ * @jest-environment jsdom */ -const getUrl = require('../../src/runtime/getUrl'); +const getUrl = require("../../src/runtime/getUrl"); -describe('escape', () => { - it('should escape url', () => { +describe("escape", () => { + it("should escape url", () => { expect(getUrl(true)).toMatchSnapshot(); expect(getUrl(null)).toMatchSnapshot(); // eslint-disable-next-line no-undefined expect(getUrl(undefined)).toMatchSnapshot(); - expect(getUrl('image.png')).toMatchSnapshot(); + expect(getUrl("image.png")).toMatchSnapshot(); expect(getUrl('"image.png"')).toMatchSnapshot(); expect(getUrl("'image.png'")).toMatchSnapshot(); - expect(getUrl('image other.png')).toMatchSnapshot(); + expect(getUrl("image other.png")).toMatchSnapshot(); expect(getUrl('"image other.png"')).toMatchSnapshot(); expect(getUrl("'image other.png'")).toMatchSnapshot(); expect(getUrl('image"other.png')).toMatchSnapshot(); - expect(getUrl('image\nother.png')).toMatchSnapshot(); + expect(getUrl("image\nother.png")).toMatchSnapshot(); - expect(getUrl('image.png', { hash: '#hash' })).toMatchSnapshot(); - expect(getUrl('"image.png"', { hash: '#hash' })).toMatchSnapshot(); - expect(getUrl("'image.png'", { hash: '#hash' })).toMatchSnapshot(); - expect(getUrl('image other.png', { hash: '#hash' })).toMatchSnapshot(); - expect(getUrl('"image other.png"', { hash: '#hash' })).toMatchSnapshot(); - expect(getUrl("'image other.png'", { hash: '#hash' })).toMatchSnapshot(); + expect(getUrl("image.png", { hash: "#hash" })).toMatchSnapshot(); + expect(getUrl('"image.png"', { hash: "#hash" })).toMatchSnapshot(); + expect(getUrl("'image.png'", { hash: "#hash" })).toMatchSnapshot(); + expect(getUrl("image other.png", { hash: "#hash" })).toMatchSnapshot(); + expect(getUrl('"image other.png"', { hash: "#hash" })).toMatchSnapshot(); + expect(getUrl("'image other.png'", { hash: "#hash" })).toMatchSnapshot(); - expect(getUrl('image other.png', { needQuotes: true })).toMatchSnapshot(); + expect(getUrl("image other.png", { needQuotes: true })).toMatchSnapshot(); expect(getUrl("'image other.png'", { needQuotes: true })).toMatchSnapshot(); expect(getUrl('"image other.png"', { needQuotes: true })).toMatchSnapshot(); expect( - getUrl({ default: 'image.png', __esModule: true }) + getUrl({ default: "image.png", __esModule: true }) ).toMatchSnapshot(); expect( getUrl({ default: "'image.png'", __esModule: true }) @@ -40,7 +40,7 @@ describe('escape', () => { getUrl({ default: '"image.png"', __esModule: true }) ).toMatchSnapshot(); expect( - getUrl({ default: 'image other.png', __esModule: true }) + getUrl({ default: "image other.png", __esModule: true }) ).toMatchSnapshot(); expect( getUrl({ default: '"image other.png"', __esModule: true }) @@ -52,28 +52,28 @@ describe('escape', () => { getUrl({ default: 'image"other.png', __esModule: true }) ).toMatchSnapshot(); expect( - getUrl({ default: 'image\nother.png', __esModule: true }) + getUrl({ default: "image\nother.png", __esModule: true }) ).toMatchSnapshot(); expect( - getUrl({ default: 'image.png', __esModule: true }, { hash: '#hash' }) + getUrl({ default: "image.png", __esModule: true }, { hash: "#hash" }) ).toMatchSnapshot(); expect( - getUrl({ default: '"image.png"', __esModule: true }, { hash: '#hash' }) + getUrl({ default: '"image.png"', __esModule: true }, { hash: "#hash" }) ).toMatchSnapshot(); expect( - getUrl({ default: "'image.png'", __esModule: true }, { hash: '#hash' }) + getUrl({ default: "'image.png'", __esModule: true }, { hash: "#hash" }) ).toMatchSnapshot(); expect( getUrl( - { default: 'image other.png', __esModule: true }, - { hash: '#hash' } + { default: "image other.png", __esModule: true }, + { hash: "#hash" } ) ).toMatchSnapshot(); expect( getUrl( - { default: 'image other.png', __esModule: true }, + { default: "image other.png", __esModule: true }, { needQuotes: true } ) ).toMatchSnapshot(); @@ -91,40 +91,40 @@ describe('escape', () => { ).toMatchSnapshot(); expect( - getUrl('image other.png', { hash: '#hash', needQuotes: true }) + getUrl("image other.png", { hash: "#hash", needQuotes: true }) ).toMatchSnapshot(); expect( - getUrl('"image other.png"', { hash: '#hash', needQuotes: true }) + getUrl('"image other.png"', { hash: "#hash", needQuotes: true }) ).toMatchSnapshot(); expect( - getUrl("'image other.png'", { hash: '#hash', needQuotes: true }) + getUrl("'image other.png'", { hash: "#hash", needQuotes: true }) ).toMatchSnapshot(); expect( - getUrl('image other.png', { hash: '#hash', needQuotes: true }) + getUrl("image other.png", { hash: "#hash", needQuotes: true }) ).toMatchSnapshot(); expect( getUrl( - { default: 'image other.png', __esModule: true }, - { hash: '#hash', needQuotes: true } + { default: "image other.png", __esModule: true }, + { hash: "#hash", needQuotes: true } ) ).toMatchSnapshot(); expect( getUrl( { default: '"image other.png"', __esModule: true }, - { hash: '#hash', needQuotes: true } + { hash: "#hash", needQuotes: true } ) ).toMatchSnapshot(); expect( getUrl( { default: "'image other.png'", __esModule: true }, - { hash: '#hash', needQuotes: true } + { hash: "#hash", needQuotes: true } ) ).toMatchSnapshot(); expect( getUrl( - { default: 'image other.png', __esModule: true }, - { hash: '#hash', needQuotes: true } + { default: "image other.png", __esModule: true }, + { hash: "#hash", needQuotes: true } ) ).toMatchSnapshot(); }); diff --git a/test/sourceMap-option.test.js b/test/sourceMap-option.test.js index 2864ef0c..7b5049f0 100644 --- a/test/sourceMap-option.test.js +++ b/test/sourceMap-option.test.js @@ -1,8 +1,8 @@ -import path from 'path'; +import path from "path"; -import webpack from 'webpack'; -import postcssPresetEnv from 'postcss-preset-env'; -import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +import webpack from "webpack"; +import postcssPresetEnv from "postcss-preset-env"; +import MiniCssExtractPlugin from "mini-css-extract-plugin"; import { compile, @@ -12,63 +12,63 @@ import { getModuleSource, getWarnings, readAsset, -} from './helpers/index'; +} from "./helpers/index"; jest.setTimeout(10000); describe('"sourceMap" option', () => { - describe('not specified', () => { - it('should not generate source maps', async () => { - const compiler = getCompiler('./source-map/basic.js'); + describe("not specified", () => { + it("should not generate source maps", async () => { + const compiler = getCompiler("./source-map/basic.js"); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); - describe('true', () => { - it('should generate source maps', async () => { - const compiler = getCompiler('./source-map/basic.js', { + describe("true", () => { + it("should generate source maps", async () => { + const compiler = getCompiler("./source-map/basic.js", { sourceMap: true, }); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should generate source maps #2', async () => { - const compiler = getCompiler('./source-map/with-query.js', { + it("should generate source maps #2", async () => { + const compiler = getCompiler("./source-map/with-query.js", { sourceMap: true, }); const stats = await compile(compiler); expect( - getModuleSource('./source-map/with-query.css?url=false', stats) - ).toMatchSnapshot('module'); + getModuleSource("./source-map/with-query.css?url=false", stats) + ).toMatchSnapshot("module"); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should generate source maps when previous loader does not generate source maps', async () => { + it("should generate source maps when previous loader does not generate source maps", async () => { const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -77,13 +77,13 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { sourceMap: null, @@ -97,26 +97,26 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps without "sourceRoot"', async () => { const absolutePath = path.resolve( __dirname, - 'fixtures', - 'source-map', - 'basic.css' + "fixtures", + "source-map", + "basic.css" ); const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -125,20 +125,20 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { sourceMap: JSON.stringify({ version: 3, sources: [absolutePath], names: [], - mappings: 'AAAA,6BAA6B;;AAE7B;EACE,UAAU;AACZ', + mappings: "AAAA,6BAA6B;;AAE7B;EACE,UAAU;AACZ", file: absolutePath, sourcesContent: [ '@import "./nested/nested.css";\n\n.class {\n color: red;\n}\n', @@ -154,30 +154,30 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should generate source maps when previous loader generates different source in source maps', async () => { + it("should generate source maps when previous loader generates different source in source maps", async () => { const absoluteSourceRoot = path.resolve( __dirname, - 'fixtures', - 'source-map' + "fixtures", + "source-map" ); - const absolutePath = path.resolve(absoluteSourceRoot, 'basic-1.css'); + const absolutePath = path.resolve(absoluteSourceRoot, "basic-1.css"); const relativePath = path.relative( absoluteSourceRoot, - path.resolve(__dirname, 'fixtures', 'source-map', 'basic-2.css') + path.resolve(__dirname, "fixtures", "source-map", "basic-2.css") ); const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -186,13 +186,13 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { sourceMap: JSON.stringify({ @@ -204,21 +204,21 @@ describe('"sourceMap" option', () => { // Relative path relativePath, // Absolute URL - 'https://example.com/foo.css', + "https://example.com/foo.css", // Scheme-relative URL, - '//example.com/foo.css', + "//example.com/foo.css", // Non-standard postcss syntax ` { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps with "sourceRoot"', async () => { const absoluteSourceRoot = path.resolve( __dirname, - 'fixtures', - 'source-map' + "fixtures", + "source-map" ); const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -257,23 +257,23 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { sourceMap: JSON.stringify({ - foo: 'bar', + foo: "bar", version: 3, - sources: ['basic.css'], + sources: ["basic.css"], sourceRoot: absoluteSourceRoot, names: [], - mappings: 'AAAA,6BAA6B;;AAE7B;EACE,UAAU;AACZ', - file: 'basic.css', + mappings: "AAAA,6BAA6B;;AAE7B;EACE,UAAU;AACZ", + file: "basic.css", sourcesContent: [ '@import "./nested/nested.css";\n\n.class {\n color: red;\n}\n', ], @@ -288,19 +288,19 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps ("postcss-loader")', async () => { const compiler = getCompiler( - './source-map/basic-postcss.js', + "./source-map/basic-postcss.js", {}, { module: { @@ -309,13 +309,13 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true, }, }, { - loader: 'postcss-loader', + loader: "postcss-loader", options: { postcssOptions: { plugins: [postcssPresetEnv({ stage: 0 })], @@ -332,18 +332,18 @@ describe('"sourceMap" option', () => { const stats = await compile(compiler); expect( - getModuleSource('./source-map/basic.postcss.css', stats) - ).toMatchSnapshot('module'); + getModuleSource("./source-map/basic.postcss.css", stats) + ).toMatchSnapshot("module"); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps ("sass-loader")', async () => { const compiler = getCompiler( - './source-map/basic-scss.js', + "./source-map/basic-scss.js", {}, { module: { @@ -352,16 +352,16 @@ describe('"sourceMap" option', () => { test: /\.s[ca]ss$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true, }, }, { - loader: 'sass-loader', + loader: "sass-loader", options: { // eslint-disable-next-line global-require - implementation: require('sass'), + implementation: require("sass"), sourceMap: true, }, }, @@ -373,19 +373,19 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.scss', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.scss", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps ("less-loader")', async () => { const compiler = getCompiler( - './source-map/basic-less.js', + "./source-map/basic-less.js", {}, { module: { @@ -394,13 +394,13 @@ describe('"sourceMap" option', () => { test: /\.less$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true, }, }, { - loader: 'less-loader', + loader: "less-loader", options: { sourceMap: true, }, @@ -413,19 +413,19 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/base.less', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/base.less", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when previous loader generates source maps ("stylus-loader")', async () => { const compiler = getCompiler( - './source-map/basic-styl.js', + "./source-map/basic-styl.js", {}, { module: { @@ -434,13 +434,13 @@ describe('"sourceMap" option', () => { test: /\.styl$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true, }, }, { - loader: 'stylus-loader', + loader: "stylus-loader", options: { sourceMap: true, }, @@ -453,31 +453,31 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/base.styl', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/base.styl", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps and do not change "[contenthash]" on different platform', async () => { const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { - devtool: 'source-map', + devtool: "source-map", // webpack@4 has bug // It uses readableIdentifier to generate the sources, which uses the RequestShortener, // which has some problems with paths that are 2 folders above the context - context: path.resolve(__dirname, '..'), + context: path.resolve(__dirname, ".."), output: { - path: path.resolve(__dirname, './outputs'), - filename: '[name].[contenthash].bundle.js', - chunkFilename: '[name].[contenthash].chunk.js', - publicPath: '/webpack/public/path/', + path: path.resolve(__dirname, "./outputs"), + filename: "[name].[contenthash].bundle.js", + chunkFilename: "[name].[contenthash].chunk.js", + publicPath: "/webpack/public/path/", }, module: { rules: [ @@ -485,7 +485,7 @@ describe('"sourceMap" option', () => { test: /\.css$/i, rules: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, ], @@ -500,35 +500,35 @@ describe('"sourceMap" option', () => { ).find((assetName) => /\.js$/.test(assetName)); expect(chunkName).toBe( - webpack.version[0] === '5' - ? 'main.12fc65e5279709bf97a4.bundle.js' - : 'main.0c7724aa71a6ab6d45fd.bundle.js' + webpack.version[0] === "5" + ? "main.c3447e78abcd04637737.bundle.js" + : "main.19efc497c5c37fc5e355.bundle.js" ); expect( - getModuleSource('fixtures/source-map/basic.css', stats) - ).toMatchSnapshot('module'); + getModuleSource("fixtures/source-map/basic.css", stats) + ).toMatchSnapshot("module"); expect(getExecutedCode(chunkName, compiler, stats)).toMatchSnapshot( - 'result' + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should generate source maps when css was extracted', async () => { + it("should generate source maps when css was extracted", async () => { const compiler = getCompiler( - './source-map/extract.js', + "./source-map/extract.js", {}, { - devtool: 'source-map', + devtool: "source-map", output: { - path: path.resolve(__dirname, '../outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', + path: path.resolve(__dirname, "../outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", }, plugins: [ new MiniCssExtractPlugin({ - filename: '[name].css', + filename: "[name].css", }), ], module: { @@ -540,7 +540,7 @@ describe('"sourceMap" option', () => { loader: MiniCssExtractPlugin.loader, }, { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, ], @@ -551,35 +551,35 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(readAsset('main.css', compiler, stats)).toMatchSnapshot( - 'extracted css' + expect(readAsset("main.css", compiler, stats)).toMatchSnapshot( + "extracted css" ); expect( - JSON.parse(readAsset('main.css.map', compiler, stats)) - ).toMatchSnapshot('source map'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + JSON.parse(readAsset("main.css.map", compiler, stats)) + ).toMatchSnapshot("source map"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should generate source maps when css was extracted and do not change "[contenthash]" on different platform', async () => { const compiler = getCompiler( - './source-map/extract.js', + "./source-map/extract.js", {}, { - devtool: 'source-map', + devtool: "source-map", // webpack@4 has bug // It uses readableIdentifier to generate the sources, which uses the RequestShortener, // which has some problems with paths that are 2 folders above the context - context: path.resolve(__dirname, '..'), + context: path.resolve(__dirname, ".."), output: { - path: path.resolve(__dirname, '../outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', + path: path.resolve(__dirname, "../outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", }, plugins: [ new MiniCssExtractPlugin({ - filename: '[name].[contenthash].css', + filename: "[name].[contenthash].css", }), ], module: { @@ -591,7 +591,7 @@ describe('"sourceMap" option', () => { loader: MiniCssExtractPlugin.loader, }, { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: true }, }, ], @@ -609,15 +609,15 @@ describe('"sourceMap" option', () => { expect(chunkName).toBe( // TODO still buggy on webpack@4 - webpack.version[0] === '5' ? 'main.0c4134a13ce273487b87.css' : chunkName + webpack.version[0] === "5" ? "main.0c4134a13ce273487b87.css" : chunkName ); expect( extractedCSS.replace( /=(.+?)\..+?\.css\.map/, - '=$1.xxxxxxxxxxxxxxxxxxxx.css.map' + "=$1.xxxxxxxxxxxxxxxxxxxx.css.map" ) - ).toMatchSnapshot('extracted css'); + ).toMatchSnapshot("extracted css"); const sourceMap = JSON.parse( readAsset(`${chunkName}.map`, compiler, stats) @@ -625,38 +625,38 @@ describe('"sourceMap" option', () => { sourceMap.file = sourceMap.file.replace( /^(.+?)\..+?\.css$/, - '$1.xxxxxxxxxxxxxxxxxxxx.css' + "$1.xxxxxxxxxxxxxxxxxxxx.css" ); sourceMap.sources = sourceMap.sources.map((source) => - source.replace('css-loader', '') + source.replace("css-loader", "") ); - expect(sourceMap).toMatchSnapshot('source map'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(sourceMap).toMatchSnapshot("source map"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); - describe('false', () => { - it('should not generate source maps', async () => { - const compiler = getCompiler('./source-map/basic.js', { + describe("false", () => { + it("should not generate source maps", async () => { + const compiler = getCompiler("./source-map/basic.js", { sourceMap: false, }); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should not generate source maps when previous loader does not generate source maps', async () => { + it("should not generate source maps when previous loader does not generate source maps", async () => { const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -665,13 +665,13 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: false }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { // eslint-disable-next-line no-undefined @@ -686,19 +686,19 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should not generate source maps when previous loader generates source maps', async () => { + it("should not generate source maps when previous loader generates source maps", async () => { const compiler = getCompiler( - './source-map/basic.js', + "./source-map/basic.js", {}, { module: { @@ -707,23 +707,23 @@ describe('"sourceMap" option', () => { test: /\.css$/i, use: [ { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: false }, }, { loader: path.resolve( __dirname, - './fixtures/source-map-loader.js' + "./fixtures/source-map-loader.js" ), options: { sourceMap: JSON.stringify({ - foo: 'bar', + foo: "bar", version: 3, - sources: ['basic.css'], + sources: ["basic.css"], names: [], - mappings: 'AAAA;EACE,UAAU;AACZ', - file: 'basic.css', - sourcesContent: ['.class {\n color: red;\n}\n'], + mappings: "AAAA;EACE,UAAU;AACZ", + file: "basic.css", + sourcesContent: [".class {\n color: red;\n}\n"], }), }, }, @@ -735,30 +735,30 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(getModuleSource('./source-map/basic.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./source-map/basic.css", stats)).toMatchSnapshot( + "module" ); expect( - getExecutedCode('main.bundle.js', compiler, stats) - ).toMatchSnapshot('result'); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + getExecutedCode("main.bundle.js", compiler, stats) + ).toMatchSnapshot("result"); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should generate source maps when css was extracted', async () => { + it("should generate source maps when css was extracted", async () => { const compiler = getCompiler( - './source-map/extract.js', + "./source-map/extract.js", {}, { output: { - path: path.resolve(__dirname, '../outputs'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - publicPath: '/webpack/public/path/', + path: path.resolve(__dirname, "../outputs"), + filename: "[name].bundle.js", + chunkFilename: "[name].chunk.js", + publicPath: "/webpack/public/path/", }, plugins: [ new MiniCssExtractPlugin({ - filename: '[name].css', + filename: "[name].css", }), ], module: { @@ -770,7 +770,7 @@ describe('"sourceMap" option', () => { loader: MiniCssExtractPlugin.loader, }, { - loader: path.resolve(__dirname, '../src'), + loader: path.resolve(__dirname, "../src"), options: { sourceMap: false }, }, ], @@ -781,11 +781,11 @@ describe('"sourceMap" option', () => { ); const stats = await compile(compiler); - expect(readAsset('main.css', compiler, stats)).toMatchSnapshot( - 'extracted css' + expect(readAsset("main.css", compiler, stats)).toMatchSnapshot( + "extracted css" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); }); }); diff --git a/test/url-option.test.js b/test/url-option.test.js index 649a20a2..566fa141 100644 --- a/test/url-option.test.js +++ b/test/url-option.test.js @@ -1,5 +1,5 @@ -import fs from 'fs'; -import path from 'path'; +import fs from "fs"; +import path from "path"; import { compile, @@ -8,52 +8,52 @@ import { getExecutedCode, getModuleSource, getWarnings, -} from './helpers/index'; +} from "./helpers/index"; describe('"url" option', () => { - it('should work when not specified', async () => { - const compiler = getCompiler('./url/url.js'); + it("should work when not specified", async () => { + const compiler = getCompiler("./url/url.js"); const stats = await compile(compiler); - expect(getModuleSource('./url/url.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./url/url.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "true"', async () => { - const compiler = getCompiler('./url/url.js', { url: true }); + const compiler = getCompiler("./url/url.js", { url: true }); const stats = await compile(compiler); - expect(getModuleSource('./url/url.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./url/url.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "false"', async () => { - const compiler = getCompiler('./url/url.js', { url: false }); + const compiler = getCompiler("./url/url.js", { url: false }); const stats = await compile(compiler); - expect(getModuleSource('./url/url.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./url/url.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should work with a value equal to "Function"', async () => { - const compiler = getCompiler('./url/url.js', { + const compiler = getCompiler("./url/url.js", { url: (url, resourcePath) => { - expect(typeof resourcePath === 'string').toBe(true); + expect(typeof resourcePath === "string").toBe(true); // Don't handle `img.png` - if (url.includes('img.png')) { + if (url.includes("img.png")) { return false; } @@ -62,89 +62,89 @@ describe('"url" option', () => { }); const stats = await compile(compiler); - expect(getModuleSource('./url/url.css', stats)).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getModuleSource("./url/url.css", stats)).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should resolve absolute path', async () => { + it("should resolve absolute path", async () => { // Create the file with absolute path - const fileDirectory = path.resolve(__dirname, 'fixtures', 'url'); - const file = path.resolve(fileDirectory, 'url-absolute.css'); - const absolutePath = path.resolve(fileDirectory, 'img.png'); + const fileDirectory = path.resolve(__dirname, "fixtures", "url"); + const file = path.resolve(fileDirectory, "url-absolute.css"); + const absolutePath = path.resolve(fileDirectory, "img.png"); const code = ` .background { background: url(${absolutePath}); } .background-other { - background: url(${absolutePath.replace(/e/g, '%65')}); + background: url(${absolutePath.replace(/e/g, "%65")}); } .background-other { - background: url('${absolutePath.replace(/e/g, '\\\ne')}'); + background: url('${absolutePath.replace(/e/g, "\\\ne")}'); } `; fs.writeFileSync(file, code); - const compiler = getCompiler('./url/url-absolute.js'); + const compiler = getCompiler("./url/url-absolute.js"); const stats = await compile(compiler); - expect(getModuleSource('./url/url-absolute.css', stats)).toMatchSnapshot( - 'module' + expect(getModuleSource("./url/url-absolute.css", stats)).toMatchSnapshot( + "module" ); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); it('should resolve "file" protocol path', async () => { // Create the file with absolute path - const fileDirectory = path.resolve(__dirname, 'fixtures', 'url'); - const file = path.resolve(fileDirectory, 'url-file-protocol.css'); + const fileDirectory = path.resolve(__dirname, "fixtures", "url"); + const file = path.resolve(fileDirectory, "url-file-protocol.css"); const absolutePath = path - .resolve(fileDirectory, 'img.png') - .replace(/\\/g, '/'); + .resolve(fileDirectory, "img.png") + .replace(/\\/g, "/"); const code = ` .background { background: url(file://${absolutePath}); } .background-other { - background: url(file://${absolutePath.replace(/e/g, '%65')}); + background: url(file://${absolutePath.replace(/e/g, "%65")}); } .background-other { - background: url('file://${absolutePath.replace(/e/g, '\\\ne')}'); + background: url('file://${absolutePath.replace(/e/g, "\\\ne")}'); } `; fs.writeFileSync(file, code); - const compiler = getCompiler('./url/url-file-protocol.js'); + const compiler = getCompiler("./url/url-file-protocol.js"); const stats = await compile(compiler); expect( - getModuleSource('./url/url-file-protocol.css', stats) - ).toMatchSnapshot('module'); - expect(getExecutedCode('main.bundle.js', compiler, stats)).toMatchSnapshot( - 'result' + getModuleSource("./url/url-file-protocol.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" ); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); }); - it('should throw an error on unresolved import', async () => { - const compiler = getCompiler('./url/url-unresolved.js'); + it("should throw an error on unresolved import", async () => { + const compiler = getCompiler("./url/url-unresolved.js"); const stats = await compile(compiler); - expect(getWarnings(stats)).toMatchSnapshot('warnings'); - expect(getErrors(stats, true)).toMatchSnapshot('errors'); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats, true)).toMatchSnapshot("errors"); }); }); diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 748c8c56..a4433113 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -1,96 +1,96 @@ -import { getCompiler, compile } from './helpers/index'; +import { getCompiler, compile } from "./helpers/index"; -describe('validate options', () => { +describe("validate options", () => { const tests = { url: { success: [true, false, () => {}], - failure: ['true'], + failure: ["true"], }, import: { success: [true, false, () => {}], - failure: ['true'], + failure: ["true"], }, modules: { success: [ true, false, - 'global', - 'local', - 'pure', - { compileType: 'module' }, - { compileType: 'icss' }, - { mode: 'global' }, - { mode: 'local' }, - { mode: 'pure' }, - { mode: () => 'local' }, - { localIdentName: '[path][name]__[local]--[hash:base64:5]' }, - { localIdentContext: 'context' }, - { localIdentHashPrefix: 'hash' }, + "global", + "local", + "pure", + { compileType: "module" }, + { compileType: "icss" }, + { mode: "global" }, + { mode: "local" }, + { mode: "pure" }, + { mode: () => "local" }, + { localIdentName: "[path][name]__[local]--[hash:base64:5]" }, + { localIdentContext: "context" }, + { localIdentHashPrefix: "hash" }, { getLocalIdent: (loaderContext, localIdentName, localName) => localName, }, - { localIdentRegExp: 'page-(.*)\\.js' }, + { localIdentRegExp: "page-(.*)\\.js" }, { localIdentRegExp: /page-(.*)\.js/ }, { exportGlobals: true }, { auto: true }, { auto: false }, { auto: /custom-regex/ }, { auto: () => true }, - { exportLocalsConvention: 'asIs' }, - { exportLocalsConvention: 'camelCase' }, - { exportLocalsConvention: 'camelCaseOnly' }, - { exportLocalsConvention: 'dashes' }, - { exportLocalsConvention: 'dashesOnly' }, + { exportLocalsConvention: "asIs" }, + { exportLocalsConvention: "camelCase" }, + { exportLocalsConvention: "camelCaseOnly" }, + { exportLocalsConvention: "dashes" }, + { exportLocalsConvention: "dashesOnly" }, { namedExport: true }, { namedExport: false }, { exportOnlyLocals: true }, { exportOnlyLocals: false }, ], failure: [ - 'true', - 'globals', - 'locals', - 'pures', - { compileType: 'unknown' }, + "true", + "globals", + "locals", + "pures", + { compileType: "unknown" }, { mode: true }, - { mode: 'globals' }, - { mode: 'locals' }, - { mode: 'pures' }, + { mode: "globals" }, + { mode: "locals" }, + { mode: "pures" }, { localIdentName: true }, { localIdentContext: true }, { localIdentHashPrefix: true }, { getLocalIdent: [] }, { localIdentRegExp: true }, - { exportGlobals: 'invalid' }, - { auto: 'invalid' }, - { exportLocalsConvention: 'unknown' }, - { namedExport: 'invalid' }, - { exportOnlyLocals: 'invalid' }, + { exportGlobals: "invalid" }, + { auto: "invalid" }, + { exportLocalsConvention: "unknown" }, + { namedExport: "invalid" }, + { exportOnlyLocals: "invalid" }, ], }, sourceMap: { success: [true, false], - failure: ['true'], + failure: ["true"], }, importLoaders: { - success: [false, 0, 1, 2, '1'], + success: [false, 0, 1, 2, "1"], failure: [2.5], }, esModule: { success: [true, false], - failure: ['true'], + failure: ["true"], }, unknown: { success: [], - failure: [1, true, false, 'test', /test/, [], {}, { foo: 'bar' }], + failure: [1, true, false, "test", /test/, [], {}, { foo: "bar" }], }, }; function stringifyValue(value) { if ( Array.isArray(value) || - (value && typeof value === 'object' && value.constructor === Object) + (value && typeof value === "object" && value.constructor === Object) ) { return JSON.stringify(value); } @@ -100,28 +100,28 @@ describe('validate options', () => { async function createTestCase(key, value, type) { it(`should ${ - type === 'success' ? 'successfully validate' : 'throw an error on' + type === "success" ? "successfully validate" : "throw an error on" } the "${key}" option with "${stringifyValue(value)}" value`, async () => { const options = { [key]: value }; if ( - key === 'modules' && - typeof value === 'object' && + key === "modules" && + typeof value === "object" && value.namedExport === true ) { options.esModule = true; } - const compiler = getCompiler('simple.js', options); + const compiler = getCompiler("simple.js", options); let stats; try { stats = await compile(compiler); } finally { - if (type === 'success') { + if (type === "success") { expect(stats.hasErrors()).toBe(false); - } else if (type === 'failure') { + } else if (type === "failure") { const { compilation: { errors }, } = stats;