Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack thread-loader with ts-loader

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.

like image 892
Chris Avatar asked Sep 29 '18 17:09

Chris


People also ask

Does TS-loader use Tsconfig?

First, for ts-loader to produce sourcemaps, you will need to set the tsconfig.

Does webpack use TSC?

Webpack compiles a TypeScript file using ts-loader package which asks TSC to do the compilation. The result of this compilation will be JavaScript code that will be used to make a bundle.

What is thread loader?

Disclaimer: thread-loader is a third-party package maintained by community members, it potentially does not have the same support, security policy or license as webpack, and it is not maintained by webpack. Runs the following loaders in a worker pool.

What is source map loader?

source-map-loader allows webpack to maintain source map data continuity across libraries so ease of debugging is preserved. The source-map-loader will extract from any JavaScript file, including those in the node_modules directory.


1 Answers

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.

like image 116
pushrbx Avatar answered Oct 18 '22 05:10

pushrbx