You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This doesn't work correctly under the Yarn PNPM linker, which constructs a node_modules tree via symlinks into a node_modules/.store directory. So, all packages are stored under /node_modules/.store/<packagename>-virtual-<hash>/package/, and require.resolve will return absolute paths into here. Thus, stripAbsNodeModulesPath is called since node_modules is in the path, and ti will return a path like .store/..., which is not a valid import path. Vite then throws errors about these paths:
3:37:05 PM [vite] Pre-transform error: Failed to resolve import ".store/@storybook-react-virtual-d2ec5c3452/package/dist/entry-preview.mjs" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
3:37:05 PM [vite] Internal server error: Failed to resolve import ".store/@storybook-react-virtual-d2ec5c3452/package/dist/entry-preview.mjs" from "/virtual:/@storybook/builder-vite/vite-app.js". Does the file exist?
Plugin: vite:import-analysis
File: /virtual:/@storybook/builder-vite/vite-app.js:7:81
5 |
6 | const getProjectAnnotations = async (hmrPreviewAnnotationModules = []) => {
7 | const configs = await Promise.all([hmrPreviewAnnotationModules[0] ?? import('.store/@storybook-react-virtual-d2ec5c3452/package/dist/entry-preview.mjs'),
| ^
8 | hmrPreviewAnnotationModules[1] ?? import('.store/@storybook-react-virtual-d2ec5c3452/package/dist/entry-preview-docs.mjs'),
Describe the bug
SB attempts to strip all leading
node_modules/
components off of the path of an import to get Vite to bundle correctly:storybook/code/core/src/common/utils/strip-abs-node-modules-path.ts
Lines 9 to 17 in 33e4397
This doesn't work correctly under the Yarn PNPM linker, which constructs a
node_modules
tree via symlinks into anode_modules/.store
directory. So, all packages are stored under/node_modules/.store/<packagename>-virtual-<hash>/package/
, andrequire.resolve
will return absolute paths into here. Thus,stripAbsNodeModulesPath
is called sincenode_modules
is in the path, and ti will return a path like.store/...
, which is not a valid import path. Vite then throws errors about these paths:Reproduction link
https://github.com/ethanwu10/sb-yarn-pnpm-vite-repro
Reproduction steps
yarn storybook
System
Additional context
No response
The text was updated successfully, but these errors were encountered: