dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
212 stars 74 forks source link

Test loading multiple applications on the same page #1030

Open grouma opened 4 years ago

grouma commented 4 years ago

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.

leonsenft commented 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.

evanweible-wf commented 3 years ago

@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?

grouma commented 3 years ago

Many internal teams shard their applications and use the equivalent of multiple webdev instances to serve DDC applications loaded on the same page.

todbachman-wf commented 3 years ago

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. 😄

grouma commented 3 years ago

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.

jakemac53 commented 3 years ago

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.

todbachman-wf commented 3 years ago

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?

jakemac53 commented 3 years ago

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.

grouma commented 3 years ago

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

evanweible-wf commented 3 years ago

@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?

jakemac53 commented 3 years ago

Correct, webdev does not support multiple apps compiled with DDC on the same page.