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

Make this package implementation-agnostic #694

Merged
merged 4 commits into from
Oct 16, 2018
Merged

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented May 24, 2018

Rather than always loading Node Sass, this now requires users to pass
in either Dart Sass or Node Sass to the require() call.

Closes #672

Rather than always loading Node Sass, this now requires users to pass
in either Dart Sass or Node Sass to the require() call.

Closes dlmanning#672
@nex3 nex3 mentioned this pull request May 24, 2018
@nex3
Copy link
Contributor Author

nex3 commented May 24, 2018

The linter wants me to add a trailing comma to my argument list, but it doesn't look like that works on Node 6.x. What should I do?

@nex3
Copy link
Contributor Author

nex3 commented Jun 4, 2018

@dlmanning Ping!

@nex3
Copy link
Contributor Author

nex3 commented Jun 13, 2018

@xzyfer As we discussed offline, I updated this to continue loading Node Sass by default, but to document support for Dart Sass and encourage users to explicitly choose their implementation. Please take a look.

This documents the option to use Dart Sass, and encourages users to
explicitly choose their implementation, but it doesn't change the
existing behavior.
@MichaelFBA
Copy link

Any chance we can get this merged? :)

@devversion
Copy link

Normally I'm not a fan of commenting in order to notify the project leads, but there hasn't been really much activity here. Please can someone have a look and give an update.

Copy link

@nschonni nschonni left a comment

Choose a reason for hiding this comment

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

Nothing blocking, just some feedback

README.md Outdated
@@ -26,6 +26,8 @@ Something like this will compile your Sass files:
var gulp = require('gulp');
var sass = require('gulp-sass');

sass.compiler = require(node-sass');

Choose a reason for hiding this comment

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

If node-sass is the default, this doesn't seem needed

@@ -13,7 +13,7 @@ Only [Active LTS and Current releases][1] are supported.
# Install

```
npm install gulp-sass --save-dev
npm install node-sass gulp-sass --save-dev

Choose a reason for hiding this comment

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

If it is still the included default this doesn't need to change


Note that when using 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. To enable this, pass the `Fiber` class to the `fiber` option:

```javascript

Choose a reason for hiding this comment

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

Maybe mention the npm install dart-sass here?

@@ -56,9 +60,36 @@ gulp.task('sass:watch', function () {
});
```

You can choose whether to use [Dart Sass][] or [Node Sass][] by setting the `sass.compiler` property. Node Sass will be used by default, but it's strongly recommended that you set it explicitly for forwards-compatibility in case the default ever changes.

Choose a reason for hiding this comment

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

The explicit compiler would be a breaking change and probably dealt with then instead of recommending it now. I'm just thinking if the future change happens it might be through a different method and this locks in the API when it's not needed yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One way or another, there needs to be a way of overriding the compiler. That's the whole point of this change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically overriding the compiler is already possible. Who knows what folks are doing with it. I'm OK with this because now we're at least documenting it as part of the API so we're committed to version correctly if we change.

## Options

Pass in options just like you would for [`node-sass`](https://github.com/sass/node-sass#options); they will be passed along just as if you were using `node-sass`. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
Pass in options just like you would for [Node Sass](https://github.com/sass/node-sass#options); they will be passed along just as if you were using Node Sass. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.

Choose a reason for hiding this comment

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

Should some validation around the file option be added, or is the dart-sass error user friendly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing about this behavior is changing. I just slightly reformatted the paragraph to refer to Node Sass more consistently.

@nschonni
Copy link

PS: I'm good if the future version tries to load sass first, and falls back to node-sass if the require fails (or add a flag to force node-sass). I'm thinking about the current changes through a "convention over configuration" lens.

Copy link
Contributor Author

@nex3 nex3 left a comment

Choose a reason for hiding this comment

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

My goal is to have the README encourage users to explicitly select the version of Sass they're using, so that in the future if the default changes or if an explicit decision is required--which is the way most plugins seem to be going--as many users' configurations as possible are already in a state that explicitly declares the Sass implementation they're using.

@@ -56,9 +60,36 @@ gulp.task('sass:watch', function () {
});
```

You can choose whether to use [Dart Sass][] or [Node Sass][] by setting the `sass.compiler` property. Node Sass will be used by default, but it's strongly recommended that you set it explicitly for forwards-compatibility in case the default ever 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.

One way or another, there needs to be a way of overriding the compiler. That's the whole point of this change.

## Options

Pass in options just like you would for [`node-sass`](https://github.com/sass/node-sass#options); they will be passed along just as if you were using `node-sass`. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
Pass in options just like you would for [Node Sass](https://github.com/sass/node-sass#options); they will be passed along just as if you were using Node Sass. Except for the `data` option which is used by gulp-sass internally. Using the `file` option is also unsupported and results in undefined behaviour that may change without notice.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing about this behavior is changing. I just slightly reformatted the paragraph to refer to Node Sass more consistently.

@nex3
Copy link
Contributor Author

nex3 commented Oct 3, 2018

Ping!

@xzyfer
Copy link
Collaborator

xzyfer commented Oct 16, 2018

Sorry for the delay. I took a break from GitHub.

@xzyfer xzyfer merged commit 98254d2 into dlmanning:master Oct 16, 2018
@xzyfer
Copy link
Collaborator

xzyfer commented Oct 16, 2018

Released as v4.0.2

@brookback
Copy link

Thanks for this!

But, would it not make sense to completely remove the dependency of node-sass, in order to avoid having binary dependencies? And to state in the README (as it is now) that people have to do

npm install --save gulp-sass node-sass

to get started?

@tinyfly
Copy link

tinyfly commented Jan 31, 2019

But, would it not make sense to completely remove the dependency of node-sass

I would like this tremendously. I'm sure there are reasons for this but one of the big advantages for using dart-sass is not having to build node-sass and the complications that can come from that. As it is I'm still having to build node sass on install event if I choose not to use it.

@xzyfer
Copy link
Collaborator

xzyfer commented Jan 31, 2019

You're welcome to fork this project or use gulp-dart-sass, but there are no plans change node-sass as the default.

xzyfer added a commit that referenced this pull request Jun 25, 2021
* Update node-sass to 6.0.0

Also moves node-sass to devDependencies and peerDependencies. This helps prevent dupes and conflicts in packages using gulp-sass

* Make mocha test compatible with gulp@4

* Update package version, engines

* Remove node-sass as peer dependency

* Replace through2 with transfob

* Uninstall through2

* Throw error if compiler not set

* Fix casing of Sass

Co-authored-by: Michael Mifsud <xzyfer@gmail.com>

* Use function arg to set compiler, use transfob package

* Update test to new API signature

* Update package versions

* Fix eslint errors

* Incorporate previously proposed documentation changes

Copied from #694

* Update document outline, apply copyedits

* Copyedit: overall clarifications

* Call out migration guide, update badges

* Document Gulp 4 usage

* smol clarification

* Copyedit some headings

* Yet Another Copyedit™

* Update README.md

Co-authored-by: Michael Mifsud <xzyfer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants