Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove fibers package #1059

Merged
merged 5 commits into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -59,7 +59,7 @@ All notable changes to this project will be documented in this file. See [standa

* allow `String` value for the `implementation` option ([382a3ca](https://github.com/webpack-contrib/sass-loader/commit/382a3ca7ca8b7041712de30ce5ad8e6532944c1b))

## [12.0.0](https://github.com/webpack-contrib/sass-loader/compare/v11.1.1...v12.0.0) (2021-06-01)
## [12.0.0](https://github.com/webpack-contrib/sa automatically use thess-loader/compare/v11.1.1...v12.0.0) (2021-06-01)
amareshsm marked this conversation as resolved.
Show resolved Hide resolved


### ⚠ BREAKING CHANGES
Expand Down
77 changes: 0 additions & 77 deletions README.md
Expand Up @@ -239,83 +239,6 @@ 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`) 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**

```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`

Type:
Expand Down
45 changes: 0 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions package.json
Expand Up @@ -38,7 +38,6 @@
"dist"
],
"peerDependencies": {
"fibers": ">= 3.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove it from here, we still need to continue support (otherwise it will be breaking change), just improve readme about deprection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. I will update readme and revert other changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Pls let me know any changes required

"node-sass": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
"sass": "^1.3.0",
"sass-embedded": "*",
Expand All @@ -53,9 +52,6 @@
},
"sass-embedded": {
"optional": true
},
"fibers": {
"optional": true
}
},
"dependencies": {
Expand All @@ -81,7 +77,6 @@
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"fibers": "^5.0.1",
"file-loader": "^6.2.0",
"foundation-sites": "^6.6.3",
"husky": "^8.0.1",
Expand Down
34 changes: 0 additions & 34 deletions src/utils.js
Expand Up @@ -112,12 +112,6 @@ function proxyCustomImporters(importers, loaderContext) {
);
}

function isSupportedFibers() {
const [nodeVersion] = process.versions.node.split(".");

return Number(nodeVersion) < 16;
}

/**
* Derives the sass options from the loader context and normalizes its values with sane defaults.
*
Expand All @@ -143,7 +137,6 @@ async function getSassOptions(
: {}
);

const isDartSass = implementation.info.includes("dart-sass");
const isModernAPI = loaderOptions.api === "modern";

options.data = loaderOptions.additionalData
Expand Down Expand Up @@ -233,32 +226,6 @@ async function getSassOptions(
} else {
options.file = resourcePath;

if (isDartSass && isSupportedFibers()) {
const shouldTryToResolveFibers =
!options.fiber && options.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
options.fiber = require(fibers);
}
} else if (options.fiber === false) {
// Don't pass the `fiber` option for `sass` (`Dart Sass`)
delete options.fiber;
}
} else {
// Don't pass the `fiber` option for `node-sass`
delete options.fiber;
}

// opt.outputStyle
if (!options.outputStyle && isProductionLikeMode(loaderContext)) {
options.outputStyle = "compressed";
Expand Down Expand Up @@ -808,5 +775,4 @@ export {
getWebpackImporter,
getCompileFn,
normalizeSourceMap,
isSupportedFibers,
};