storybookjs/storybook

[Bug]: incorrectly build preview when use pnpm with custom virtual store directory

已關閉

#20,211 建立於 2022年12月12日

 (1 則留言) (0 個反應) (0 位負責人)TypeScript (10,058 個分叉)batch import
bughelp wantedpnpmsev:S3

倉庫指標

星標
 (89,909 顆星)
PR 合併指標
 (平均合併 7天 22小時) (30 天內合併 184 個 PR)

描述

Describe the bug

When use latest version of pnpm with .npmrc like this:

store-dir=${HOME}/.some-folder/pnpm-store
virtual-store-dir=${HOME}/.some-folder/pnpm-virtual-store

About store-dir and virtual-store-dir.

So in case when my node modules located somewhere outside the project then used babel-loader for preview - https://github.com/storybookjs/storybook/blob/7a86f0363ef184a80437b7abf98e98d86e821f75/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts defines include property incorrectly. As a result babel-loader not transpile my storybook components and I got some TS error.

The problem in this getProjectRoot method - https://github.com/storybookjs/storybook/blob/7035ea7389393da041985ebc491ee58dedb50d06/code/lib/core-common/src/utils/paths.ts#L4-L29. It founds node_modules inside my virtual store in home and thinks that my components located in one directory up.

To fix this problem, I need to change include option for babel-loader inside webpackFinal.

Another bug with this method - https://github.com/storybookjs/storybook/issues/14042

To Reproduce

No response

System

No response

Additional context

No response

貢獻者指南