storybook [Bug]: 使用自定义虚拟存储目录的pnpm时,构建预览不正确,

monwx1rj  于 29天前  发布在  其他
关注(0)|答案(1)|浏览(197)

描述bug

当使用最新版本的pnpm,并在.npmrc中设置如下内容时:

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

关于store-dir和virtual-store-dir。
因此,如果我的node_modules位于项目之外的地方,然后使用babel-loader进行预览 - https://github.com/storybookjs/storybook/blob/7a86f0363ef184a80437b7abf98e98d86e821f75/code/lib/builder-webpack5/src/preview/babel-loader-preview.ts 错误地定义了 include 属性。结果是babel-loader没有转译我的storybook组件,我得到了一些TS错误。
这个问题出现在 getProjectRoot 方法中 -
storybook/code/lib/core-common/src/utils/paths.ts
第4行到第29行 in 7035ea7
| | exportconstgetProjectRoot=()=>{ |
| | letresult; |
| | try{ |
| | constfound=findUp.sync('.git',{type: 'directory'}); |
| | if(found){ |
| | result=result||path.join(found,'..'); |
| | } |
| | }catch(e){ |
| | // |
| | } |
| | try{ |
| | constfound=findUp.sync('.svn',{type: 'directory'}); |
| | if(found){ |
| | result=result||path.join(found,'..'); |
| | } |
| | }catch(e){ |
| | // |
| | } |
| | try{ |
| | result=result||__dirname.split('node_modules')[0]; |
| | }catch(e){ |
| | // |
| | } |
| | |
| | returnresult||process.cwd(); |
| | }; |
它在我的虚拟存储库的home目录中找到了 node_modules,并认为我的组件位于一个目录上。要解决此问题,我需要更改 includebabel-loaderwebpackFinal 中。另一个与此方法相关的bug是 #14042

cetgtptt

cetgtptt1#

我在使用pnpm进行测试时遇到了问题,即使在其他项目中也是如此,所以我不得不清理缓存。我删除了所有的node_modules并重新构建。

相关问题