Description
I've recently attempted to update one of my projects to webpack
v4, in addition to a couple of other updates. One of them broke my build with a curious error:
TypeError: readFileFn is not a function
After debugging things a bit, I figured out that one of the plugins I'm using attempts to access compiler.inputFileSystem._readFile
, which is present in the apply
phase, but was no longer existing when it came to emit
.
Playing a bit with the configuration, I was able to point out that this modification was made by the AngularCompilerPlugin
, which is part of @ngtools/webpack
. More precisely, it happens due to the decoration
performed by it:
angular-cli/packages/@ngtools/webpack/src/angular_compiler_plugin.ts
Lines 549 to 553 in d1b22d0
After this,
compiler.inputFileSystem._readFile
is no longer available. Thus, the decoration breaks the API available on compiler.inputFIleSystem
and makes plugins relying on it fail.
Versions
- No
ng
version, since it's a custom setup - Node 8.10.0
- NPM 5.7.1
- Yarn 1.5.1
- @ngtools/webpack 1.10.2
- Ubuntu 16.04
Repro steps
- Clone repository: https://github.com/DorianGrey/ng-webpack-template/tree/webpack-4
yarn
yarn build
Observed behavior
The last command will fail with an error like this.
TypeError: readFileFn is not a function
(See the build output here: https://travis-ci.org/DorianGrey/ng-webpack-template/jobs/357274315)
Desired behavior
Decoration or encapsulation of any of these internal parts of webpack
should not break their available API, regardless of potentially intended privacy (suppose the leading _
might tend in this direction).
Mention any other details that might be useful (optional)
I've also tried the latest beta version of the @ngtools/webpack
plugin and made a cross-check against webpack
v3, but neither made any difference.
Not sure if this is of any help or use, but the affected plugin in my case is the workbox-webpack-plugin
, which changed it's implementation and behavior in v3.
Suppose that's why this problem did not raise before.