I'm trying to upgrade to webpack 5, but I'm now getting a type error when trying to use the TsconfigPathsPlugin. (npm tsconfig-paths-webpack-plugin).
I need this plugin so that I can resolve the alias paths in my files. You can see a usage example here: https://betterprogramming.pub/the-right-usage-of-aliases-in-webpack-typescript-4418327f47fa
resolve: {
extensions: [...],
// resolve aliases from tsconfig.server.json
plugins: [
new TsconfigPathsPlugin({ // type error here
configFile: './tsconfig.server.json',
}),
],
alias: {...},
},
I get the following error:
Type 'TsconfigPathsPlugin' is not assignable to type '"..." | ResolvePluginInstance'.
Type 'TsconfigPathsPlugin' is not assignable to type 'ResolvePluginInstance'.
Types of property 'apply' are incompatible.
I have the feeling that this isn't a widespread issue as I can't see any mention of it in other places, but I would have thought that I'd be able to find at least someone that has come across the same problem.
'...'
somewhere in your configuration. – Azimuth"..."
is a valid option (type) to pass intoplugins
now in webpack 5, that is you could sayplugins: [ "...", new CssMinimizer(), ]
and this will include terser plugin whereas it used to overwrite it and you had to manually add it back in before'. So that error is sayingTsconfigPathsPlugin is not assignable to "..."
, not that I'm trying to use"..."
anywhere. – Ducknode_modules
, and maybe try creating a freshpackage-lock.json
. – AzimuthBundleAnalyzerPlugin
– Phalan(new TsconfigPathsPlugin({ // type error here configFile: './tsconfig.server.json', }) as unknown) as ResolvePluginInstance.
This did the trick for me. It's due to some unfinished types of the plugins – Phalan