sass-loader
Advanced tools
Comparing version 13.3.3 to 14.0.0
@@ -77,3 +77,3 @@ "use strict"; | ||
if (typeof result.loadedUrls !== "undefined") { | ||
result.loadedUrls.filter(url => url.protocol === "file:").forEach(includedFile => { | ||
result.loadedUrls.filter(loadedUrl => loadedUrl.protocol === "file:").forEach(includedFile => { | ||
const normalizedIncludedFile = _url.default.fileURLToPath(includedFile); | ||
@@ -80,0 +80,0 @@ |
@@ -13,3 +13,2 @@ "use strict"; | ||
exports.getWebpackResolver = getWebpackResolver; | ||
exports.isSupportedFibers = isSupportedFibers; | ||
exports.normalizeSourceMap = normalizeSourceMap; | ||
@@ -93,6 +92,2 @@ var _url = _interopRequireDefault(require("url")); | ||
} | ||
function isSupportedFibers() { | ||
const [nodeVersion] = process.versions.node.split("."); | ||
return Number(nodeVersion) < 16; | ||
} | ||
@@ -184,24 +179,2 @@ /** | ||
sassOptions.file = resourcePath; | ||
const isDartSass = implementation.info.includes("dart-sass"); | ||
if (isDartSass && isSupportedFibers()) { | ||
const shouldTryToResolveFibers = !sassOptions.fiber && sassOptions.fiber !== false; | ||
if (shouldTryToResolveFibers) { | ||
let fibers; | ||
try { | ||
fibers = require.resolve("fibers"); | ||
} catch (_error) { | ||
// Nothing | ||
} | ||
if (fibers) { | ||
// eslint-disable-next-line global-require, import/no-dynamic-require | ||
sassOptions.fiber = require(fibers); | ||
} | ||
} else if (sassOptions.fiber === false) { | ||
// Don't pass the `fiber` option for `sass` (`Dart Sass`) | ||
delete sassOptions.fiber; | ||
} | ||
} else { | ||
// Don't pass the `fiber` option for `node-sass` | ||
delete sassOptions.fiber; | ||
} | ||
@@ -239,2 +212,3 @@ // opt.outputStyle | ||
if (loaderOptions.webpackImporter === false && sassOptions.importer.length === 0) { | ||
// eslint-disable-next-line no-undefined | ||
sassOptions.importer = undefined; | ||
@@ -241,0 +215,0 @@ } |
{ | ||
"name": "sass-loader", | ||
"version": "13.3.3", | ||
"version": "14.0.0", | ||
"description": "Sass loader for webpack", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 14.15.0" | ||
"node": ">= 18.12.0" | ||
}, | ||
@@ -46,3 +46,2 @@ "scripts": { | ||
"peerDependencies": { | ||
"fibers": ">= 3.1.0", | ||
"node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", | ||
@@ -62,5 +61,2 @@ "sass": "^1.3.0", | ||
"optional": true | ||
}, | ||
"fibers": { | ||
"optional": true | ||
} | ||
@@ -72,7 +68,7 @@ }, | ||
"devDependencies": { | ||
"@babel/cli": "^7.22.9", | ||
"@babel/core": "^7.22.9", | ||
"@babel/preset-env": "^7.22.9", | ||
"@commitlint/cli": "^17.6.7", | ||
"@commitlint/config-conventional": "^17.6.7", | ||
"@babel/cli": "^7.23.4", | ||
"@babel/core": "^7.23.7", | ||
"@babel/preset-env": "^7.23.8", | ||
"@commitlint/cli": "^18.4.4", | ||
"@commitlint/config-conventional": "^18.4.4", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
@@ -84,9 +80,9 @@ "babel-jest": "^29.6.2", | ||
"cross-env": "^7.0.3", | ||
"cspell": "^6.31.2", | ||
"css-loader": "^6.8.1", | ||
"cspell": "^8.3.2", | ||
"css-loader": "^6.9.0", | ||
"del": "^6.1.1", | ||
"del-cli": "^4.0.1", | ||
"del-cli": "^5.1.0", | ||
"enhanced-resolve": "^5.15.0", | ||
"eslint": "^8.46.0", | ||
"eslint-config-prettier": "^8.9.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-import": "^2.28.0", | ||
@@ -98,14 +94,14 @@ "file-loader": "^6.2.0", | ||
"jest-environment-node-single-context": "^29.1.0", | ||
"lint-staged": "^13.2.3", | ||
"lint-staged": "^15.2.0", | ||
"material-components-web": "^9.0.0", | ||
"memfs": "^3.5.1", | ||
"node-sass": "^8.0.0", | ||
"memfs": "^4.6.0", | ||
"node-sass": "^9.0.0", | ||
"node-sass-glob-importer": "^5.3.2", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.8.8", | ||
"sass": "^1.64.2", | ||
"sass-embedded": "^1.64.2", | ||
"prettier": "^3.2.2", | ||
"sass": "^1.69.7", | ||
"sass-embedded": "^1.69.7", | ||
"semver": "^7.5.4", | ||
"standard-version": "^9.3.1", | ||
"style-loader": "^3.3.3", | ||
"style-loader": "^3.3.4", | ||
"webpack": "^5.88.2" | ||
@@ -112,0 +108,0 @@ }, |
@@ -252,81 +252,2 @@ <div align="center"> | ||
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`) for `Node.js` less v16.0.0 if is possible (i.e. you need install the [`fibers`](https://github.com/laverdet/node-fibers) package). | ||
> **Warning** | ||
> | ||
> Fibers is not compatible with `Node.js` v16.0.0 or later. Unfortunately, v8 commit [dacc2fee0f](https://github.com/v8/v8/commit/dacc2fee0f815823782a7e432c79c2a7767a4765) is a breaking change and workarounds are non-trivial. ([see introduction to readme](https://github.com/laverdet/node-fibers)). | ||
**package.json** | ||
```json | ||
{ | ||
"devDependencies": { | ||
"sass-loader": "^7.2.0", | ||
"sass": "^1.22.10", | ||
"fibers": "^4.0.1" | ||
} | ||
} | ||
``` | ||
You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers) package by passing a `false` value for the `sassOptions.fiber` option. | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.s[ac]ss$/i, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
{ | ||
loader: "sass-loader", | ||
options: { | ||
implementation: require("sass"), | ||
sassOptions: { | ||
fiber: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
You can also pass the `fiber` value using this code: | ||
**webpack.config.js** | ||
```js | ||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.s[ac]ss$/i, | ||
use: [ | ||
"style-loader", | ||
"css-loader", | ||
{ | ||
loader: "sass-loader", | ||
options: { | ||
implementation: require("sass"), | ||
sassOptions: { | ||
fiber: require("fibers"), | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
### `sassOptions` | ||
@@ -342,3 +263,3 @@ | ||
loaderContext: LoaderContext, | ||
meta: any | ||
meta: any, | ||
) => import("sass").LegacyOptions<"async">); | ||
@@ -345,0 +266,0 @@ ``` |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5
5
55920
750
880