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

add an option to render scss synchronously via renderSync #123

Merged
merged 2 commits into from
Mar 26, 2020
Merged

add an option to render scss synchronously via renderSync #123

merged 2 commits into from
Mar 26, 2020

Conversation

Leonidaz
Copy link
Contributor

@Leonidaz Leonidaz commented Mar 20, 2020

Synchronous SCSS Compiling

  • This adds a way to synchronously compile SCSS via sass or node-sass. According to sass:

When using Dart Sass, renderSync() is almost twice as fast as render() by default, due to the overhead of making the entire evaluation process asynchronous.
Just need to pass renderSync as true with scss options:

	scss: {
		includePaths: ['theme', 'src/styles'],
		renderSync: true,
	}
  • Allows a developer to choose whether to use the async render method, which is the default, or the synchronous and potentially faster renderSync method. Both sass and node-sass support renderSync
  • All of the current and new tests should pass, the output from the scss transformer remains the same utilizing the same async method with resolve and reject on error. (the actual call though is synchronous with a try/catch block)

Tests

  • Added a couple of tests of the new option and they pass

@kaisermann
Copy link
Member

kaisermann commented Mar 20, 2020

Hey @Leonidaz 👋 First of all, thanks for your contribution!

If both node-sass and dart-sass support renderSync and it's faster in at least one of them, would it make sense to make the default behaviour synchronous? I think exposing a renderSync: boolean is kind of exaggerated, people shouldn't need to mess with this kind of settings; the library should be automatically doing what's best for them.

@kaisermann kaisermann self-assigned this Mar 20, 2020
@kaisermann kaisermann added the enhancement New feature or request label Mar 20, 2020
@Leonidaz
Copy link
Contributor Author

Leonidaz commented Mar 20, 2020

Hey @kaisermann, awesome work on this library!

I thought that it's good to give people a choice. There are many variations with OS
s, docker, node versions - so sometimes it may be that one method is faster than the other or one library is faster than the other.

After all we're all developers and should be able to figure out what's best for us.

If we want to make the decisions for the developer, we may as well consider just keeping sass and not even support node-sass since sass supports the full and latest features of scss language (e.g. "@use"), it's pure JS with no C++ bindings - less issues installing and using across various platforms, and the renderSync seems faster.

I personally would say that in this case having this kind of choice is ok. We can monitor the situation and maybe if a clear winner emerges and at that point it wouldn't make sense to support 2 options.

@Leonidaz
Copy link
Contributor Author

Hey @kaisermann, wanted to follow up on this pr. Thanks!

@kaisermann kaisermann merged commit 1c9285d into sveltejs:master Mar 26, 2020
@kaisermann
Copy link
Member

Released in v3.6.0 😀 And again, thanks for your thoughtful contribution 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants