Skip to content
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

initial work for Aot support #13

Merged
merged 4 commits into from
Jan 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ng2/lazyLoadNgModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type NgModuleToLoad = string | ModuleTypeCallback;
* - Returns the new states array
*/
export function loadNgModule(moduleToLoad: NgModuleToLoad): (transition: Transition) => Promise<LazyLoadResult> {
return function(transition: Transition) {
return (transition: Transition) => {
Copy link
Member

Choose a reason for hiding this comment

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

can you explain why this was necessary? I don't see any this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To use function it should be exported, it will not work with AoT when it is passed to an NgModule

const ng2Injector = transition.injector().get(NATIVE_INJECTOR_TOKEN);

const createModule = (factory: NgModuleFactory<any>) =>
Expand All @@ -53,7 +53,7 @@ export function loadNgModule(moduleToLoad: NgModuleToLoad): (transition: Transit
return loadModuleFactory(moduleToLoad, ng2Injector)
.then(createModule)
.then(applyModule);
}
};
}

/**
Expand All @@ -80,7 +80,7 @@ export function loadModuleFactory(moduleToLoad: NgModuleToLoad, ng2Injector: Inj
const compileAsync = (moduleType: Type<any>) =>
compiler.compileModuleAsync(moduleType);

return offlineMode ? loadChildrenPromise : loadChildrenPromise.then(compileAsync)
return offlineMode ? loadChildrenPromise : loadChildrenPromise.then(compileAsync);
}

/**
Expand Down