-
-
Notifications
You must be signed in to change notification settings - Fork 27k
yarn tsc && react-scripts build
v3 takes 1 hour to complete
#7003
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
Comments
yarn tsc && react-scripts build
v3 takes 1 hour to complete
How long it took without TS? Both How long it took to finish just |
We had a similar issue as we are using custom create-react-app fork with enabled tslint. Looks like project grows to the size, where Maybe @johnnyreilly could help us with this as message "Files successfully emitted, waiting for typecheck results..." means that create-react-app is waiting for result from For your information, we are currently not listening to |
I'd be interested to know how I've never encountered a build that performs that badly before. I'm also curious that this script is first running tsc and then running react-scripts: Can't guarantee I'll be able to help more than this but these are my quick observations |
I have same issue. Local build took about 1 minute avg. this was after node reinstallation (removed all cache and node js files). |
Random thought: are you building in the root of your docker container? I've an idea that's problematic for reasons that escape me. Something was reported in ts-loader (I don't think it was ts-loader specific). Read details here: TypeStrong/ts-loader#758 (comment) |
Nope, working in subdirectory. Using this dockerfile.
|
running tsc doesn't seem to cause an issue (completes in ~ 1min) I also tried with typescript 3.4.1 and 3.4.5 all with the same issue. I found some posts suggesting I eject and use Fork TS Checker Webpack plugin, but I would much rather be stuck with hour long deployments than an ejected CRA. |
We already use |
It looks like when there is |
I've resolved the issue however its hard to pinpoint the exact cause; seems there were multiple side effects happening.
material-ui/material-ui-pickers is deprecated for @material-ui & @material-ui/pickers however there seems to be a conflict with @material-ui/core and style themes don't render properly when using withStyles(); unfortunately I'm stuck with a project that heavily uses these HOC's. I also added a condition to the tsconfig.json to exclude all .js & .jsx files in my project which could have been part of the reason build times were taking an hour. { There is still the issue of my CPU ( i7 ) running at 100%, node consumes all available resources; when I close apps node increases it's consumption. There is clearly a leak and I'm wondering if it's package related or a hardware failure. My cloud deployments are down to 3min now :) |
Finally resolved the CPU issue but now seems to have slowed down the typechecking, getting the message "Files successfully emitted, waiting for typecheck results..." in my terminal. Docker build times are back up to ~50min @types/styled-components is a conflicting package (newer versions break the docker build) "dependencies": { |
Re: styled components it sounds like TypeScript 3.5 will improve the situation: https://devblogs.microsoft.com/typescript/announcing-typescript-3-5-rc/ |
thanks @johnnyreilly I just installed 3.5-rc and it resolved the build times and the typechecking. I am still getting 100% CPU usage when connected to AC (HP Elite Book i7) |
Glad things are improving! I wonder if this issue might help you with the CPU usage problem: microsoft/TypeScript#31048 See also: #6792 (comment) |
I ran into a similar issue on Windows when migrating from CRA With every top level import like This does not happen if I disable async mode for
I can confirm that setting |
@InvictusMB thanks to your post, I was able to come up with a combined solution that appears to have massively improved my start up times (typically took 1-2 minutes, now it's ~15 seconds) as well as my continuous build speeds (used to be 3-5 seconds, now 2). After reading your post and how Material UI's official site recommend path imports in development environments, I switched all my named imports to path imports and it seems to have done the trick!
However, before switching them all out I realised this would quickly become cumbersome, considering I will have to do anywhere between 3-8 MUI path imports in each of my React component. So instead, I created an index file at E.g. // index.ts
// Components
export { default as Grid } from '@material-ui/core/Grid';
export { default as Button } from '@material-ui/core/Button';
export { default as FormControl } from '@material-ui/core/FormControl';
export { default as InputLabel } from '@material-ui/core/InputLabel';
...etc.
// Styles
export { default as createStyles } from '@material-ui/core/styles/createStyles';
export { default as makeStyles } from '@material-ui/core/styles/makeStyles';
// Icons
export { default as CalendarIcon } from '@material-ui/icons/CalendarTodayOutlined';
export { default as MenuIcon } from '@material-ui/icons/Menu';
export { default as LockOutlinedIcon } from '@material-ui/icons/LockOutlined'; |
@Ravnurin, you are welcome. I prefer namespace imports over named imports mainly because further down in the code I want to distinguish where a particular component is coming from without scrolling up and parsing 20+ imports over and over again. Having And I'm not going to give that up to compiler deficiencies. |
@Ravnurin Did you consider to report this "import workaround" as a bug to TypeScript team? I know that imports could have a side effects and changing the imports could theoretically affect the code in certain cases (which almost everyone consider as unwanted and unexpected behaviour), but it is probably not an issue for static type check. So, maybe they can help us with this 😉 |
@deftomat |
With Babel 7 out suppporting Typescript would there be a push to move from tsc to that? I'm facing large build times on docker and a little locally. Whats the best way to overrride the |
@jamesg1 So, Babel is something like CRA is using both to "simulate" the |
Cheers for the info, the reason i ask is I'm trying to make docker builds faster for an app I'm working on which is CRA v3 with typescript. I'm wondering if its due to the material imports above which is extending the build/compile time, it takes 3 or so minutes to compile the app with |
Unfortunately, I think that this still requires a little bit of investigation. Looks like we still don't know for 100% if it is caused by TypeScript itself or by |
Not using material-ui, but my builds also take long (around 3-5 min) inside docker. Using typescript 3.5.2 with CRA 3.0.1 Is there some command to run to check which packages are taking long to transpile or type check? PS. 90% of my actual code is still in JS and only around 5 files in TS at the moment. EDIT: On codeship it completely fails (only sometimes) when running out of memory.
Running
|
This seems to be an error from v2 already. @ianschmitz care to take a look at this? PS. got |
InvictusMB's answer (#7003 (comment)) was the fix for me. |
…e testing) We're trying to solve hanging builds, see discussions here: * facebook#7003 (comment) * TypeStrong/fork-ts-checker-webpack-plugin#256
|
I think this issue can present if you have your project in the root. Try moving it down a directory and see if that helps |
Interesting -- I'm running everything in |
I'm still having this issue. Any ideas on how I can fix this? |
My production build is taking upward of 15 minutes. I am using the typescript template but other than that no changes have been made to the build process. Type checking also takes several minutes with TS3.8 |
I thought it was fixed, but ended up still having issues with long builds on other computers. I gave up and migrated from a base config of react-boilerplate-ts. |
Is anyone working on this? This is still a huge issue for us. |
I have this problem, my project is fairly big so unless I add When it builds, it takes about 21 minutes. We've built it with an old manually configured webpack setup and it takes 5 mins, so I'm guessing it's related to Typescript |
@lukas1994 I just tried the new snowpack typescript react template and it handles compilation of TS much faster leveraging ESM imports. It's backwards compatible with CRA and Typescript compatible out of the box, might be worth a try to help with your build performance issues. https://www.snowpack.dev/#what-is-snowpack%3F |
@jamesg1 Does Snowpack work correctly with old CommonJS packages? Because if yes, then it sound like a way to go. At least for a development. |
I've been using their webpack bundler recently and find it great. The config is much more flexible than CRA yet keeps the simplicity similar to CRA. |
Our react application is in initial stages and at most we have added 5 components with libs like chakra-ui and styled-components Solutions tried so far with respect to fork-ts-checker plugin, no difference in build time. Its still 1.5 hours:
Alternatively I went right into node_modules and removed spliced fork-ts-checker from the plugins and the build was done in 10 seconds. Digging more and found out that in var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); The problem is it always halts / pauses indefinitely (sort of) after processing few files. |
My issue was resolved after I bumped my typescript version from 3.9.7 to 4.0.0-beta. Build time with 3.9.7 eventually got to 4 hours. And it failed after 4 hours of running, pointing to this error: |
@anit my issue didn't resolved after switching to typescript 4.0.0-beta. I am stuck . what should i do ? can anyone help me ?? |
For anyone looking for a workaround - @anit 's response helped me "solve" this issue with Local builds went from over 10mins to 40 seconds. Provided is a patch file to use with |
I don't think react-scripts team help anymore. I am facing similar issue although i am not using typescript. My prod build takes more than 30 mins. |
Is an issue for me too. Prod build takes 10 mins. How can I debug it at least? |
@mankutila My project still taking more than 30 mins during production build and this team is no useful at all. |
My build is also taking 30+ min, and i've tried a lot of things to improve and could not get a single second better What i've tried: Changing imports from material-ui (which is heavy) removing some librarys and other things and none had any positive impact |
Lo mismo por acá :( |
even specifying the max--old usafe for build does not effect the performance at all ,, is there any other solution ?? |
Ubuntu 20.04 LTS, running on a VPS, 1GB RAM. Regular user, with sudo privileges. I am certain that having more RAM would make it faster, but it kind of makes no sense to take so long, because I have 2GB swap memory. Also, it would be GREAT if there was any progress bar or progress percentage indicator. Would be really really nice. Like, really. Show us where the loading is hanging... I need to run this command before
|
Is this a bug report?
Yes,
The production build of a TypeScript project requires almost an hour to complete.
I have tried many different version combinations all with the same result; either my system crashes or I get a very slow build process.
yarn start takes about 5 min and my production build takes almost 1 hour; it's quite consistent.
Currently on the following versions.
"@types/styled-components": "4.1.10",
"react-scripts": "3.0.0",
"typescript": "3.3.4000",
Did you try recovering your dependencies?
I have deleted these files numerous times and tried a few of the typescript-dev versions as well as the styled-component types.
I am using Yarn
Version 1.15.2
Which terms did you search for in User Guide?
script react-scripts tsc build slow
typescript cra creating optimized production build takes an hour
Environment
Issues are consistent in both environments.
npx: installed 91 in 18.872s
Environment Info:
System:
OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Binaries:
Node: 11.11.0 - ~/.nvm/versions/node/v11.11.0/bin/node
Yarn: 1.15.2 - /usr/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v11.11.0/bin/npm
Browsers:
Chrome: Not Found
Firefox: Not Found
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
This is a very large project with hundreds of components.
I upgraded my existing installation to the newest version of React which supports Hooks and integrated TypeScript which caused the development server to slow down on first launch; with the console displaying the following.
Files successfully emitted, waiting for typecheck results...
When I commit and merge the code, a deployment build is spun up in a Docker instance which takes almost an hour to complete.
Expected Behavior
I would expect the production build to take no more than 10 min.
The development server should also launch a bit quicker.
The text was updated successfully, but these errors were encountered: