-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Lazy Loading engines #51
Comments
Yeah, we do. I'll try to take some time in the next day or two and comment with some of the ideas... |
Their have been several issues opened in the past, I believe the RFC has some relevant comments. From memory the following needs to be fixed:
|
thanks @stefanpenner, that summarizes the path pretty well |
Will this feature have to be used with fastboot, or will the dist contain everything necessary? Like will the paren't app append engine script tags to the DOM when the user triggers an engine for the first time? |
When we have written the code, we will let you know. 😺 In all seriousness though, we do not plan to require fastboot for anything in this addon. |
Excellent 👍 |
likely this |
The last time I explored this for ember-admin I believe it could be possible by modifying how the resolver does look ups. If a module is not found locally the resolver would defer to fetching the resource remotely then try the lookup again. At that point the resolver has the resource cached. Its been a while since I mucked around inside the resolver code but it would be ideal if however the remote fetch is done that the resolving itself is promise-based the consuming application can give some state indication that the engine's loading is |
Looks like ember engines may be what I'm looking for especially lazy-loading. In my modular structure, several engines will be distributed in different directories. Will it be possible to load engines that are not explicitely installed with |
This is something that I am also interested in. For my use-case, a majority of engines wouldn't actually be installed into the main application at build time. They would instead be built independently and the application would be required to locate, configure and mount them at runtime. |
I don't believe this should be a resolver concern, or atleast shouldn't be at the per-module granularity as they would force all possible module loads to be async. I believe that would result in much more complexity then we want to deal with. Instead larger slabs, like per engine async'ness is likely the best balance. This keeps async to explicit points where async can be correctly handled, not at every possible resolve step. |
@stefanpenner and @dgeb I spent time working on lazy-loading for an app. Some of this work could help engines and I have some time to work on it. I solve some of the points that you mentioned above:
I solved this by using a catch-all route, abort the transition, load the bundle with the route and then resume the transition. You can see an example on routes/catch-all#redirect.
I've been ignoring it for now, but it might just work with the approach above.
This is a bit hacky and I still plan to extract it. Likely the
Alternatively, we could provide the configuration for each engine's
For now, I'm avoiding that or simply using a new
Still WIP, but the idea is to define the list of asset URLs based on the names of the bundles in a map {engine-name: /assets/engine-name.js} and let AssetRev tweak it. You can see an example on index.html. The map isn't used yet at runtime, I want to move away from the global, so that's why it still needs some work. I have an example of all of this working on https://github.com/MiguelMadero/ember-cli-packages-demo/. I would love your feedback on this and as I mentioned, I have some time to see help push this forward. |
Just wanted to get this out there, but if the query params API was a service, it would be simple to integrate between different engines. |
@mike183 - that's exactly what I'm looking for as well. @dgeb - will this be possible with ember-engines in the future? That would allow users to customize an app by selecting the engines they actually need. At the moment it looks like every engine to be consumed needs to be defined at build time... |
@mike183 @peStoney Sorry to delay with a response. It is theoretically possible that routeless engines could be lazy-loaded by a parent that doesn't have any foreknowledge of the engine. However, routable engines need to eagerly provide their route maps to their parents to support routing into them that triggers lazy-loading. |
This issue has been superceded by #154 |
So in the readme it's mentioned that this is coming soon. I'm wondering how this will work, since it seems like you have some ideas already.
The text was updated successfully, but these errors were encountered: