Skip to content

build aot failed when having lazy load #2602

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

Closed
jjlgjkkl opened this issue Oct 9, 2016 · 4 comments
Closed

build aot failed when having lazy load #2602

jjlgjkkl opened this issue Oct 9, 2016 · 4 comments

Comments

@jjlgjkkl
Copy link

jjlgjkkl commented Oct 9, 2016

there is a loadChildren in my project
export const routes: Routes = [
{ path: '', redirectTo: 'test01', pathMatch: 'full'},
{ path: 'test01', loadChildren: 'app/testing01/test01.module' },
when ng build --aot
exception occurred:

0% compiling can't resolve module D:/ng2/aotdemo/src/app/testing01/test01.module.ts from D:/ng2/aotdemo/src/app/testing01/test01.module.ts
can't find symbol MainModule exported from module D:/ng2/aotdemo/src/app/testing01/test01.module.ts
Error: can't find symbol MainModule exported from module D:/ng2/aotdemo/src/app/testing01/test01.module.ts
at ReflectorHost.findDeclaration (D:\Users\iminar\Dev\angular\modules@angular\compiler-cli\src\reflector_host.ts:200:15)
at _loop_1 (D:\Users\iminar\Dev\angular\modules@angular\compiler-cli\src\codegen.ts:62:45)
at CodeGenerator.readFileMetadata (D:\ng2\aotdemo\node_modules.npminstall@angular\compiler-cli\0.6.4@angular\compiler-cli\src\codegen.js:66:13)
at D:\Users\iminar\Dev\angular\modules@angular\compiler-cli\src\codegen.ts:105:56

i am using

"angular-cli": "1.0.0-beta.17",
@angular 2.0.2

@dev-johnny-gh
Copy link

+1

@hassanasad
Copy link

I could never get loadChildren to work so simply as loadChildren: 'app/testing01/test01.module' in webpack.

I use something like this:

loadChildren: () => new Promise(resolve => {
    (require as any).ensure([], () => {
        resolve(require('./testing01/test01.module').default);
    })
})

and then in the test01.module file

export default class Test01Module { }

But this might not work for --aot flag.

@filipesilva
Copy link
Contributor

Dupe of #2452

@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants