Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I can't find in the documentation, does the `pub build` tool do code splitting? I can't use a language without this.


Sorry for my ignorance, but does that amount to loading a library on demand? If so, yes, Dart can do this:

  import 'package:deferred/hello.dart' deferred as hello;
  // When you need the library, invoke loadLibrary() using   the library’s identifier.

  greet() async {
    await hello.loadLibrary();
    hello.printGreeting();
  }


Also worth pointing out that Dart can do tree shaking at compile time, to eliminate library code that is never called


That does indeed work. I just tried it, and it works beautifully.

The only problem is that the main output js file is still 107kb, quite large.


When I test this out, I get a 94KB file. That's reasonable depending on what you're doing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: