Skip to content

Builds fail when using thread-loader #1206

@valerio

Description

@valerio

Expected Behaviour

Using thread-loader before ts-loader, compilation of a project should succeed.

Actual Behaviour

Compilation fails with the following error:

[webpack-cli] Compilation finished
assets by status 655 bytes [cached] 1 asset
./src/app.ts 39 bytes [built] [code generated] [1 error]

ERROR in ./src/app.ts
Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Invalid value used as weak map key
    at PoolWorker.fromErrorObj (/Users/valeriopipolo/repos/tsloaderleak/node_modules/thread-loader/dist/WorkerPool.js:344:12)
    at /Users/valeriopipolo/repos/tsloaderleak/node_modules/thread-loader/dist/WorkerPool.js:217:29
    at WeakMap.set (<anonymous>)
    at Object.getTypeScriptInstance (/Users/valeriopipolo/repos/tsloaderleak/node_modules/ts-loader/dist/instances.js:37:23)
    at Object.loader (/Users/valeriopipolo/repos/tsloaderleak/node_modules/ts-loader/dist/index.js:16:41)

webpack 5.3.2 compiled with 1 error in 441 ms

Steps to Reproduce the Problem

Use a minimal webpack configuration as follows:

module.exports = {
  devtool: "inline-source-map",
  entry: "./src/app.ts",
  output: {
    filename: "bundle.js",
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: ["thread-loader", "ts-loader"],
      },
    ],
  },
};

Running builds with webpack should fail.
Reproducible with the following dependencies:

    "thread-loader": "3.0.1",
    "ts-loader": "8.0.8",
    "typescript": "4.0.5",
    "webpack": "4.13.0"

Location of a Minimal Repository that Demonstrates the Issue.

https://github.com/valerio/tsloader-build-issue-with-thread-loader

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions