question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] React/Docgen TypeScript detection insufficient in NPM monorepo.

See original GitHub issue

What 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
scott-lccommented, Jul 25, 2022

@IanVS

Both manually specifying react-docgen as well as defaulting to react-docgen-typescript works for me. Thanks.

+1

1reaction
IanVScommented, Jul 22, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mismatching React types in pnpm monorepo - Stack Overflow
i'm currently getting an error due to mismatching react versions, typescript isn't picking up on the @types/react version that's closest in ...
Read more >
How we configured pnpm and Turborepo for our monorepo
We decided to move to a monorepo to solve these issues. We chose pnpm as our package manager and Turborepo as our build...
Read more >
Setup a Monorepo with PNPM workspaces and speed it up ...
In this article we're going to have a deep dive into setting up a new monorepo using PNPM workspaces that hosts a Remix...
Read more >
Building a full-stack TypeScript application with Turborepo
js using pnpm workspaces and demonstrate how the process can be improved by using Turborepo. What is a monorepo? Polyrepos; Optimizing monorepos ......
Read more >
Tools | pnpm
Turborepo - A high-performance build system for JavaScript and TypeScript codebases. Rush - A scalable monorepo manager for the web. changesets - A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found