Closed urig-40seas closed 3 months ago
same issue, the mini re-product is :
node -v v18.15.0 yarn -v 3.6.1
{
"name": "AAAAA",
"private": true,
"scripts": {
"build:watch": "tsc --watch",
"webpack:watch": "webpack --watch"
},
"packageManager": "yarn@3.6.1",
"dependencies": {
"fork-ts-checker-webpack-plugin": "^8.0.0",
"ts-loader": "^9.4.4",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.1.6",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
}
}
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = {
mode: "development",
devtool: "inline-source-map",
entry: {
server: './src/server/0.ts',
web: './src/web/1.ts',
},
output: {
filename: './dist/[name]/[name].js',
path: path.resolve(__dirname, 'dist'),
},
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
plugins: [
// new TsconfigPathsPlugin({configFile: "./tsconfig.json"}),
new ForkTsCheckerWebpackPlugin(),
],
},
module: {
rules: [
// all files with a `.ts`, `.cts`, `.mts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.([cm]?ts|tsx)$/, loader: "ts-loader" ,
// use: [
// {
// loader: 'ts-loader',
// options: {
// transpileOnly: true
// }
// }
// ]
}
]
},
// watchOptions: {
// // for some systems, watching many files can result in a lot of CPU or memory usage
// // https://webpack.js.org/configuration/watch/#watchoptionsignored
// // don't use this pattern, if you have a monorepo with linked packages
// ignored: /node_modules/,
// },
};
You are including ForkTsCheckerWebpackPlugin in the wrong place. It needs to be outside the "resolve" property, as seen in the docs examples: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/main/examples/babel-loader/webpack.config.js
WRONG:
module.exports = {
mode: "development",
devtool: "inline-source-map",
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
plugins: [
new ForkTsCheckerWebpackPlugin(),
],
},
};
GOOD:
module.exports = {
mode: "development",
devtool: "inline-source-map",
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".ts", ".tsx", ".js"],
plugins: [],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
]
};
Thanks @AlesioSinopoli for the answer :+1:
Current behavior
I have a React application that exists within a monorepo managed by NX. I build the application using the command
npx webpack --config webpack.browser.config.js
, and I have attached mywebpack.browser.config.js
file below.The build process works smoothly, but when I tried to add
ForkTsCheckerWebpackPlugin
, the build failed with the error message:ERROR in compiler.getInfrastructureLogger is not a function.
I searched the web and found that this issue may be related to having multiple webpacks installed, but since webpack is installed by NX and is also needed for other projects, I am not sure how to proceed.Has anyone else experienced this issue? Do you have any ideas for remediation?
Environment
fork-ts-checker-webpack-plugin: 8.0.0
(btw, seems like I have several more installed) ├─┬ @nrwl/cypress@14.5.10 │ └── fork-ts-checker-webpack-plugin@7.2.13 ├─┬ @nrwl/node@14.4.3 │ └── fork-ts-checker-webpack-plugin@6.2.10 ├─┬ @nrwl/web@14.5.10 │ └── fork-ts-checker-webpack-plugin@7.2.13 └── fork-ts-checker-webpack-plugin@8.0.0
typescript: 4.7.4
os: Mac Os Ventura 13.2.1
webpack config