build icon indicating copy to clipboard operation
build copied to clipboard

Consider building the Dart SDK with package:build instead of using the prebuilt dart_sdk.js

Open vsmenon opened this issue 5 years ago • 8 comments

We may want to consider building the Dart SDK (i.e., the JS files) from sources instead of using the prebuilt dart_sdk.js.

We already ship sources with the SDK (need to check for which backend - I suspect it's dart2js).

Some advantages:

  • Source maps for the SDK just work.
  • More intelligent chunking of SDK (instead of one monolithic JS file).
  • Enables fast iteration / hot reload on dart:* packages.
  • Enables experimental feature testing/eval in SDK (e.g., NNBD).

Disadvantages:

  • Additional one-time startup cost to compile the SDK.
  • Need to figure out packaging of DDC version of sources (where to apply patch files).

fyi - @jakemac53 - per earlier conversation.

vsmenon avatar May 09 '19 19:05 vsmenon

fyi - @nshahan - if we go this route, we could stop packaging all dart_sdk.js.

vsmenon avatar May 09 '19 19:05 vsmenon

This may also be the cleanest way to facilitate the Flutter Web team's req for fast iteration on dart:ui.

vsmenon avatar May 09 '19 19:05 vsmenon

If we remove the "Potentially" qualifier for the "fast iteration / hot reload on dart:* packages" feature, then the Flutter team could get behind this request. We currently need to jump through hoops to get a reasonable dev environment for the Web engine.

yjbanov avatar May 10 '19 05:05 yjbanov

I don't believe there is any known issue that would prevent exactly the same fast iteration (and even hot restart) behavior as you get when developing packages. I think @vsmenon was just being conservative with the "Potentially" wording given we don't even have a proof of concept at this time.

If we couldn't enable those things, we almost certainly would not do this. The only motivation at that point would be download size of the sdk.

jakemac53 avatar May 10 '19 15:05 jakemac53

Additional one-time startup cost to compile the SDK.

This would be once per "clean build" - so it would happen on every pub upgrade as well as SDK upgrades.

natebosch avatar May 10 '19 16:05 natebosch

Technically it only happens on pub upgrade if a package imported by the build changes, but that is pretty likely to happen :).

jakemac53 avatar May 10 '19 16:05 jakemac53

"Potentially" removed from initial post. We should focus on solutions that enable fast iteration.

vsmenon avatar May 10 '19 16:05 vsmenon

fyi @sigmundch

Some notes:

  • We current bundle all sources with the SDK, but only dart2js versions (including non-public files like core_patch.dart, js_helper.dart, etc) - not VM or DDC.
  • dart2js doesn't use those anymore since we now also include the precompiled dill).
  • The sources are used for code completion.

So, we probably could switch this over to (or just add) DDC specific sources.

vsmenon avatar May 10 '19 17:05 vsmenon

Pretty sure we do this now :)

jakemac53 avatar Sep 01 '23 17:09 jakemac53