Open grouma opened 4 years ago
I'm definitely interested in this topic. If this ends up being supported and used, we'll need to handle this case in our developer tools as well.
@grouma is this still the case? We've tried doing this but the apps don't run as expected unless we compile with dart2js. Is there some additional config that's required?
Many internal teams shard their applications and use the equivalent of multiple webdev
instances to serve DDC applications loaded on the same page.
Thanks for the info @grouma . Is there an example somewhere that we can take a look at to see how that works? We're quite interested in doing something similar. 😄
I don't know of any external examples. What issues are you running into? Most of the infrastructure is the same internally except how we build and the web server's module strategy. We do not use requireJS
internally.
Ya, requireJS
is part of the problem at least externally, or at least the way we use it. We have to set up a global options object which is different per application, so we can't have multiple.
It's been a while since we've tried to get this to work, but yeah it seemed like requireJs was the issue we were running into. Do you all use ES6 modules instead? Are you able to do that when using webdev or do you have to drop down to compile things with dartdevc directly?
We are using a custom module system internally (referred to as the "legacy" module system by ddc). This is a very stripped down/simple module system, and then we have a bunch of extra stuff built on top to make this work in our bootstrapping code.
Webdev itself only supports requireJs/amd for the module system.
We've drifted internally but this is essentially what we use: https://github.com/dart-lang/sdk/blob/master/pkg/dev_compiler/lib/js/legacy/dart_library.js
@jakemac53 @grouma Hi there, we're revisiting this and I want to make sure I'm following. It sounds like if we're using webdev which uses requirejs/amd for the module system, we'll be unable to run multiple DDC apps on the same page. Is that accurate? Or is this something that should be possible even without the internal legacy module system you've linked here?
Correct, webdev does not support multiple apps compiled with DDC on the same page.
Although not a common workflow, we do support debugging multiple DDC applications on the same page. We should add a few smoke tests to
package:dwds
to ensure this workflow is properly supported.