GithubHelp home page GithubHelp logo

Comments (16)

mike183 avatar mike183 commented on May 22, 2024 3

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 ember install command but by telling ember (maybe in the html or via rest-api) where to find an engine at which mount point?

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.

from ember-engines.

dgeb avatar dgeb commented on May 22, 2024 2

This issue has been superceded by #154

from ember-engines.

rwjblue avatar rwjblue commented on May 22, 2024

Yeah, we do. I'll try to take some time in the next day or two and comment with some of the ideas...

from ember-engines.

stefanpenner avatar stefanpenner commented on May 22, 2024

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:

  1. Router.js needs to support routing to handlers that are not yet loaded
  2. Likely something about query params
  3. slight addition to concat-phase of ember-cli + some config to enable a quick path for this. (Although more intelligent packaging aka linker/packager work will likely be able to solve other relevant issues, like splitting vendor etc but in a more automatic way)
  4. in the past, the route serialization stuff was a concern but i believe right now we don't allow link-to between engines, is that correct?
  5. be sure to add support for lazy-loading fingerprinted bundles

from ember-engines.

rwjblue avatar rwjblue commented on May 22, 2024

thanks @stefanpenner, that summarizes the path pretty well

from ember-engines.

knownasilya avatar knownasilya commented on May 22, 2024

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?

from ember-engines.

rwjblue avatar rwjblue commented on May 22, 2024

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.

from ember-engines.

knownasilya avatar knownasilya commented on May 22, 2024

Excellent 👍

from ember-engines.

stefanpenner avatar stefanpenner commented on May 22, 2024

or will the dist contain everything necessary?

likely this

from ember-engines.

bcardarella avatar bcardarella commented on May 22, 2024

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

from ember-engines.

gossi avatar gossi commented on May 22, 2024

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 ember install command but by telling ember (maybe in the html or via rest-api) where to find an engine at which mount point?

from ember-engines.

stefanpenner avatar stefanpenner commented on May 22, 2024

Its been a while since I mucked around inside the resolver code

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.

from ember-engines.

MiguelMadero avatar MiguelMadero commented on May 22, 2024

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

Router.js needs to support routing to handlers that are not yet loaded

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 wanted to do it in a way that I didn't have to patch Ember, but I could do something similar in router.js

Likely something about query params

I've been ignoring it for now, but it might just work with the approach above.

slight addition to concat-phase of ember-cli + some config to enable a quick path for this. (Although more intelligent packaging aka linker/packager work will likely be able to solve other relevant issues, like splitting vendor etc but in a more automatic way)

This is a bit hacky and I still plan to extract it. Likely the packager will be a better long-term solution, for now, I'm basically using a different EmberApp for each "package" (you can think of them as engines, but I wanted to use a different term to make it clear that this isn't the same thing). You can see an example on ember-cli-build, but this could be encapsulated in something that looks like:

var emberApp = EmberAppWithPackages({
  sharedConfig: {},
  bootAppConfig: {},
  packagesConfig: {}
});

Alternatively, we could provide the configuration for each engine's index.js file, but still let the consuming app provide overrides. Although this works, I don't think it's they way to go, it is just the way I solved it without tweaking CLI internal's or re-doing this work directly in broccoli and breaking add-ons.

in the past, the route serialization stuff was a concern but i believe right now we don't allow link-to between engines, is that correct?

For now, I'm avoiding that or simply using a new {{link-to}} helper that uses the default serialize behavior until we get a way to override it in Router.map.

be sure to add support for lazy-loading fingerprinted bundles

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.

from ember-engines.

knownasilya avatar knownasilya commented on May 22, 2024

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.

from ember-engines.

peStoney avatar peStoney commented on May 22, 2024

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.

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

from ember-engines.

dgeb avatar dgeb commented on May 22, 2024

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

from ember-engines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.