Skip to content
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

Poor Performance, build times >30 seconds #112

Closed
tutman96 opened this issue Aug 13, 2018 · 12 comments
Closed

Poor Performance, build times >30 seconds #112

tutman96 opened this issue Aug 13, 2018 · 12 comments
Labels
stale There is no activity for a long time.

Comments

@tutman96
Copy link

I am currently using this package with a project that has about 75 components. Each of these components can take over 500ms to parse. This causes our compile times (and live-reload times) to be close to 40 seconds between each change.

I have noticed that the parser creates a new Typescript program (ts.createProgram) a new Parser, which take about 400ms and 150ms each. This of course gets ran once for every component.

I have prototyped out a solution that caches the Typescript program and Parser based on the file path and can shave off almost 35 seconds from our build time. This of course is not a production solution, and there are probably plenty of cases where this wouldn't work.

I have also prototyped a version where there is one instance of the Typescript program and Parser and it gets replaced whenever there is a new filepath to compile. However I feel that this solution is less robust and probably has many more cases for regression.

I just wanted to open a conversation to the experts to see if there is an easy solution to this problem and if anybody else has run into similar issues. Thanks for all the great work with styleguidist. It makes the development of our React component library way easier and has forced our team to write documentation :D, which is a win-win.

@strothj
Copy link
Contributor

strothj commented Aug 21, 2018

I was thinking that it might be possible to use a language service the way ts-loader does.

Looking over the code from ts-loader, I think it might be possible to re-use parts of its implementation:
https://github.com/TypeStrong/ts-loader/blob/master/src/servicesHost.ts

@wkillerud
Copy link

wkillerud commented Apr 4, 2019

I'm seeing this performance issue in my react-styleguidist project as well. Parsing props takes up the largest portion of the build time by far, with total build time ~300 seconds.

My environment is up-to-date Windows 10, using Node 10.15.3 LTS and the latest Git Bash.

The work done by denieler on strothj/react-docgen-typescript-loader#40 seemed promising, so I tried porting it over for use in styleguide.config.js. My build time ended up at ~90 seconds, so a significant improvement.

I've put the relevant code up as a Gist. Since it's mostly code from strothj/react-docgen-typescript-loader
I 've included their license and copyright.

@strothj
Copy link
Contributor

strothj commented Apr 4, 2019

It’d be awesome to get that feature moved here so everyone can benefit. I’m unfortunately completely swamped at the moment but if the functionality is moved here we can make the adjustment at the loader side.

@clintandrewhall
Copy link

I'm quite interested in this issue, as it has bogged down our Storybook experimentation quite a bit.

See: storybookjs/storybook#6430

@strothj
Copy link
Contributor

strothj commented Apr 5, 2019

I'm quite interested in this issue, as it has bogged down our Storybook experimentation quite a bit.

See: storybooks/storybook#6430

I've replied on your issue, hopefully that improves things a bit. Right now the TypeScript instance is being reused in the loader. If we move that code from the loader to this parser here, the loader performance will stay the same but Styleguidest will also benefit.

@clintandrewhall
Copy link

FYI: It definitely improved things: it builds in ~9s now:

Screen Shot 2019-04-05 at 8 40 56 AM

@clintandrewhall
Copy link

@strothj Things appear to have regressed. This is with both 3.1.1 and 3.2.0.

Screen Shot 2019-09-04 at 4 19 02 PM

@The-Code-Monkey
Copy link

any update on this issue?

@ammmze
Copy link

ammmze commented May 6, 2020

I've got a project that was taking almost 3 minutes to compile. This brought it down to ~10s.
Until we get something built-in to this project, I threw together a package based on the gist shared here.

@hipstersmoothie
Copy link
Contributor

For anyone who is interested I wrote a plugin for webpack that does all the doc generation at once at the end of the build.

https://github.com/hipstersmoothie/react-docgen-typescript-plugin

This dramatically improved our start times over the loader.

For styleguidist users the gist shared above is probably the best way to go

@github-actions
Copy link

github-actions bot commented Oct 9, 2021

There was no activity for a long time. Closing this issue as obsolete. In case it is still valid, please, open a new one.

@github-actions github-actions bot added the stale There is no activity for a long time. label Oct 9, 2021
@github-actions
Copy link

Closing this issue as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale There is no activity for a long time.
Projects
None yet
Development

No branches or pull requests

7 participants