Skip to content

Commit

Permalink
fix(sass!): remove fibers support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anidetrix committed Jan 14, 2022
1 parent 5d6ccc1 commit 8992356
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 37 deletions.
24 changes: 1 addition & 23 deletions README.md
Expand Up @@ -32,7 +32,6 @@
- [Emitting processed CSS](#emitting-processed-css)
- [CSS Modules](#css-modules)
- [With Sass/Less/Stylus](#with-sasslessstylus)
- [Sass and `fibers`](#sass-and-fibers)
- [Configuration](#configuration)
- [Why](#why)
- [License](#license)
Expand Down Expand Up @@ -230,27 +229,6 @@ Install corresponding dependency:

That's it, now you can import `.scss` `.sass` `.less` `.styl` `.stylus` files in your code.

### Sass and `fibers`

By default, when using `Dart Sass` implementation, `fibers` package will be loaded automatically if available, otherwise sync mode will be used for better performance.

> When installed via npm, `Dart Sass` supports a JavaScript API that's fully compatible with `Node Sass` <...>, with support for both the render() and renderSync() functions. <...>
>
> Note however that by default, **renderSync() is more than twice as fast as render()** due to the overhead of asynchronous callbacks. To avoid this performance hit, render() can use the `fibers` package to call asynchronous importers from the synchronous code path.
>
> [Source](https://github.com/sass/dart-sass/blob/master/README.md#javascript-api)
To install `fibers`:

```bash
# npm
npm install -D fibers
# pnpm
pnpm add -D fibers
# yarn
yarn add fibers --dev
```

## Configuration

See [API Reference for `Options`](https://anidetrix.github.io/rollup-plugin-styles/interfaces/types.options.html) for full list of available options.
Expand All @@ -273,7 +251,7 @@ With that said, here is the basic list of things which differentiate this plugin
- Proper sourcemaps, with included sources content by default
- Respects `assetFileNames` for CSS file names
- Respects sourcemaps from loaded files
- Support for implementation and `fibers` forcing for Sass
- Support for implementation for Sass
- Support for partials and `~` in Less import statements
- More smaller things that I forgot

Expand Down
9 changes: 1 addition & 8 deletions src/loaders/sass/index.ts
@@ -1,4 +1,3 @@
import loadModule from "../../utils/load-module";
import { normalizePath } from "../../utils/path";
import { Loader } from "../types";
import loadSass from "./load";
Expand All @@ -8,8 +7,6 @@ import { importer, importerSync } from "./importer";
export interface SASSLoaderOptions extends Record<string, unknown>, sass.PublicOptions {
/** Force Sass implementation */
impl?: string;
/** Forcefully enable/disable `fibers` */
fibers?: boolean;
/** Forcefully enable/disable sync mode */
sync?: boolean;
}
Expand All @@ -20,9 +17,7 @@ const loader: Loader<SASSLoaderOptions> = {
async process({ code, map }) {
const options = { ...this.options };
const [sass, type] = loadSass(options.impl);
const useFibers = options.fibers ?? type === "sass";
const fiber = useFibers ? (loadModule("fibers") as fibers.Fiber) : undefined;
const sync = options.sync ?? (type !== "node-sass" && !fiber);
const sync = options.sync ?? type !== "node-sass";
const importers = [sync ? importerSync : importer];

if (options.data) code = options.data + code;
Expand All @@ -40,7 +35,6 @@ const loader: Loader<SASSLoaderOptions> = {

// Remove non-Sass options
delete options.impl;
delete options.fibers;
delete options.sync;

// node-sass won't produce sourcemaps if the `data`
Expand All @@ -61,7 +55,6 @@ const loader: Loader<SASSLoaderOptions> = {
omitSourceMapUrl: true,
sourceMapContents: true,
importer: importers,
fiber,
});

const deps = res.stats.includedFiles;
Expand Down
3 changes: 0 additions & 3 deletions src/shims/fibers.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/shims/sass.d.ts
@@ -1,5 +1,3 @@
/// <reference types="./fibers" />

declare namespace sass {
type Data = { file: string } | { contents: string } | Error | null;

Expand All @@ -16,7 +14,6 @@ declare namespace sass {
}

interface Options extends PublicOptions {
fiber?: fibers.Fiber;
file?: string;
indentedSyntax?: boolean;
omitSourceMapUrl?: boolean;
Expand Down

0 comments on commit 8992356

Please sign in to comment.