-
Notifications
You must be signed in to change notification settings - Fork 492
Migrate ts-loader to awesome-typescript-loader #74
Conversation
Nah it seems it will be harder than I expected. Any ideas why this is failing? |
I think one of the big wins using at-loader is its integration with Babel which is not part of this commit. Do you think that is something that should be added? Maybe it can be opt-in? |
Precisely. It should, but I haven't figured out how to do it yet. Any suggestions? |
This is extracted from my previously ejected CRA (pre-webpack2)
I basically just copy and pasted from their docs. Havent tried with latest CRA and Webpack2 but imagine its not much different. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
I am pretty much shooting in the dark so any help with this would be most welcome. |
I see this is still failing. I will try to check out your branch if I have a chance today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the benefit of awesome-typescript-loader ?
Read their readme. I think it's worth to try to fight it through. |
I made some progress but it is still failing with error:
|
@Havret what happens if you remove rootDir from tsconfig entirely? I had a similar problem in a non CRA project and simply removed that and then it worked as expected. |
I'm not totally sure that removing the |
Hi, if you proceed with this, please measure some numbers (also with |
You should be able to solve that error by adding |
@wmonk @Havret I can confirm that adding |
Is awesome-typescript-loader really the way to go? I just read the notes about the poor performance for incremental builds with atl at fork-ts-checker-webpack-plugin and this makes me very nervous. The caching of atl is definitly a benefit, but I think it makes just the initial start faster. What really counts is the incremental build speed and that should be as fast as possible. Btw we could also introduce caching with webpack's cache-loader, especially when they provide a option for custom cache key generation. I already tried the transpileOnly option of ts-loader with fork-ts-checker-webpack-plugin and the results are pretty promising. The only issue at the moment is that the type checking reporting isn't part of the webpack build workflow, so CRA's great error reporting in the terminal and browser will not work without any adaptations. However, this is solvable and we can workaround this. |
@Havret @wmonk do you know if there are any benchmarks we can run before we merge this in? @plievone's and then @zinserjan's comments regarding slow watch speeds is getting me nervous... though as someone who has contributed nothing to this project yet I won't complain with whatever decision is collectively arrived at :) Just wanted to check all dissenting views had been engaged with as Plievone's seems to be have slipped through the net. ** edit ** Apologies, I also appreciate how annoying this might be after all the work you've generously put into this open source project. |
I personally like this approach, as my editor provides the errors for me. Maybe we could make this a configurable option with an env var? -- Can someone describe the non speed related benefits of using ATL? Is it just to allow babel plugins for language features (or addons, e.g. Relay) that TS doesn't support natively? I'm aware this has been open for a long time now, sorry for not getting on it sooner! I want to make sure this is right decision before we move to it. |
@wmonk
In my personal opinion using fork-ts-checker-webpack-plugin with CRA is basically the same as disabling type checking completely, because you might never see the results. But in general the performance gain of this plugin approach is pretty good. Just using the IDE (IntelliJ 2017) in my case isn't a option, cause type errors that affects multiple files are shown too late. I want the feedback immediately and fix those bugs when they appear and not when I'm already doing something else... Another issue I noticed that it does not work with CSS-Modules (which is not part of CRA, but I configured it on my fork). I tried to fork the plugin and fix my issues, but fixing was more complicated than I initially thought and it would result in a complete rewrite. That's why I've started to build my own plugin. The approach is similar but the implementation is different. My incremental compile times with this plugin are nearly identical as without the plugin. But I have just a small project to test with, it would be interesting how this scales on a large project. Anyway I'll try to finish it over the weekend. |
Being able to use |
The first issue seems to be caused by the change of version 0.2 which remove the option to forcefully block the emit. Maybe it's possible to convince the author(s) to reconsider this change, since it's not only a problem with CRA, but with webpack plugins like friendly-errors as well. Alternatively - that's my current workaround in a playground project - it's possible to use a custom logger which defers logging while webpack compilation is active. That wouldn't help with the second issue, however. I have recently changed a production project (angular) with ~1000 typescript modules to use
These numbers include the usage of TSLint as well - the plugin can handle it along with the type-checking, and share program instances, which especially helps with linter rules that also require type-checking. Regarding the babel issue: I haven't recognized any problems or reasonable performance regressions in any project with using a proper chain of ts- and babel-loader instead of ATL, though I've only used this in projects with < 200 modules. |
One of the advantages of using at-loader is to be able to fight with microsoft/TypeScript#15088 those type of issues |
FYI: Create-React-App + TypeScript + Ant-Design (without Eject) - how to change app from ts-loader to awesome-typescript-loader without eject. Happy coding! |
Hi everyone - would like to get this merged or closed. What is the final consensus? |
Assuming the two loaders are able to join forces (s-panferov/awesome-typescript-loader#266), is it worth moving to awesome-typescript-loader if the beneficial features are being ported to ts-loader and ts-loader will become the basis for the combined library? |
@corydeppen thanks for this, I hadn't seen it before. It doesn't look like there has been any movement there for a while though. Do you know of an update? |
Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74
Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
@wmonk i suggest closing this |
let it be |
Resolves #60.
I think it should do the trick, but please check if I didn't miss something. I tried this on my own project and it seems to work just fine.