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

Use the Sass Compiler API #1163

Closed
nex3 opened this issue Oct 18, 2023 · 4 comments · Fixed by #1195
Closed

Use the Sass Compiler API #1163

nex3 opened this issue Oct 18, 2023 · 4 comments · Fixed by #1195

Comments

@nex3
Copy link
Contributor

nex3 commented Oct 18, 2023

Modification Proposal

We (the Sass team) have just released a proposal for a Compiler API in Sass that shares resources between different compilations (see also sass/sass#3296). This is particularly useful when using the sass-embedded package, which runs a very fast subprocess to compile Sass: within the lifetime of a single Compiler, the subprocess will remain open, eliminating all the overhead of starting it and shutting it down that currently causes sass-embedded to be slower than it could be.

For now, we're just seeking your feedback on the proposal. Once it lands, we hope you'll integrate it into the plugin for substantially improved performance.

Expected Behavior / Situation

The plugin starts a Compiler when it initializes and uses that compiler to compile all Sass files, so that Sass users using the embedded host experience better performance.

Actual Behavior / Situation

The plugin runs a separate sass.compile() call for each compilation, which has a large amount of overhead when using sass-embedded.

Please paste the results of npx webpack-cli info here, and mention other relevant information

N/A

@alexander-akait
Copy link
Member

I agree, internal cache inside sass between compilation will be grea, it will improve perf very well, I don't have good idea how it can be implement, but ready to discuss about any suggestions

@renspoesse
Copy link
Contributor

@alexander-akait I believe the proposed API has landed in 1.70.0, https://github.com/sass/embedded-host-node/blob/main/CHANGELOG.md#javascript-api-3. Have you started any work on implementing it in sass-loader? If not, I could take a stab at it.

@alexander-akait
Copy link
Member

@renspoesse Hello, I didn't start it, so feel free to send a PR

@alexander-akait
Copy link
Member

We still not finished https://github.com/webpack-contrib/sass-loader/blob/master/src/utils.js#L614, maybe it is another API right now, need to check

renspoesse added a commit to renspoesse/sass-loader that referenced this issue Mar 29, 2024
This implements the Shared Resources proposal that was accepted and implemented in Dart Sass 1.70.0.
By reusing the same compiler process when compiling multiple files, this significantly improves
performance for tools like webpack.

Closes: webpack-contrib#1163
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 a pull request may close this issue.

3 participants