Skip to content

feat(router): register NgModuleFactory objects. #11211

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

Merged
merged 4 commits into from
Sep 1, 2016

Conversation

mprobst
Copy link
Contributor

@mprobst mprobst commented Aug 31, 2016

When lazily loading code, users need to be able to get hold of the
NgModuleFactory. For SystemJS environments, the SystemJS registry serves
this purpose. However other environments, such as modules compiled with
Closure compiler, do not expose exports object or a path based registry.

For these environments, @NgModule objects can include an identifier, and
the loading code can then pass loadModule(id).then(() => getNgModule(id)) to the router.

@mprobst
Copy link
Contributor Author

mprobst commented Aug 31, 2016

loadToken is a provisional name, please suggest a better one :-)

@@ -0,0 +1,95 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file here? I don't think it is part of the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, botched merge.

@mprobst
Copy link
Contributor Author

mprobst commented Sep 1, 2016

PTAL, now with loadToken renamed to id.

@@ -107,6 +107,11 @@ export class Identifiers {
runtime: NgModuleInjector,
moduleUrl: assetUrl('core', 'linker/ng_module_factory')
};
static RegisterLoadedModuleFn: IdentifierSpec = {
name: 'registerLoadedModule',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps registerModuleFactory would be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mhevery
Copy link
Contributor

mhevery commented Sep 1, 2016

One more rename, otherwise LGTM.

@mhevery mhevery added pr_state: LGTM action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Sep 1, 2016
@tbosch
Copy link
Contributor

tbosch commented Sep 1, 2016

Also LGTM from me.

* An opaque ID for this module, e.g. a name or a path. Used to identify modules in `getNgModule`.
* If left `undefined`, the `NgModule` will not be registered with `getNgModule`.
*/
id: string|undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove |undefined as that is not compatible with typescript 1.8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

When lazily loading code, users need to be able to get hold of the
NgModuleFactory. For SystemJS environments, the SystemJS registry serves
this purpose. However other environments, such as modules compiled with
Closure compiler, do not expose exports object or a path based registry.

For these environments, `@NgModule` objects can include an identifier, and
the loading code can then pass `loadModule(id).then(() =>
getNgModule(id))` to the router.
@mprobst mprobst added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Sep 1, 2016
@mprobst mprobst merged commit ebc8e80 into angular:master Sep 1, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants