-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Option to use the DartVM executable rather than the pure-js version of dart-sass. #774
Comments
Make sense, feel free to send a PR |
https://github.com/sass/embedded-host-node, currently in Alpha, may be the easiest way to achieve this! |
Yep, but right now it is not easy |
+1! |
@alexander-akait https://github.com/sass/embedded-host-node is getting close to a usable beta that includes custom importers and many other features that the sass-loader relies on. What do you think? |
Unfortunately, I have not looked at this for a long time, if you have any ideas how we can integrate this now, you can send it, I will be glad any help |
It will be easy if they have docs 😄 @nex3 Can we try it to integrate and test or is it still very young? |
As soon as sass/embedded-host-node#94 lands, the embedded host will fully support the new JS API. I'll be cutting a beta release at that point that you can test against. |
Just to mention that @nex3 has now merged that PR and cut the beta release: https://github.com/sass/embedded-host-node/releases/tag/1.0.0-beta.8 . I'm excited about this! |
@nex3 Hi, where we can find docs about usage? Thanks |
It's all documented at https://sass-lang.com/documentation/js-api. Edit: I realized you probably meant docs specifically about using |
I tried to adopt https://github.com/sass/embedded-host-node locally, and it works good for me, I'll try it here and maybe make a release, perf is almost the same |
@nex3 Small feedback:
Example (if you change var sass = require("sass-embedded");
sass.render(
{
data: "#{headings(2,5)} { color: #08c; }\n",
functions: {
"headings($from: 0, $to: 6)": (from, to) => {
const f = from.getValue();
const t = to.getValue();
const list = new sass.types.List(t - f + 1);
let i;
for (i = f; i <= t; i++) {
list.setValue(i - f, new sass.types.String(`h${i}`));
}
return list;
},
},
},
function (err, result) {
if (err) {
// `err - Error: expected selector.` for `sass-embedded`
console.log(err);
return;
}
console.log(result.css.toString());
}
);
@import import-with-custom-logic We still use
|
https://github.com/sass/embedded-host-node/blob/main/lib/src/legacy.ts does not seem to have some of the specification included as it masks most of the options before calling the new api |
Yep, we can do it, just interesting why it doesn't work with legacy, because types exist |
hm, I was wrong, if we change |
I tried to switch on modern API, but docs are very bad and no examples (spent a lot of time to understand how new API works), so it requires more time than I think... |
Spent two days on this stuff and no luck, the new importer api is not usable and docs are very bad 😞 , https://sass-lang.com/documentation/js-api/interfaces/Importer, The problem - we don't have |
@nex3 Why Without file where it was requested we can't perform resolving, we don't know context so we don't have where we should start to resolve... |
We implemented the new API for
Correct, old importers won't work with the new JS API and vice versa. Old importers are actually quite difficult to make efficient because they don't play nicely with the concept of "canonical URLs", which was one of the motivations of moving to a new API in the first place.
I wrote all those docs, so if you can provide specific ways they could be more helpful or additional examples you'd like to see I'd be happy to improve them.
This would have been a good thing to bring up when we asked for feedback. In this case, though, there's a good reason for the behavior. There are a few invariants we want to make sure all importers abide by, in order to allow the Sass compiler to make important optimizations (like only loading each stylesheet once) and to ensure that users can consistently reason about loads:
The old importer API didn't guarantee any of these invariants. An importer could use the Rather than pushing all the complexity of handling these invariants onto importer authors like the old API, the new API is designed so that these invariants can't be violated. To quote the documentation:
For your use-case, it's probably easiest to use a |
@nex3 hello, do you have news on this? |
Looks like fixed, I will test |
Can you point to the commit which fixed this, please? |
All tests passed #1044 |
I simply add Both |
@Clarkkkk hard to say, how you profile? |
The config is like: entry: './src/index.js',
mode: 'production',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [{
test: /\.(sa|sc)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader',
options: {
modules: {
exportLocalsConvention: 'camelCase'
},
}
},
'postcss-loader',
{
loader: 'sass-loader',
options: {
sassOptions: {
charset: false
},
implementation: require('sass-embedded')
}
}
]
}]
},
plugins: [
new MiniCssExtractPlugin(),
new CleanWebpackPlugin(),
], But when I use the same config on a simple bootstrap example, |
@Clarkkkk maybe you can profile, I file loke regression on |
I'm sorry, but what do you mean 'profile'? |
Profile code and undestand where it you have perf problems, https://nodejs.org/en/docs/guides/simple-profiling/ |
Oh, I see. The original log file is quite large (over 100 M), here is the processed txt file: https://1drv.ms/t/s!AqaKW1-15JGra_rU4o09K44A04E. (It generates 12 files after compilation, and this is one that includes |
@Clarkkkk I think better to open an issue in |
I happened to give
I was surprised by this based on the results other folks have been reporting. Please let me know if you'd like me to do more benchmarking or profiling; I'm happy to help if I can. |
@AprilArcus That's expected if you're compiling many small CSS files. See sass/sass#3296. |
Unfortunately it's a common use case to have many small sass files for those using CSS Modules in a large React codebase. |
I'm using the latest sassOptions: {
api: "legacy",
webpackImporter: false,
implementation: sass,
includePaths: [
'ui/css',
'node_modules'
],
}, but this throws an error: sassOptions: {
api: "modern",
webpackImporter: false,
implementation: sass,
loadPaths: [
'ui/css',
'node_modules'
],
}, The error:
I also tried using npx sass@latest ./ui/css/index.scss ./dist/index.css --load-path ./node_modules --load-path ./ui/css I also tried setting the paths in What is the difference between sass-loader's implementation of the legacy api's |
@davidmurdoch could you create a reproduction repo. I'll have a look. |
Looks like most of tests passed - #1197, will finish soon and make a release |
Also using |
All tests passed, please try https://github.com/webpack-contrib/sass-loader/releases/tag/v14.2.0 |
Feature Proposal
Currently, the only options for
implementation
are node-sass and the pure-js version of dart-sass.There should be an option to use the fast DartVM executable version of dart-sass.
Feature Use Case
For projects that have a large codebase of sass files that need to be compiled and performance is important.
The text was updated successfully, but these errors were encountered: