-
-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builds fail when using thread-loader and webpack >= 4.13.0 #1242
Comments
@caseyjhol, As noted in the ts-loader readme, you will need to set happyPackMode to true if you are using thread-loader: https://github.com/TypeStrong/ts-loader#happypackmode Your rule in webpack will be:
With this your repo builds. This config disables all error checking so you will want to configure fork-ts-checker-webpack-plugin to re-enable it. I question whether thread-loader will bring you more performance or whether its overhead will slow down the build. If you are not using transpileOnly mode with ts-loader then you cannot use thread-loader as it requires that the loaders it parallelizes are very simple with no side-effects. Using transpileOnly and fork-ts-checker-webpack-plugin you should see a nice speed boost as you are taking the error checking off the main thread. If your project is huge you could consider using project references so you pre-compile modules within your project. Before using thread-loader I would suggest you benchmark the build with and without and check that it gives you some benefit. |
Interesting. In my actual build, I already had both happyPackMode and transpileOnly set to true. I'm getting this error: Running webpack ...
94% after seal ERROR Failed to compile with 1 errors 8:17:57 PM
error in ./assets/js/react-app/App.tsx
Syntax Error: Thread Loader (Worker 0)
Cannot read property 'hooks' of undefined
@ ./assets/js/app.js 11:0-34 12:107-110 I'll see if I can create a reduced test case. |
I'm using Webpack Encore, and it was adding ts-loader for me. I was looping through the loaders and adjusting the settings only if it was ts-loader. The way I was checking was incorrect. I was checking for an exact string match ( Thanks for your help! Encore.getWebpackConfig().module.rules.forEach((rule) => {
if (rule.test.test(".ts")) {
rule.use.forEach((loader) => {
if (loader.loader.includes("ts-loader")) {
loader.options.happyPackMode = true;
loader.options.transpileOnly = true;
}
});
rule.use.unshift({
loader: "thread-loader",
options: {
workers: require("os").cpus().length - 2,
},
});
}
}); |
Similar to #1206, but since that issue has been resolved, I figured I'd open a new issue to keep the discussion separate.
Expected Behaviour
Using
thread-loader
beforets-loader
, compilation of a project should succeed.Actual Behaviour
Compilation fails with this error:
Steps to Reproduce the Problem
Use a minimal webpack configuration as follows:
Running builds with
webpack
should fail.Reproducible with the following dependencies:
Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/caseyjhol/tsloader-build-issue-with-thread-loader
The text was updated successfully, but these errors were encountered: