-
-
Notifications
You must be signed in to change notification settings - Fork 427
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
Dart Sass without fibers should use renderSync instead of render #701
Comments
Thanks for issue, i will investigate this for next major release, i think i will start work on next release at this week, a lot of other issues |
SGTM, thanks for looking at it! |
We could make it configurable via loader options. This pushes the responsibility/complexity back to the user. The problem is that the sass-loader has no clue if your project uses any custom importer where the async API is necessary. I should also mention that compiling something synchronously is one of the worst things you can do in a webpack build. In a regular webpack build there are hundreds of async module builds simultaneously. If you do something synchronously, it will pause all other module builds. I'm pretty sure that most people will get worse performance results if they do something synchronously 😁 |
I think configurable makes sense if the plugin cannot determine it. I can compare performance numbers if you guide me a little bit on how I can change it in my node modules. I tried to change it myself in sass/dart-sass#744 (comment) but it looks like I was missing something. |
This would make sense, but the default should still probably be running synchronously (which means WebPack's custom importer should be synchronous as well).
The logic of compiling Sass—which is by far the bottleneck of Sass compilation—is inherently synchronous. There's nothing about parsing strings or manipulating ASTs that can be done out-of-process, so making it asynchronous doesn't buy you anything in terms of speed (and in fact makes it much slower because it has to bounce back to the event loop all the time). The only reason it has an asynchronous mode at all is to support asynchronous plugins. |
In theory it is possible https://github.com/webpack/enhanced-resolve#resolve (we need use |
The overhead of running Sass asynchronously tends to range between 2x and 3x the total synchronous compilation time for large projects, not to mention the memory overhead that @filipesilva is running into. This dwarfs file IO time, which means it's also likely to dwarf the benefits you'd get from increased parallelism while waiting on file IO. |
Filesystem operations aren't the bottleneck here. The issue, as I explained above, is the overhead of going back to the event loop for every method call in asynchronous mode.
Yes, |
@nex3 Can I set your avatar in my plugin? |
I'd prefer it if you didn't. |
@nex3 Ok. I will not add a photo of your avatar. It was just needed for the quote you made. Then I'll just add your nickname. Here are these quotes
|
What’s the status of this issue? I thinks what @jhnns proposed—pushing the responsibility/complexity back to the user—is the best way forward. Make sass-loader async by default, but strongly recommend (in documentation) switching to sync API when using Dart Sass. |
We can't use sync api because we need resolve your |
This is still developer/user issue and it’s something that could be mentioned in documentation. Currently there really isn’t any good way forward other than opt-in to sync API and deal with consequences. As for resolving module at-rules, that’s included inside |
We can't enable sync api, resolver are always async |
Do you mean Webpack resolver or Sass resolver? Because Webpack enhanced resolve has sync option IIRC. |
Are we not caching the results? |
I want to close this issue, because we can't use Anyway feel free to feedback |
Expected Behavior
When using Dart Sass and not using
fibers
, therenderSync
method should always be used instead of therender
method (see https://github.com/sass/dart-sass#javascript-api, #435 (comment) and sass/dart-sass#744 (comment) for details). Always usingrender
has severe performance implications.Actual Behavior
The
render
method is always used with Dart sass.Code
sass-loader/lib/loader.js
Lines 137 to 144 in e279f2a
How Do We Reproduce?
No external reproduction needed. It's in the source code for this package.
The text was updated successfully, but these errors were encountered: