-
Notifications
You must be signed in to change notification settings - Fork 12k
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
fix(@ngtools/webpack): fix aot builds using npm packages that have la… #5594
Conversation
const lr = path.relative(this.basePath, lazyRoute.replace(/\.ts$/, '.ngfactory.ts')); | ||
this._lazyRoutes[k + '.ngfactory'] = path.join(this.genDir, lr); | ||
const lr = path.relative(this.basePath, lazyRoute.replace(/(\.d)?\.ts$/, '.ngfactory.ts')); | ||
this._lazyRoutes[k + '.ngfactory'] = path.join(this.genDir, path.join('/', lr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the change on the line before (which LGTM), but I'm curious for why do you join /
here and what does that mean for Windows users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment! I'm thinking I should have used path.sep instead to be platform agnostic. Will update the PR shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the purpose of the join is to ensure lr cannot traverse up the directory tree and escape the $$_gendir directory. Assuming the following:
- basePath: '/project/src'
- genDir: '/project/src/$$_gendir
- lazyRoute: '/project/node_modules/package/lazy.module.ngfactory.ts'.
lr would then be '../node_modules/package/lazy.module.ngfactory.ts' and then the resulting _lazyRoutes path would end up being '/project/src/node_modules/package/lazy.module.ngfactory.ts', but the actual AOT factory file would be in '/project/src/$$_gendir/node_modules/package/lazy.module.ngfactory.ts'
1226c36
to
b5b024c
Compare
@hansl can you re-review? |
…zy loaded modules Currently, code splitting derived from routes with the loadChildren property only works if the resolved source file is a *.ts file in the source directory of your angular-cli project. If your project uses an npm package that has a route with loadChildren, the build will resolve the lazy loaded module as a *.d.ts definition file and then attempt to find an *.d.ts.ngfactory.ts file in the generated AOT directory, which does not exist. This fixes the path generation logic so the build will look for a *.ngfactory.ts file in $$_gendir/node_modules.
b5b024c
to
18ee60b
Compare
Fixed the linter issue but I couldn't reproduce the issue from e2e test case tests/build/rebuild. |
Any suggestions on what I need to do to avoid this test failure? It seems it is examining commits that it probably shouldn't. Examining 1331 commit(s) between HEAD and master |
…zy loaded modules Currently, code splitting derived from routes with the loadChildren property only works if the resolved source file is a *.ts file in the source directory of your angular-cli project. If your project uses an npm package that has a route with loadChildren, the build will resolve the lazy loaded module as a *.d.ts definition file and then attempt to find an *.d.ts.ngfactory.ts file in the generated AOT directory, which does not exist. This fixes the path generation logic so the build will look for a *.ngfactory.ts file in $$_gendir/node_modules. Closes #5594
…zy loaded modules Currently, code splitting derived from routes with the loadChildren property only works if the resolved source file is a *.ts file in the source directory of your angular-cli project. If your project uses an npm package that has a route with loadChildren, the build will resolve the lazy loaded module as a *.d.ts definition file and then attempt to find an *.d.ts.ngfactory.ts file in the generated AOT directory, which does not exist. This fixes the path generation logic so the build will look for a *.ngfactory.ts file in $$_gendir/node_modules. Closes #5594
…zy loaded modules Currently, code splitting derived from routes with the loadChildren property only works if the resolved source file is a *.ts file in the source directory of your angular-cli project. If your project uses an npm package that has a route with loadChildren, the build will resolve the lazy loaded module as a *.d.ts definition file and then attempt to find an *.d.ts.ngfactory.ts file in the generated AOT directory, which does not exist. This fixes the path generation logic so the build will look for a *.ngfactory.ts file in $$_gendir/node_modules. Closes angular#5594
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently, code splitting derived from routes with the loadChildren property only works
if the resolved source file is a *.ts file in the source directory of your angular-cli
project. If your project uses an npm package that has a route with loadChildren, the
build will resolve the lazy loaded module as a *.d.ts definition file and then attempt
to find an *.d.ts.ngfactory.ts file in the generated AOT directory, which does not exist.
This fixes the path generation logic so the build will look for a *.ngfactory.ts file
in $$_gendir/node_modules.