fix: resolve pnpm hoisting issue with StorybookConfig type imports #923
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using pnpm without hoisting (e.g., without
shamefully-hoist=true
), users cannot import types from@storybook-vue/nuxt
directly because the package is not available at the top-levelnode_modules
. This causes TypeScript compilation errors when trying to use:Solution
This PR fixes the issue by ensuring that all types from
@storybook-vue/nuxt
are properly re-exported through@nuxtjs/storybook
, allowing users to import types directly from the main package:Changes Made
Fixed package.json exports: Updated
packages/nuxt-module/package.json
to point to the correct.d.mts
TypeScript declaration files instead of non-existent.d.ts
files.Updated examples: Changed import statements in playground and examples to use
@nuxtjs/storybook
instead of@storybook-vue/nuxt
.Updated documentation: Modified the configuration documentation to show the correct import pattern.
Technical Details
The fix leverages the existing
export * from '@storybook-vue/nuxt'
in the nuxt-module source code, which already re-exports all types includingStorybookConfig
. The main issue was that the package.json exports weren't pointing to the correct TypeScript declaration files, preventing proper type resolution.Now users can safely import types using either pattern, but the recommended approach is to import from
@nuxtjs/storybook
to avoid pnpm hoisting issues.This solution works in both hoisted and non-hoisted pnpm environments without requiring users to configure
shamefully-hoist=true
.Fixes #920.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.iconify.design
node (vitest 1)
(dns block)fonts.bunny.net
node (vitest 1)
(dns block)storybook.js.org
node /home/REDACTED/work/storybook/storybook/playground/node_modules/.bin/../storybook/bin/index.cjs build
(dns block)node /home/REDACTED/work/storybook/storybook/examples/starter/node_modules/.bin/../storybook/bin/index.cjs build
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.