-
-
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
Try to move LanguageService to separate process #830
Comments
Feel free to spike this and send a PR to collaborate on. Could be interesting! |
Doesn’t this work with thread-loader? |
@felixfbecker also my original thought; there is a distinction - see discussion in linked thread. This is the relevant quote from @timocov:
|
If I understand correctly how |
thread-loader is not the same as fork-ts-checker-webpack-plugin: We use thread-loader with ts-loader together. @timocov could you clarify what part of ts-loader still blocks the main process with that setup? |
@felixfbecker I cannot tell you for sure, but compilation TypeScript is not async and every time when you request to compile some file it blocks the process until compilation is finished. In our case we have the following situation:
|
Yes, but isn't the point of Have you tried using |
Hm, good point - I didn't think about it.
I need to check it. Quite possible that it can help here. 👍 |
I just have played with
|
No, we don't have these errors. Here are the options we use for loader: 'ts-loader',
options: {
compilerOptions: {
target: 'es6',
module: 'esnext',
noEmit: false,
},
experimentalWatchApi: true,
happyPackMode: true, // typecheck in fork-ts-checker-webpack-plugin for build perf
}, |
We use |
Using Would recommend to have some custom code for configuring how many works use, interesting parts of the config... module: {
rules: [
{
...commonRule,
test: /\.tsx?$/,
use: [
tsWorkers > 0 && {
loader: 'thread-loader',
options: tsWorkerPool,
},
{
loader: 'babel-loader',
options: babelOptions({ hotMode, isDevelopmentMode }),
},
{
loader: 'ts-loader',
options: {
happyPackMode: tsWorkers > 0,
transpileOnly: tsTranspileOnly,
compilerOptions: {
sourceMap,
},
},
},
].filter(Boolean),
},
{
...commonRule,
test: /\.jsx?$/,
use: [
jsWorkers > 0 && {
loader: 'thread-loader',
options: jsWorkerPool,
},
{
loader: 'babel-loader',
options: babelOptions({ hotMode, isDevelopmentMode }),
},
].filter(Boolean),
},
// ...
]
},
// fork-ts-checker-webpack-plugin in plugins
plugins: [
...(tsTranspileOnly && forkTsWorkers > 0
? [
new ForkTsCheckerWebpackPlugin({
async: true,
watch: [srcPath],
workers: forkTsWorkers,
checkSyntacticErrors: tsWorkers > 0,
}),
]
: []),
] Workers pools const commonModulesToWarmup = [
'babel-loader',
'babel-preset-env',
'babel-preset-react',
'babel-plugin-syntax-dynamic-import',
'babel-plugin-syntax-object-rest-spread',
'babel-plugin-transform-object-rest-spread',
]
const tsWorkerPool = {
workers: tsWorkers,
poolTimeout: watchMode || devServer ? Infinity : 2000,
}
if (tsWorkers > 0) {
threadLoader.warmup(tsWorkerPool, [...commonModulesToWarmup, 'ts-loader'])
}
const jsWorkerPool = {
workers: jsWorkers,
poolTimeout: watchMode || devServer ? Infinity : 2000,
}
if (jsWorkers > 0) {
threadLoader.warmup(jsWorkerPool, commonModulesToWarmup)
} Running it with configuration of "tsWorkers":1,"jsWorkers":2,"forkTsWorkers":1 no blocking just building as mad 😄Plus thanks to |
Can this be closed then? I don't think ts-loader should include this functionality if it can be achieved by composition of other loaders |
@felixfbecker Exactly 👍 There is no need for this logic in |
Actually there is one difference between using |
Yes that is true, just wondering in scenario that you use |
In some cases you just cannot use it - #825 (comment) |
Hmm what exactly this means ?
But yeah, then it make sens to run it in separate process... When running build without thread-loader & fork-ts-checker-webpack-plugin also gets blocked for few seconds |
Could you please share a little bit about your project: how many files ts/js do you have, cloc value?
Instead of declaring constants or importing declare const enum KeyboardEventKeyCode {
Backspace = 8,
Tab = 9,
Enter = 13,
Shift = 16,
Control = 17,
Alt = 18,
CapsLock = 20,
Escape = 27,
Space = 32,
PageUp = 33,
PageDown = 34,
End = 35,
} (this file is added to build the same as typing from And use it like this: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
I noticed that
ts-loader
runs TypeScript synchronously in the main process what causes blocking webpack's main process and webpack stops doing other stuff with other files until TypeScript finish compiling (I guess it is applicable for projects with mixed typescript and javascript files).It is possible that we can move LanguageService to other process and handle compilation there while webpack doing other work in the main process. In this case, I believe, we will compile in other process while webpack doing own work in the main process without blocking (but yeah, at some time we'll wait until the compilation is finished because there are no other non-typescript files to process by webpack).
(moved from #825 (comment))
The text was updated successfully, but these errors were encountered: