[Bug] React/Docgen TypeScript detection insufficient in NPM monorepo.
See original GitHub issueWhat version of vite
are you using?
vite@3.0.2
System info and storybook versions
System: OS: macOS 11.4 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Binaries: Node: 18.3.0 - ~/.nvm/versions/node/v18.3.0/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.14.0 - ~/.nvm/versions/node/v18.3.0/bin/npm Browsers: Chrome: 95.0.4638.69 Firefox: 102.0.1 Safari: 14.1.1
@storybook/cli: 6.5.9
Describe the Bug
The code here attempts to determine if typescript is installed by reading the package.json
file and checking for a typescript
dependency in either pkgJson.dependencies
or pkgJson.devDependencies
. (should also check pkgJson.peerDependencies
BTW).
In an NPM monorepo (AKA workspaces), it is likely that any typescript dependency is defined at the root of the repository (<root>/package.json
), rather than in the package.json
file for a particular workspace/package (<root>/packages/some-package/package.json
). Therefore the determination whether or not typescript
is being used is incorrect.
[tangentially related]
As a result, for me the react-docgen
plugin is being referenced which, incidentally, ultimately throws an exception about a missing @rollup/pluginutils
dependency:
info => Loading presets
ERR! Error: Cannot find module '@rollup/pluginutils'
ERR! Require stack:
ERR! - .../node_modules/@storybook/builder-vite/dist/plugins/react-docgen.js
Link to Minimal Reproducible Example
No response
Participation
- I am willing to submit a pull request for this issue.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
@IanVS
Both manually specifying
react-docgen
as well as defaulting toreact-docgen-typescript
works for me. Thanks.+1
We did use a check similar to that at one point, but it ended up being a problem because typescript can be brought in without actually being used. https://github.com/storybookjs/builder-vite/pull/313.
I’ll try giving this some thought though and see if we can clean it up one way or another.