Comments (5)
Sounds exactly like what I recall from the meeting. 👍🏼
I have a few minor notes though:
- Register a new
router
service that proxies all its methods to the host'srouter
service. Every method invocation that's passed should include a deprecation warning.
Unconditionally creating a proxy router
service in every engine may cause unintended side-effects, e.g. some addon or user code may check for the existence of a router
service and use different adapters then. Considering that addons that deal with routing need to special-handle engines in one way or another, if they want to be compatible, the likelihood is not zero, that the mere presence of a router
service could change the behavior.
On the other hand, this may be super-edge-case-y, SemVer-lawyering-wise still okay and not even a real issue.
We could however only setup the proxy router
service, when a service with that name is actually injected into the engine.
Which is a nice segue into my next nitpick:
[...] proxies all its methods to the host's
router
service [...]
This would not work for these two scenarios:
- Engine implements and registers the
router
service by itself. It is not an external injection. - The host remaps / aliases the
router
service name and e.g. injectsmock-router
asrouter
.engines = { superBlog: { dependencies: { services: [ // name in superBlog engine: 'store' // name in host: 'store' 'store', // name in superBlog engine: 'router' // name in host: 'mock-router' { 'router': 'mock-router' } ] } } };
Instead of always "blindly" proxying to the host's router
service, I would prefer, if we could somehow "wrap" the actual router
service instance, when it gets registered / injected. This way we would:
- only make
router
available in engines, where it already was available - don't accidentally break custom interfaces introduced by users, who use some sort of custom
router
service, i.e. not theapp-router
.
For instance, at @ClarkSource we've been using our own make-shift engine-specific router service as router
inside many engines for 2½ years now, basically ever since I opened #587.
We should also consider allowing an experimental build flag to allow usage of an alpha engine-specific router which we can iterate upon starting in 0.9. This approach should allow opt-in usage of a router service similar to that in #669 for developers who are willing to experiment and endure some breaking changes.
Big 👍🏼.
from ember-engines.
Ya, sounds like a good summary here to me.
from ember-engines.
Great summary, thanks @dgeb
But I think you can put here how the new router
service will work in js and template files and the relation with *External
methods to give more context
from ember-engines.
Closing now, since this has effectively been resolved via the deprecation introduced in #764. As discussed in that PR, the assumption about automatic injection of the host's router
was incorrect. This is greatly simplifying, since we only needed to deprecate injection of the router
service and no longer need to deal with the complexities of a proxy router (which @buschtoens mentions above).
from ember-engines.
The one piece left todo is this:
We should also consider allowing an experimental build flag to allow usage of an alpha engine-specific router which we can iterate upon starting in 0.9.
This can be handled in a subsequent PR.
from ember-engines.
Related Issues (20)
- Pod style with tailwind inside in-repo engine doesn't processed correctly HOT 3
- [RFC] Deprecate `{ 'engine-service': 'host-service' }` syntax for service dependencies HOT 1
- Lazy loading changes output path of assets HOT 1
- [RFC] Provide `externalRouter` to Engines HOT 5
- `@embroider/macros` macro conditions can sometimes be evaluated incorrectly HOT 1
- Unknown object passed to sourceOfConfig() error HOT 6
- How to install an addon in an engine? HOT 2
- getOwner doesn't return the context for the route HOT 3
- cannot find module "@ember/routing/link-component" in ember ~4.1 HOT 2
- Class extends value [object Object] is not a constructor or null HOT 3
- Could not find module `@ember/legacy-built-in-components` HOT 2
- error reading "inaccessibleByURL" is undefined sometimes
- build error after upgrading to 0.9.0 HOT 3
- Service dependencies do not pass through properly in embedded engine (Ember 3.28) HOT 3
- Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'on') HOT 1
- dependencies do not pass through properly in embedded engine under single spa
- 0.8.22 breaks compatability with Ember > 3.24 HOT 2
- Transitioning from one engine route to another triggers a Cannot read properties of undefined (reading 'shouldSupersede')
- Rebuild crash on Ember 4.12.1 apps - Ember CSS file HOT 1
- Getting ember-source dependency conflict with ember-source 5.3 HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-engines.