-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
ts-loader config with transpileOnly: true and experimentalWatchApi: true #1124
Comments
|
@johnnyreilly thank for your answer. |
I believe it is this |
Looking through the ts-loader code I can see that the experimentalWatchApi option is used to select the watch api of TypeScript: Line 321 in cb487e4
However, if transpileOnly is true the code above is never executed: Line 292 in cb487e4
So it seems to me that transpileOnly and experimentalWatchApi are mutually exclusive. This also seems to make sense as, if I understand correctly, experimentalWatchApi should speed up compile time by only transpiling files which have been changed. But transpileOnly speeds up even more by only transpiling the single file it is given. So by specifying transpileOnly you are directing the compiler to transpile only one file; watching for other changes as well would make no sense. This comment from @sheetalkamat seems to confirm that with transpileOnly there will be no tsbuild info file, which I assume means the new watch api is not used. So it is unfortunate that the webpack documentation indicates that you can use both together: https://webpack.js.org/guides/build-performance/#typescript-loader Searching on Github I see many people have copied this configuration hoping that it will give a speed boost. Some are then trying experimentalWatchApi on its own and experiencing problems. From several issues that have been raised it seems that experimentalWatchApi is not yet ready for production. If my understanding is correct I'll submit a PR to update the webpack documentation to show that transpileOnly+ForkTsCheckerWebpackPlugin is the current way to boost speed and remove the reference to experimentalWatchApi. |
Gosh I didn't know that was the case!
Yes, I'd always intended it to become the default way to use If you were looking for something to get your teeth into @appzuka, then it's worth considering having a go at seeing if you could get the Obviously, you don't have to do this at all! But if you were after a challenge then this could be that. 😎 |
Is there a repo to show how experimentalWatchApi should be used? I understand how --build and --incremental work with tsc, but I'm struggling to see how this works with ts-loader. When you run tsc --build you get all the ts files transpiled to js files in the outDir. When you run again with --incremental tsc is able to only re-build files which need to be rebuilt because it knows which files have changed by looking in .tsbuildinfo. But under webpack, the intermediate js files are not saved. ts-loader transpiles them to js files and tells webpack to add them to the bundle. Webpack produces one or more bundles, but it does not save the js files. So when you run webpack again it still needs to re-transpile all ts files, even if .tsbuildinfo indicates the ts files have not changed. I feel I must be missing something and will continue to dig into the code. I tried it with watch mode using webpack-dev-server and it did work, with some caveats. The first compilation worked but when I changed a ts file for the first time it did not update the bundle. It did work on subsequent updates. I have a minimal repo and am investigating why this happens. If I can understand how this should work and get it reliable I'll submit a PR and some documentation. |
There isn't - but really just imagine taking the vanilla example and switching on that option. It should, theoretically, work exactly the same as with it off but just be faster in watch mode. https://github.com/TypeStrong/ts-loader/tree/master/examples/vanilla You could also take a look at ts-loader's sister project: https://github.com/TypeStrong/fork-ts-checker-webpack-plugin Which I believe uses the same API internally (not certain though) |
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 read the article here: https://webpack.js.org/guides/build-performance/#typescript-loader
and I decided to check performance with
transpileOnly: true
andexperimentalWatchApi: true
options.When I use these options together I don't see that the incremental build TS feature works, because
tsconfig.tsbuildinfo
file is not generated and build time has the same time like only withtranspileOnly
So my questions are:
tsconfig.tsbuildinfo
is not generated whentranspileOnly: true
andexperimentalWatchApi: true
?Steps to Reproduce the Problem
I used this project https://github.com/TypeStrong/ts-loader/tree/master/examples/fork-ts-checker-webpack-plugin
the last version of the packages:
Case 1: experimentalWatchApi: true
npm run build
Actual Behaviour
tsconfig.tsbuildinfo is generated
Expected Behaviour
tsconfig.tsbuildinfo is generated
Case 2: transpileOnly: true and experimentalWatchApi: true
npm run build
Actual Behaviour
tsconfig.tsbuildinfo is not generated
Expected Behaviour
tsconfig.tsbuildinfo is generated
The text was updated successfully, but these errors were encountered: