From f4234e458b33de5890e33b1be3e7725d36d3552a Mon Sep 17 00:00:00 2001 From: "Christopher S. Case" Date: Fri, 14 Jan 2022 11:33:20 -0600 Subject: [PATCH] fix: backported disabled auto importing `fiber` on node >= 16 (#1014) --- .eslintrc.js | 3 + .github/workflows/nodejs.yml | 2 +- README.md | 4 +- package-lock.json | 495 +++------------------------ package.json | 2 +- src/utils.js | 9 +- test/additionalData-option.test.js | 17 +- test/implementation-option.test.js | 28 +- test/loader.test.js | 26 +- test/sassOptions-option.test.js | 27 +- test/sourceMap-options.test.js | 17 +- test/validate-options.test.js | 17 +- test/webpackImporter-options.test.js | 17 +- 13 files changed, 179 insertions(+), 485 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 29e7717f..197e7300 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,7 @@ module.exports = { root: true, extends: ["@webpack-contrib/eslint-config-webpack", "prettier"], + parserOptions: { + ecmaVersion: 2020, + }, }; diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index e599f545..c84f636a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -55,7 +55,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version: [10.x, 12.x, 14.x] + node-version: [10.x, 12.x, 14.x, 16.x] webpack-version: [4, latest] runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index e8911681..dd514ccc 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,9 @@ module.exports = { Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice as fast as asynchronous compilation** by default, due to the overhead of asynchronous callbacks. To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers) package to call asynchronous importers from the synchronous code path. -We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package (setup `sassOptions.fiber`) if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package). +We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers) package (setup `sassOptions.fiber`) for `Node.js` less v16.0.0 if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package). + +> Fibers is not compatible with `Node.js` v16.0.0 or later ([see introduction to readme](https://github.com/laverdet/node-fibers)). **package.json** diff --git a/package-lock.json b/package-lock.json index c9f549d0..8239280f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,8 @@ "requires": true, "packages": { "": { - "version": "10.1.1", + "name": "sass-loader", + "version": "10.2.0", "license": "MIT", "dependencies": { "klona": "^2.0.4", @@ -41,7 +42,7 @@ "lint-staged": "^10.5.1", "material-components-web": "^8.0.0", "memfs": "^3.2.0", - "node-sass": "^5.0.0", + "node-sass": "^6.0.1", "npm-run-all": "^4.1.5", "prettier": "^2.1.2", "sass": "^1.29.0", @@ -12930,18 +12931,6 @@ "node": ">=0.10.0" } }, - "node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, "node_modules/modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -13222,9 +13211,9 @@ "dev": true }, "node_modules/node-sass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-5.0.0.tgz", - "integrity": "sha512-opNgmlu83ZCF792U281Ry7tak9IbVC+AKnXGovcQ8LG8wFaJv6cLnRlc6DIHlmNxWEexB5bZxi9SZ9JyUuOYjw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-6.0.1.tgz", + "integrity": "sha512-f+Rbqt92Ful9gX0cGtdYwjTrWAaGURgaK5rZCWOgCNyGWusFYHhbqCCBoFBeat+HKETOU02AyTxNhJV0YZf2jQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -13235,8 +13224,7 @@ "get-stdin": "^4.0.1", "glob": "^7.0.3", "lodash": "^4.17.15", - "meow": "^3.7.0", - "mkdirp": "^0.5.1", + "meow": "^9.0.0", "nan": "^2.13.2", "node-gyp": "^7.1.0", "npmlog": "^4.0.0", @@ -13249,7 +13237,7 @@ "node-sass": "bin/node-sass" }, "engines": { - "node": ">=10" + "node": ">=12" } }, "node_modules/node-sass/node_modules/ansi-regex": { @@ -13270,28 +13258,6 @@ "node": ">=0.10.0" } }, - "node_modules/node-sass/node_modules/camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "dependencies": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-sass/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -13322,19 +13288,6 @@ "node": ">= 8" } }, - "node_modules/node-sass/node_modules/find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "dependencies": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-sass/node_modules/get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", @@ -13344,104 +13297,30 @@ "node": ">=0.10.0" } }, - "node_modules/node-sass/node_modules/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 - }, - "node_modules/node-sass/node_modules/indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "dependencies": { - "repeating": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-sass/node_modules/meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "dependencies": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "trim-newlines": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/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, - "dependencies": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, - "node_modules/node-sass/node_modules/parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-9.0.0.tgz", + "integrity": "sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==", "dev": true, "dependencies": { - "error-ex": "^1.2.0" + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize": "^1.2.0", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.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.18.0", + "yargs-parser": "^20.2.3" }, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "dependencies": { - "pinkie-promise": "^2.0.0" + "node": ">=10" }, - "engines": { - "node": ">=0.10.0" + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/node-sass/node_modules/path-key": { @@ -13453,78 +13332,6 @@ "node": ">=8" } }, - "node_modules/node-sass/node_modules/path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "dependencies": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "dependencies": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, - "dependencies": { - "indent-string": "^2.1.0", - "strip-indent": "^1.0.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/node-sass/node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -13558,33 +13365,6 @@ "node": ">=0.10.0" } }, - "node_modules/node-sass/node_modules/strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "dependencies": { - "is-utf8": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/node-sass/node_modules/strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "dependencies": { - "get-stdin": "^4.0.1" - }, - "bin": { - "strip-indent": "cli.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-sass/node_modules/supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", @@ -13594,15 +13374,6 @@ "node": ">=0.8.0" } }, - "node_modules/node-sass/node_modules/trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/node-sass/node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -28099,15 +27870,6 @@ } } }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, "modify-values": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.1.tgz", @@ -28337,9 +28099,9 @@ "dev": true }, "node-sass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-5.0.0.tgz", - "integrity": "sha512-opNgmlu83ZCF792U281Ry7tak9IbVC+AKnXGovcQ8LG8wFaJv6cLnRlc6DIHlmNxWEexB5bZxi9SZ9JyUuOYjw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-6.0.1.tgz", + "integrity": "sha512-f+Rbqt92Ful9gX0cGtdYwjTrWAaGURgaK5rZCWOgCNyGWusFYHhbqCCBoFBeat+HKETOU02AyTxNhJV0YZf2jQ==", "dev": true, "requires": { "async-foreach": "^0.1.3", @@ -28349,8 +28111,7 @@ "get-stdin": "^4.0.1", "glob": "^7.0.3", "lodash": "^4.17.15", - "meow": "^3.7.0", - "mkdirp": "^0.5.1", + "meow": "^9.0.0", "nan": "^2.13.2", "node-gyp": "^7.1.0", "npmlog": "^4.0.0", @@ -28372,22 +28133,6 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true - }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "requires": { - "camelcase": "^2.0.0", - "map-obj": "^1.0.0" - } - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -28412,102 +28157,30 @@ "which": "^2.0.1" } }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, "get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "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", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - }, "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "requires": { - "camelcase-keys": "^2.0.0", - "decamelize": "^1.1.2", - "loud-rejection": "^1.0.0", - "map-obj": "^1.0.1", - "minimist": "^1.1.3", - "normalize-package-data": "^2.3.4", - "object-assign": "^4.0.1", - "read-pkg-up": "^1.0.1", - "redent": "^1.0.0", - "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", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-9.0.0.tgz", + "integrity": "sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==", "dev": true, "requires": { - "error-ex": "^1.2.0" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "^2.0.0" + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize": "^1.2.0", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.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.18.0", + "yargs-parser": "^20.2.3" } }, "path-key": { @@ -28516,60 +28189,6 @@ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "^1.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^1.0.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "^1.0.0", - "read-pkg": "^1.0.0" - } - }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, - "requires": { - "indent-string": "^2.1.0", - "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 - }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -28594,36 +28213,12 @@ "ansi-regex": "^2.0.0" } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "requires": { - "get-stdin": "^4.0.1" - } - }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true - }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 2bf95ea5..110a1ac6 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "lint-staged": "^10.5.1", "material-components-web": "^8.0.0", "memfs": "^3.2.0", - "node-sass": "^5.0.0", + "node-sass": "^6.0.1", "npm-run-all": "^4.1.5", "prettier": "^2.1.2", "sass": "^1.29.0", diff --git a/src/utils.js b/src/utils.js index 144a8327..8f231ecc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -89,6 +89,12 @@ function getSassImplementation(loaderContext, implementation) { ); } +function isSupportedFibers() { + const [nodeVersion] = process.versions.node.split("."); + + return Number(nodeVersion) < 16; +} + function isProductionLikeMode(loaderContext) { return loaderContext.mode === "production" || !loaderContext.mode; } @@ -131,7 +137,7 @@ async function getSassOptions( const isDartSass = implementation.info.includes("dart-sass"); - if (isDartSass) { + if (isDartSass && isSupportedFibers()) { const shouldTryToResolveFibers = !options.fiber && options.fiber !== false; if (shouldTryToResolveFibers) { @@ -575,4 +581,5 @@ export { getWebpackImporter, getRenderFunctionFromSassImplementation, normalizeSourceMap, + isSupportedFibers, }; diff --git a/test/additionalData-option.test.js b/test/additionalData-option.test.js index 77b1b003..de712322 100644 --- a/test/additionalData-option.test.js +++ b/test/additionalData-option.test.js @@ -1,6 +1,7 @@ import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; + +import { isSupportedFibers } from "../src/utils"; import { compile, @@ -13,13 +14,23 @@ import { getWarnings, } from "./helpers"; +let Fiber; const implementations = [nodeSass, dartSass]; const syntaxStyles = ["scss", "sass"]; describe("additionalData option", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => { diff --git a/test/implementation-option.test.js b/test/implementation-option.test.js index 16e783fd..e37fd605 100644 --- a/test/implementation-option.test.js +++ b/test/implementation-option.test.js @@ -1,6 +1,7 @@ import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; + +import { isSupportedFibers } from "../src/utils"; import { compile, @@ -12,15 +13,24 @@ import { getWarnings, } from "./helpers"; -const implementations = [nodeSass, dartSass]; - jest.setTimeout(30000); +let Fiber; +const implementations = [nodeSass, dartSass]; + describe("implementation option", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); - jest.clearAllMocks(); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => { @@ -51,6 +61,9 @@ describe("implementation option", () => { expect(nodeSassSpy).toHaveBeenCalledTimes(0); expect(dartSassSpy).toHaveBeenCalledTimes(1); } + + nodeSassSpy.mockRestore(); + dartSassSpy.mockRestore(); }); }); @@ -72,6 +85,9 @@ describe("implementation option", () => { expect(nodeSassSpy).toHaveBeenCalledTimes(0); expect(dartSassSpy).toHaveBeenCalledTimes(1); + + nodeSassSpy.mockRestore(); + dartSassSpy.mockRestore(); }); it('should throw an error when the "node-sass" package is an incompatible version', async () => { diff --git a/test/loader.test.js b/test/loader.test.js index 1fdda94b..81d9adb9 100644 --- a/test/loader.test.js +++ b/test/loader.test.js @@ -2,9 +2,10 @@ import path from "path"; import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; import del from "del"; +import { isSupportedFibers } from "../src/utils"; + import { compile, getCodeFromBundle, @@ -16,15 +17,25 @@ import { getWarnings, } from "./helpers"; +jest.setTimeout(60000); + +let Fiber; const implementations = [nodeSass, dartSass]; const syntaxStyles = ["scss", "sass"]; -jest.setTimeout(60000); - describe("loader", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => { @@ -420,7 +431,10 @@ describe("loader", () => { implementation: getImplementationByName(implementationName), }; const compiler = getCompiler(testId, { - loader: { options, resolve: { mainFields: ["custom-sass", "..."] } }, + loader: { + options, + resolve: { mainFields: ["custom-sass", "..."] }, + }, }); const stats = await compile(compiler); const codeFromBundle = getCodeFromBundle(stats, compiler); diff --git a/test/sassOptions-option.test.js b/test/sassOptions-option.test.js index f9ecac6f..18c13562 100644 --- a/test/sassOptions-option.test.js +++ b/test/sassOptions-option.test.js @@ -3,7 +3,8 @@ import path from "path"; import semver from "semver"; import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; + +import { isSupportedFibers } from "../src/utils"; import { compile, @@ -18,15 +19,25 @@ import { getCompiler, } from "./helpers"; +jest.setTimeout(30000); + +let Fiber; const implementations = [nodeSass, dartSass]; const syntaxStyles = ["scss", "sass"]; -jest.setTimeout(30000); - describe("sassOptions option", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => { @@ -351,7 +362,8 @@ describe("sassOptions option", () => { if ( implementationName === "dart-sass" && - semver.satisfies(process.version, ">= 10") + semver.satisfies(process.version, ">= 10") && + isSupportedFibers() ) { expect(dartSassSpy.mock.calls[0][0]).toHaveProperty("fiber"); } @@ -378,7 +390,8 @@ describe("sassOptions option", () => { if ( implementationName === "dart-sass" && - semver.satisfies(process.version, ">= 10") + semver.satisfies(process.version, ">= 10") && + isSupportedFibers() ) { expect(dartSassSpy.mock.calls[0][0]).toHaveProperty("fiber"); } diff --git a/test/sourceMap-options.test.js b/test/sourceMap-options.test.js index 435cf189..e89920fc 100644 --- a/test/sourceMap-options.test.js +++ b/test/sourceMap-options.test.js @@ -3,7 +3,8 @@ import path from "path"; import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; + +import { isSupportedFibers } from "../src/utils"; import { compile, @@ -15,13 +16,23 @@ import { getWarnings, } from "./helpers"; +let Fiber; const implementations = [nodeSass, dartSass]; const syntaxStyles = ["scss", "sass"]; describe("sourceMap option", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => { diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 5a4bba47..5e542d0b 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -1,4 +1,4 @@ -import Fiber from "fibers"; +import { isSupportedFibers } from "../src/utils"; import { getCompiler, @@ -7,10 +7,21 @@ import { getImplementationByName, } from "./helpers/index"; +let Fiber; + describe("validate options", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); const tests = { diff --git a/test/webpackImporter-options.test.js b/test/webpackImporter-options.test.js index fda65ff1..7d783593 100644 --- a/test/webpackImporter-options.test.js +++ b/test/webpackImporter-options.test.js @@ -1,6 +1,7 @@ import nodeSass from "node-sass"; import dartSass from "sass"; -import Fiber from "fibers"; + +import { isSupportedFibers } from "../src/utils"; import { compile, @@ -13,13 +14,23 @@ import { getWarnings, } from "./helpers"; +let Fiber; const implementations = [nodeSass, dartSass]; const syntaxStyles = ["scss", "sass"]; describe("webpackImporter option", () => { + beforeAll(async () => { + if (isSupportedFibers()) { + const { default: fibers } = await import("fibers"); + Fiber = fibers; + } + }); + beforeEach(() => { - // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype - Object.setPrototypeOf(Fiber, Function.prototype); + if (isSupportedFibers()) { + // The `sass` (`Dart Sass`) package modify the `Function` prototype, but the `jest` lose a prototype + Object.setPrototypeOf(Fiber, Function.prototype); + } }); implementations.forEach((implementation) => {