-
Notifications
You must be signed in to change notification settings - Fork 36
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
Design: Replacement Service Registry #1366
Comments
@adamshone / @andyberry88 / @bit-shifter / @briandipalma / @hobojed / @james-shaw-turner / @janhancic / @stevesouth / any body else that's interested, the plans for a replacement service registry have been evolving based on your feedback, and an updated proposal is now available that it would be good to further feedback on. I've created a new issue since the original thread had become too long, and wasn't based on this updated proposal. Please help to fix any remaining issues now as this is an important infrastructure piece that will affect all of you in the future. |
I couldn't figure out from this proposal if the problem of requiring services in the top-level is solved. Certain services (config service, html service) cannot be required outside of a constructor/method/function as they get run when a module is defined. Does this solve the problem? |
I started trying to form an opinion on the new proposal but quickly realised I don't have a good enough understanding of the current implementation to comment on the changes. I've asked @james-shaw-turner if we can talk it through this afternoon. |
@janhancic, yes, this problem is solved by moving service requires into the constructor, and using |
@adamshone, what, as part of the Architecture meeting at 3pm? Yes, good idea if it doesn't already have an agenda. |
So it's not solved then. We always require our dependencies up front in our code (unless it would be a circular dependency otherwise). This would mean we would have to change a lot of code. A lot. Also, what does |
Oh, sorry, I may have confused you, I was specifically talking about services that themselves depend on other services. For normal code you are free to require stuff up top since the app is expected to fetch any dependent services beforehand (via
It will continue to proxy to a registry as it does now — while we could theoretically leave it proxying to the old registry (which itself will be updated to proxy to the new registry) it will almost certainly be updated to proxy directly to the new registry. This issue is making no effort to change how sub-realms works, though we are starting to think about doing things differently ahead of adding ES6 transpilation support (see the half-baked #1303). |
Having spoken yesterday with @adamshone, @andyberry88, @james-shaw-turner & @janhancic it was noted that this proposal isn't quite right as it currently stands since, at present, classes are sometimes able to retrieve services without any problems, yet at other times this may fail. We could fix this by insisting that classes can't request service references at define-time, which can be achieved by making the following changes:
Given that the registry is the thing that constructs services, it would even be possible to fail-fast if a service that is being constructed requires any services that weren't explicitly defined as dependencies, since otherwise services may occasionally be able to get away with this, depending on load order. |
We also discussed the following things, for which I don't think we have answers/solutions for yet:
One additional thing that I'm not clear on is how's the backward comparability going to be. This questions spring to mind:
|
Yes, I think this is a good idea.
We could do this, but we'd need a way to differentiate between services and aliases, we'd no longer make it possible for CT to modify service behaviour to help with backwards compatibility, and we'd lose the flexibility of being able to add new things into the registry in the future. Perhaps you have some ideas about this?
Test suites will use
Yes, still supported, but won't be able to happen at define-time. Unfortunately some re-jigging may be required here, though I believe that doing this was likely to cause problems before too?
Sub-realms aren't used to override a service, they're used to override a module definition. They will continue to work as before. |
@janhancic, the other thing that keeps coming to mind is whether we should not bother dropping support for If we went that route than we'd still recommend developers not to require services at define-time, and in fact we'd guarantee to throw an exception for apps having a globalization block. |
I've been thinking about the fact that the design so far was based on the mis-information that ES6 modules can't be replaced once they've been cached, whereas we now know this has not yet been decided (see lukehoban/es6features#75). The fact that the current polyfills do allow this is probably a good enough reason for us to continue using this feature since it's necesarry for both the The fact the Module Loader API for ES2016 will be informed by the polyfills that people use in the interim means that these features may end up becoming standardized anyway, and if not then we can just continue shimming the Module Loader API in future ES2016 compatible browsers. Given all of that, a design where we don't try to deprecate the
BRJS Backwards Compatibility Issues:
CT backwards compatibility Issues:
|
What I said was that only the exporting module could modify what it exported. Where has this changed in the loader spec? Don't confuse the fact that you can register modules with the ability to change the bindings that have already been created by all the importing modules. Allowing that sort of power would seem to undermine the static nature of ES6 import/exports. |
I've created a |
The design for this work is now available as: |
This issue is where discussion of the Replacement Service Registry plan should occur.
The text was updated successfully, but these errors were encountered: