We're trying to port an angular application that was built without the angular cli (uses webpack directly and a custom server) to angular 9 with cli. The upgrade to angular 9 itself worked perfectly. After we started using the angular cli, we faced several problems.
The only one remaining right now is that it seems the build is not picking up webpack's require.context
calls at all. We use this everywhere to find and register our components dynamically, and it used to work just fine before, using only the @types/webpack-env
package. But now, in vscode, there are no syntax errors, but when we try to run ng serve
, it produces the following error for each file that has require.context
:
ERROR in src/app/shared/shared.module.ts:22:29 - error TS2339: Property 'context' does not exist on type 'NodeRequire'.
const requireFile = require.context(
And the whole build fails. I'm guessing this is because of ivy in some way, but I don't know how to approach this, I looked everywhere but I didn't find a solution. I tried to install @types/webpack-env
in dependencies (instead of dev dependencies), but no luck. I'm not sure why this is happening, I thought that webpack will work normally and pick up those calls before ivy gets to work.