5 ms·
I can't find in the documentation, does the `pub build` tool do code splitting? I can't use a language without this.
by Touche 10y ago
I can't find in the documentation, does the `pub build` tool do code splitting? I can't use a language without this.
- markdog12 10y agoSorry 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(); }
- Touche 10y agoThat 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.
- markdog12 10y agoWhen I test this out, I get a 94KB file. That's reasonable depending on what you're doing.
- wstrange 10y agoAlso worth pointing out that Dart can do tree shaking at compile time, to eliminate library code that is never called