storybookjs / builder-vite

A builder plugin to run and build Storybooks with Vite
MIT License
886 stars 109 forks source link

Fix multiple docgen runnign at the same time #521

Closed dubzzz closed 1 year ago

dubzzz commented 1 year ago

While bumping one project from v0.2.0 to v0.2.1, I experienced errors like:

> build-storybook -o build-storybook

info @storybook/react v6.5.12
info
info => Cleaning outputDir: C:\dev\monorepo\apps\Front\packages\design-system\build-storybook
info => Loading presets
info => Compiling manager..
info => Manager built (8.96 s)
vite v3.0.9 building for production...
✓ 0 modules transformed.
Could not resolve entry module (index.html).
ERR! Error: Could not resolve entry module (index.html).
ERR!     at error (file:///C:/dev/monorepo/apps/Front/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
ERR!     at ModuleLoader.loadEntryModule (file:///C:/dev/monorepo/apps/Front/node_modules/rollup/dist/es/shared/rollup.js:22352:20)
ERR!     at async Promise.all (index 0)
ERR!  Error: Could not resolve entry module (index.html).
ERR!     at error (file:///C:/dev/monorepo/apps/Front/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
ERR!     at ModuleLoader.loadEntryModule (file:///C:/dev/monorepo/apps/Front/node_modules/rollup/dist/es/shared/rollup.js:22352:20)
ERR!     at async Promise.all (index 0) {
ERR!   code: 'UNRESOLVED_ENTRY'
ERR! }
info => Loading presets

By looking into the diff between these two versions I found the following line change: https://github.com/storybookjs/builder-vite/compare/v0.2.0...v0.2.1#diff-1897e37c00f0a892e59db90901f310d352427ba2bd39472789bbd91a1e48c8efR183. Actually while in the past we either push-ed or unshift-ed, we now push and unshift as soon as the docgen has been defined to react-docgen-typescript.

The change seem to be related to https://github.com/storybookjs/builder-vite/commit/26e66474b42c6e7e4c98c3cba2a05bfd5805f6eb in which } else if (reactDocgen) { got replaced by if (typeof reactDocgenOption === 'string') {.

I locally changed the if by else if and dropped the error on my local version. But there might be a real need for this if without a else...?

dubzzz commented 1 year ago

Following my change, I checked that react-ts is still passing:

And before it:

dubzzz commented 1 year ago

For more context, in my case I got the following presets (output of await presets.apply('typescript', {})):

{
  "check": false,
  "reactDocgen": "react-docgen-typescript",
  "reactDocgenTypescriptOptions": {
    "shouldExtractLiteralValuesFromEnum": true,
    "shouldRemoveUndefinedFromOptional": true,
    "savePropValueAsString": true
  }
}

Which seems to be the default for https://github.com/storybookjs/storybook/blob/bd23a5abff9daadc85d6bd081dda082f01a82fbd/code/lib/core-server/src/presets/common-preset.ts#L46

dubzzz commented 1 year ago

I think I can close the issue. Actually the error came from the fact that our internal configuration was doing nasty things on plugins. So not related to this repository at all. The 0.2.1 just highlighted a bug on my side.

Sorry for the useless ping