Skip to content
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

[webdev] Generate auto-switching combined build for dart2js and dart2wasm output #2296

Open
parlough opened this issue Dec 5, 2023 · 13 comments
Assignees
Labels
P2 A bug or feature request we're likely to work on package:webdev triaged type-enhancement A request for a change that isn't a bug

Comments

@parlough
Copy link
Member

parlough commented Dec 5, 2023

I'm not exactly sure at what layer this should be in, but webdev seems like an most appropriate place. Happy to hear what other's think! Perhaps it does make sense directly as a dart subcommand, not sure.

Building on dart-lang/sdk@0df58fc and eventually dart-lang/build#3621:

I think webdev should have a release mode that generates output with both dart2js (dart compile js) and dart2wasm (dart compile wasm). Then it should generate a JS script which chooses between them based on browser capabilities.

Developers can technically do this themselves, but I imagine it will be common enough that it's worth having some built-in functionality to do so.

Perhaps for a while, this can be a separate mode from the existing --release, but eventually I'd expect this to be the default.

\cc @kevmoo @jakemac53 For general thoughts, including about where this functionality could live.

@jakemac53
Copy link
Contributor

jakemac53 commented Dec 6, 2023

This probably has to be a part of the build package explicitly, because usually we don't support compiling the same app with multiple compilers (as a part of a single build). We could though, and I had just yesterday started some informal conversations regarding how we should do the switching too, as a part of dart-lang/build#3621 :).

@mit-mit
Copy link
Member

mit-mit commented May 28, 2024

Functionally I think we'd want something like this:

  • webdev serve: Do DDC compilation + serve up result
  • webdev build: Do dart2js & dart2wasm compilation; plus bundle up in some out folder with bootstrapping logic that selects between JS and Wasm in the browser.

wdyt @jakemac53 @kevmoo ?

@jakemac53
Copy link
Contributor

That seems pretty reasonable, and I was looking into doing this before, but I need good direction from the dart2js/wasm teams on how to implement the JS/Wasm switching.

@kevmoo
Copy link
Member

kevmoo commented May 28, 2024

@jakemac53 – @eyebrowsoffire has figured this out for Flutter. We should look to share logic as much as possible!

@bkonyi bkonyi added type-enhancement A request for a change that isn't a bug P3 A lower priority bug or feature request triaged labels Aug 21, 2024
@bkonyi
Copy link
Collaborator

bkonyi commented Aug 21, 2024

@kevmoo @mit-mit is this something that we should prioritize?

@kevmoo
Copy link
Member

kevmoo commented Aug 21, 2024

@bkonyi – I'd LOVE to have this.

And we have the first step here: dart-lang/build#3727

CC @jakemac53 who has been helping on the review side

@mit-mit
Copy link
Member

mit-mit commented Aug 21, 2024

Yeah, +1, this would be great to enable the ecosystem

@simolus3
Copy link

I have also opened dart-lang/build#3737 as a follow-up for build_web_compilers to optionally compile with both compilers and then generate an entrypoint script loading the correct entrypoint based on browser features.
I don't think there's anything that webdev would have to do in addition to that.

@bkonyi bkonyi added P2 A bug or feature request we're likely to work on and removed P3 A lower priority bug or feature request labels Aug 22, 2024
@jakemac53
Copy link
Contributor

jakemac53 commented Oct 9, 2024

We can likely close this? build_web_compilers does support it now (in the recent beta versions).

@bkonyi
Copy link
Collaborator

bkonyi commented Oct 9, 2024

@jakemac53 are you 100% sure this is supported? If not, how would we go about confirming it is?

@jakemac53
Copy link
Contributor

jakemac53 commented Oct 9, 2024

You will need to update to the latest build_web_compilers (one of the 4.1.0-beta versions) and add this to your build.yaml:

targets:
  $default:
    builders:
      build_web_compilers:entrypoint:
        release_options:
          compilers:
            dart2js:
            dart2wasm:

Or at least, I think that is all you need :). Might be worth adding an integration test to webdev?

This only changes the release mode config (which I think for webdev means just the build command). I can't recall if webdev allows you to serve in release mode.

You could alter the dev mode as well by using options instead of release_options.

@bkonyi
Copy link
Collaborator

bkonyi commented Oct 9, 2024

Sounds good! @jyameo, can you take a look at this when you have a chance?

@jakemac53
Copy link
Contributor

jakemac53 commented Oct 9, 2024

Fwiw there is also a way on the command line to set this configuration. So, webdev could in theory have a command line argument which it converts into the more complicated builder option command line argument which it passes to the build daemon. If you want to go that route feel free to reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on package:webdev triaged type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants