-
Notifications
You must be signed in to change notification settings - Fork 433
Lazy loading error when trying to AoT output code to es6 #394
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
Comments
Lazy loading works by default yes, I just removed the webpack folder (since it's no longer being used), maybe that was causing some issues? { path: 'lazy', loadChildren: './containers/lazy/lazy.module#LazyModule'}, |
@MarkPieszak |
So this is because yes, unfrotunately right now you can't output es6 code during AoT. |
I am having the same issue with es5, no lazy loading files being created when compiling AOT: Trying to learn this but shouldn't the AOTPlugin point to tsconfig.spec.json file, or how does the compiler know what typescript configuration file to use? new AotPlugin({ |
Each one simply points to the browser or server NgModule, and ignores the other files (browser or server boot files). new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#AppModule'),
exclude: ['./**/*.server.ts']
})
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: path.join(__dirname, 'ClientApp/app/app.module.server#AppModule'),
exclude: ['./**/*.browser.ts']
}) The spec tsconfig is for unit tests (.spec files). As for Lazy routing not being initialized during server renders it's most likely that you need the additional Router options we have in the template. initialNavigation gets it to lazy load it immediately, as you need it right away during server renders. RouterModule.forRoot([
/* all the routes */
], {
// Router options
useHash: false,
preloadingStrategy: PreloadAllModules, // <---
initialNavigation: 'enabled' // <--- especially this one
}) Hope that helps! |
Thanks Mark, but my issue is when publishing the latest version of aspnetcore-angular2-universal. This is the full output:
Module not found(0,0): Error : Can't resolve './../$$_gendir/ClientApp/app/app.module.browser.ngfactory' in 'C:\dev\tutorials\aspnetcore-angular2-universal\ClientApp'
C:\dev\tutorials\aspnetcore-angular2-universal\Asp2017.csproj(44,5): Error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 2. |
Are you on Windows 10 by any chance? @swaner What version of |
Yes, Windows 10 Enterprise indeed. I am using the latest version from git, no changes. I tried the workaround, got a different error. Will investigate further later:
|
Did you try this workaround in your webpack config? Windows 10 is really finicky and has quite a few problems when it comes to command line stuff :( |
Yes it got solved, to be honest not quite sure why. I removed the whole folder, cloned into another folder and it just worked. It even created the lazy loading module (this was my original issue). In my own project, I needed to add the
|
@swaner So you are saying you can get lazy loading to work without angular-router-loader? Is it defined globally maybe? |
I am trying to merge my application with latest aspnetcore-angular2-universal after a few months.
Is lazy loading module supported in latest release?
I get error at runtime in code:
which is transpile to:
And the error happens here:
With error:
The text was updated successfully, but these errors were encountered: