8

I have the following rule in my webpack config:

       {
            test: /(\.tsx?)$/,
            use: [{
                loader: 'thread-loader'
            },
            {
                loader: 'ts-loader',
                options: {
                    transpileOnly: true,
                    appendTsSuffixTo: [/\.vue$/]
                }
            }]
        }

This results in:

ERROR in ./plugins/axios.ts
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 9)
Cannot read property 'errors' of undefined

It works fine when I remove the thread-loader.

Chris
  • 13,100
  • 23
  • 79
  • 162

1 Answers1

14

According to the example on github, you need to set the happyPackMode option on the ts-loader to true. I've came across with the same problem you described, and this made it work.

pushrbx
  • 312
  • 2
  • 9
  • 2
    But this stops throwing syntactic typescript errors to webpack, which is problematic – blisher Dec 03 '19 at 11:12
  • 1
    @blisher The fix is mentioned in HappyPack's [Documentation](https://github.com/TypeStrong/ts-loader#happypackmode). Note, however, that both HappyPack and ThreadLoader are deprecated in Webpack 5. – Stevethemacguy Aug 26 '21 at 02:42