Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

fix(AoT): stop using require.context in Angular apps #574

Merged
merged 4 commits into from
Jun 22, 2018

Conversation

sis0k0
Copy link
Contributor

@sis0k0 sis0k0 commented Jun 19, 2018

Calling require.context for the app directory adds a ContextDependency in webpack for it. That causes every change inside the app/ directory to emit a change event for the whole directory.
There's a logic in the TypeScript compiler host (from
@ngtools/webpack)
that invalidates all files in the changed directory. The invalidation
removes all cached information for the virtual files produced by the
Angular AoT compilation (ngfactory files, etc.). Since these files are
not in the cache anymore, webpack tries to resolve them from the
filesystem and fails. The solution is to remove the ContextDependency
for the app dir, which should also make the rebuilds much faster.

fixes #566

Calling `require.context` for the app directory adds a `ContextDependency` in webpack for it. That causes every change inside the app/ directory to emit a change event for the whole directory.
There's a logic in the TypeScript compiler host (from
[@ngtools/webpack](https://github.com/angular/angular-cli/blob/master/packages/ngtools/webpack/src/compiler_host.ts#L235))
that invalidates all files in the changed directory. The invalidation
removes all cached information for the virtual files produced by the
Angular AoT compilation (ngfactory files, etc.). Since these files are
not in the cache anymore, webpack tries to resolve them from the
filesystem and fails. The solution is to remove the `ContextDependency`
for the `app` dir, which should also make the rebuilds much faster.

fixes #566
@sis0k0 sis0k0 added this to the 0.13.1 milestone Jun 19, 2018
@sis0k0 sis0k0 self-assigned this Jun 19, 2018
@sis0k0
Copy link
Contributor Author

sis0k0 commented Jun 20, 2018

test

@vchimev vchimev self-requested a review June 22, 2018 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no such file or directory, stat app-routing.module.ngfactory.js
3 participants