Typescript and nuxt memory leak with ForkTsCheckerWebpackPlugin

10.4k Views Asked by At

I am trying to use typescript with nuxt but am getting the following issue when the site reloads in dev

Issues checking service aborted - probably out of memory. Check the memoryLimit option in the ForkTsCheckerWebpackPlugin configuration. If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.

Is there anyway to increase this in nuxt config?

2

There are 2 best solutions below

0
Andrei Gătej On

I was able to find some docs that indicate a possible solution - you can use the typeCheck option in your nuxt config.

And here's the source code where the merge takes place,

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
config.plugins!.push(new ForkTsCheckerWebpackPlugin(Object.assign({
  typescript: {
    configFile: path.resolve(this.options.rootDir!, 'tsconfig.json'),
    extensions: {
      vue: true
    }
  },
  logger: consola.withScope('nuxt:typescript')
} as TsCheckerOptions, options.typeCheck)))

so providing the typeCheck option as an object with properties known to the ForkTsCheckerWebpackPlugin should do the job:

// The nuxt config file
{
 /* ... */
  typescript: {
   typeCheck: {
    memoryLimit: 2048,
   }
  }
 /* ... */
}
1
sgedye On

// In your webpack.config.js file

const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");

module.exports = {
  ...,
  plugins: [
    ...,
    new ForkTsCheckerWebpackPlugin({
      typescript: {
        memoryLimit: 4096,
      },
    }),
  ],
}