strothj / react-docgen-typescript-loader

Webpack loader to generate docgen information from Typescript React components.
Other
360 stars 47 forks source link

Slowness #37

Closed zoltanbedi closed 5 years ago

zoltanbedi commented 5 years ago

Hey guys,

I was wondering if using this loader is really that slow or I'm doing something wrong. So creating the docs for ~57 components takes about ~1.5 minutes. Without docgen it builds around ~10 seconds. Is there a way to only create these docs for storybook-static and not for start-storybook?

davidlacasse commented 5 years ago

Same issue here, we roughly have around 80 components and it take ~5 minutes to start. Unfortunately we haven't found any solution yet.

zoltanbedi commented 5 years ago

I've spent the other night trying to solve this. So I found out the slowness is related to https://github.com/styleguidist/react-docgen-typescript/issues/112

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.

Also there was a possible fix for that where you can pass a typescript program as a parameter but I couldn't make it work with the loader. So I've written a webpack plugin that will do the doc generation at the end of the build. It worked. Now it builds in ~17 seconds.

It is not the cleanest code but it works well. You can take a look at it and add it to your project as well. see my pr with the plugin

zoltanbedi commented 5 years ago

I'm going to close this issue because my problem is solved. 😃

strothj commented 5 years ago

Cool, thanks. I'm going to leave this open so I remember to look this over.

pedronauck commented 5 years ago

Wow, such a huge slowness reducement creating a custom program @B3zo0 👏

denieler commented 5 years ago

I think we can close this issue, right @strothj ?

strothj commented 5 years ago

Awesome work @B3zo0 and @denieler . Closing this.