I am trying to run fork-ts-checker-webpack-plugin with webpack v5, and am getting errors originating from the hooks/pluginHooks.ts file. Looking at that file and the project's package.json file, I see that the types are those of webpack v4, and that @types/webpack is indeed a dev dependency.
Does the plugin support webpack v5? If so, I believe the types need to be updated (and am willing to open a PR with the needed changes).
Note that updating the types to support webpack v5 will probably break compatibility with webpack v4. From what I've seen with other plugins, it's an either-or situation...
If the plugin already supports webpack v5 in theory, no functional changes will need to be made. If it isn't, well that's a whole different story, and this ticket is irrelevant.
Assuming the plugin already supports webpack v5, and from what I've seen, only changes required are using webpack v5 as a dev dependency (instead of @types/webpack of v4), and updating webpack types used throughout this repository.
I think we should support both webpack 4 in 5 in terms of typings - maybe we should just copy-paste required typings to support both...
Or maybe it doesn't make sense - the maintenance cost will be too high... :)
Webpack migrated to Typescript in v5, so there won't be a @types/webpack v5.
I can try updating the types used in this repository to v5, if you want. Not sure how to support both v4 and v5 though.
Start trying to update, and encountered a few issues.
A few of the types defined in this repository are copies or extensions of internal types defined in webpack. For example, the CompilerWithWatchFileSystem interface incorrectly extends webpack.Compiler, as the watchFileSystem field on the Compiler cannot be undefined, and the arguments to that field's watch method do not match those of the base interface.
Trying to fix that, I found that the WatcherV4 interface which can be returned by the watch method does not match webpack's watcher, missing the getFileTimeInfoEntries and getContextTimeInfoEntries methods (they are defined on the WatcherV5 interface).
Additionally, webpack v5 uses tapable v2, which itself contains a lot of changes - shipping with their own types, for example, and some changes to some interfaces.
I tried upgrading that dependency as well, but ran into more issues, which I'm not sure if are related to webpack or tapable - in the createForkTsCheckerWebpackPluginHooks function in the pluginHooks.ts file, the start and error hooks throw errors when running tsc, saying that the argument passed to the constructor must have length of 1, and the issues hook expects to receive only 1-2 type arguments, instead of the received 3.
The IssueWebpackError class is not assignable to the WebpackError class, missing a few properties like chunk, loc and details.
Even after all of these will be fixed, there still remain a few Typescript errors that will need to be fixed...
Any idea about this issue?
Is there any way I can help?
I am willing to work on a PR for this, but from what I've seen it will mean dropping support for webpack < 5. I would also appreciate any help with the issues I raised in the previous comment, specifically regarding tapable.
This seems like quite the challenging task, and can involve more than its fair share of rewriting code, and I'm not sure I'm in a position to do that...
Got problem when using ftcwp in webpack v5:
node_modules/fork-ts-checker-webpack-plugin/lib/ForkTsCheckerWebpackPlugin.d.ts:10:54 - error TS2724: 'exports' has no exported member named 'compilation'. Did you mean 'Compilation'?
Any idea for this now?
Maybe just mentioning the solution in README is fine.
I got back around to this issue, and am playing around with the source code, to see if I can get it to work.
So far so good, managed to get it to compile with webpack v5, and am running tests now.
If everything goes well, I'll open a PR soon.
EDIT - PR opened - #556
Most helpful comment
I got back around to this issue, and am playing around with the source code, to see if I can get it to work.
So far so good, managed to get it to compile with webpack v5, and am running tests now.
If everything goes well, I'll open a PR soon.
EDIT - PR opened - #556