dart-lang / build

A build system for Dart written in Dart
https://pub.dev/packages/build
BSD 3-Clause "New" or "Revised" License
791 stars 211 forks source link

Multi compiler support in `dart_web_compilers` #3730

Closed simolus3 closed 2 months ago

simolus3 commented 3 months ago

In https://github.com/dart-lang/build/pull/3727, there was a discussion on how to best support scenarios where we'd compile Dart apps with dart2js and dart2wasm, using a browser compatibility check at runtime to select the right application. I wanted to extract this into a separate issue so that it doesn't get lost.

For the feature detection in an entrypoint script, we probably want to clone what Flutter is doing. A question is how this would be enabled (or if it should be the default), possible options are:

  1. Keeping the current compiler builder option and adding a new boolean flag controlling whether dart2wasm should be running too. A downside is that users then won't be able to use dart2wasm exclusively (if that's what they want).
  2. Turning the compiler option into an array (which would be a singleton if a string is given). The compiler could then default to [dart2js, dart2wasm] and the entrypoint builder would take care of emitting an entrypoint script if multiple compilers are enabled. A question is what we'd do if both dartdevc and dart2js are listed - we could simply reject those configurations, or only consider dart2js in the entrypoint script while still emitting dartdevc modules (can be useful for tests where one wants to test compatibility with all three compilers).

A couple of follow-up issues before we call this closed.

jakemac53 commented 3 months ago

There is also the option of a dart2wasm+dart2js named compiler or something. I think I like that more than an array of compilers where we have to check the valid combinations.

simolus3 commented 2 months ago

Is there anything left I can help with to get this released?

kevmoo commented 2 months ago

I think we're done, modulo bugs. The question: do we release before Dart 3.6 stable is out.

We could do a beta release, if that's useful for you.

simolus3 commented 2 months ago

Well I'd definitely prefer a beta release over having to add git dependency overrides everywhere :) I've opened a PR for that, but if it's too much work to get this released it's not critical either.