-
Notifications
You must be signed in to change notification settings - Fork 207
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
Support compiling to wasm in build_web_compilers
#3727
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One higher level comment here, is that we want to be able to support some form of auto-switching between dart2wasm and dart2js based on browser support.
This would imply being able to compile both with dart2js and with dart2wasm simultaneously, which somewhat complicates things.
I actually ran into this problem already, haha. I thought I could just apply the entrypoint builder twice to different targets to fix this, but I think in the end we may want to support four options in the
For 4, the question is how the auto-switching would look like. We could embed a suffix to the dart2js entrypoint file to either invoke the |
I support getting wasm working first, then enabling the runtime detection. We should look to see what Flutter does here. I wish we had a good place to put the shared logic! |
We may need dart2wasm+DDC and dart2wasm+dart2js eventually? I was thinking about splitting out whether "wasm" is enabled or not as a separate thing? Then we don't have to have an option for every combination. Maybe, an
Yeah I think we need something like this.
I am fine with that, but we need to make sure the user facing configuration is compatible with a future mode that does runtime detection. |
I agree that eventually compiling with both + emitting a small launcher doing feature detection and picking the appropriate one is the way to go. It's also a good default. However, there are also some cases where we want to compile with both, but also make an explicit decision about which one to use. One case that comes to mind is prebuilt tests with |
I don't believe there is one, the SDK does completely its own thing for wasm testing (I have no idea how this works). |
4f6cacd
to
ec6cb2d
Compare
I think this PR now covers everything for basic dart2wasm support - I've opened #3730 for the future work of compiling with multiple compilers. @jakemac53 I've added you as a reviewer on https://dart-review.googlesource.com/c/sdk/+/377662 which needs to land before we can ship this. I don't what the right process is to get SDK CLs reviewed, could you help me find reviewers for dart2wasm that may review that CL? |
@@ -4,4 +4,5 @@ | |||
|
|||
export 'message.dart' | |||
if (dart.library.io) 'message_io.dart' | |||
if (dart.library.html) 'message_html.dart'; | |||
if (dart.library.html) 'message_html.dart' | |||
if (dart.library.ffi) 'message_ffi_without_io.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be the default import probably too, but either way works. @kevmoo do we have a recommended way to target wasm with conditional imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO! @sigmundch is working on that RIGHT NOW.
After this lands we can check for js_interop & !js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(er, after we have a dev SDK that supports this release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the import chain to check for dart:js
not being available and dart:js_interop
being available.
However, citing the 3.5 release announcement:
We plan on deprecating the old interop APIs (dart:html, dart:js, package:js, etc.) in our next Dart release, and fully discontinuing them later next year.
This makes it sound like there's soon going to be a dart2js
version that doesn't support dart:js
either, which will once again mean that there's no way to distinguish the compilers through conditional imports.
@simolus3 – if we wait for We'll just need to ponder if we want build_web_compilers limited to that SDK for a while. Something to discuss... |
Fwiw I am perfectly fine with build_web_compilers only supporting dev SDKs or whatever, it is often in that state. And nobody seems to complain 🤷♂️ |
@jakemac53 – ditto! |
47395da
to
ca4b498
Compare
Ooo! Looks like 3.6.0-150.0.dev has the fix you want. So |
@simolus3 – for auto-switch, have you looked at the code in Flutter? |
Flutter is doing a lot more (like also importing skwasm and so on), but the loader script is minified from these sources using esbuild. I think in the end we can pretty much copy this check to detect whether the browser supports dart2wasm. It's unlikely that we can ever share the files though. Is it fine if we do this in another PR? |
Need to do some work to be CI happy... |
The latest release on the |
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Package publish validation ✔️
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
a7c3f86
to
84a98ab
Compare
I guess we DON'T have a release after |
Looks like 3.6.0-165.0-dev has just been released, so maybe it works when triggering the CI again? |
84a98ab
to
d21d5db
Compare
Co-authored-by: Jacob MacDonald <jakemac@google.com>
7c1f556
to
b9d8a0f
Compare
I've done that, let's see if it works. A downside is that |
Thanks for your patience here @simolus3 – lets see if tests pass |
Not sure I follow - that is a feature request for mono_repo?
I think this is the same request as dart-lang/pub#4357 |
Let me know if there's anything else for me to do here now that the tests are passing. I think the package version thing is a mono_repo issue primarily (it tests each package with the oldest SDK it claims to support, which can break in workspaces if other packages require newer SDKs). |
Similar, but not quite. The main difference is I would still want it to use a path dependency for all the packages in the workspace that the package does depend on. I do have access to the entire workspace, and not just a single package, and the package may rely on unpublished functionality from some of the workspace packages. |
Just took a final pass with a few final nits, then we can land this. @kevmoo would we want to ship this ASAP? |
Not sure I follow - if you feel like it, could you open a feature request with perhaps an example scenario of what you would like to be able to do? |
Add
dart2wasm
as a compiler option forbuild_web_compilers
.This is still incomplete, since:
dart compile wasm
to support--multi-root
: https://dart-review.googlesource.com/c/sdk/+/377662Closes #3621