sass / dart-sass

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

Use DDC for JS compilation #6

Open nex3 opened 7 years ago

nex3 commented 7 years ago

The Dart dev compiler produces much nicer-looking JavaScript output than dart2js, and makes JavaScript interop much nicer by guaranteeing that all Dart objects can be used directly in JS without extra wrappers. This will be very useful for custom functions, which will need to be able to interact with SassScript values with as little overhead as possible.

This is currently blocked on dart-lang/sdk#27607.

matanlurey commented 7 years ago

@nex3: I imagine though you'd still want dart2js for the "binary", right?

i.e. dart-sass.js (dart2js) and dart-sass.debug.js (using DDC)

nex3 commented 7 years ago

I'd rather avoid shipping two copies of the compiled codebase. @jmesserly was saying that they'll probably be comparably fast if we avoid dynamic dispatch.

jmesserly commented 7 years ago

It should be in the same ballpark, yeah, but worth verifying that.

Where it may fall behind are places where dart2js type inference knows more than the Dart types in the program. For example dart2js knows something is never null but DDC doesn't (DDC has some limited local nullable type inference that helps somewhat). It's also possible that DDC's covariance checks will prove to be expensive (dart2js needs them too but has more type test optimizations). I was hoping for a sufficiently expressive type system that null checks and type checks could be avoided if the developer wishes, but we're unfortunately not there yet.