sass / dart-sass

The reference implementation of Sass, written in Dart.
https://sass-lang.com/dart-sass
MIT License
3.87k stars 350 forks source link

Add WASM compilation target #2250

Open dmichon-msft opened 3 months ago

dmichon-msft commented 3 months ago

Now that Dart supports WASM as a compilation target, produce a version of dart-sass compiled to WASM for distribution (compatible with NodeJS 21+): https://dart.dev/web/wasm

nex3 commented 3 months ago

I don't know that we can realistically ship this until April 2026 when Node.js 20 leaves LTS, since we're required by our compatibility policy to continue supporting LTS Node.js releases and npm isn't smart enough to install different packages for different SDK versions.

It's also currently an open question whether WASM actually provides any performance benefits, or how feasible it would be to wrap it with a JS API. One possibility is that we replace the embedded host with WASM as a way of reducing cross-process overhead, but that's also contingent on the runtime performance being comparable with a native executable. Another is that we use the embedded host infrastructure for the main Sass release as a way of exposing the JS API with minimal additional wrapping.

nex3 commented 3 months ago

I spent some time today doing a bit of preliminary investigation of this. Here are some issues I've identified, in no particular order:

If anyone is interested in helping with this effort, the best place to put your energy in the short term would be migrating node_interop to use dart:js_interop.