Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Can't import @vitejs/plugin-vue2 properly when using vue2.7 #506

Closed
1 task
emosheeep opened this issue Oct 4, 2022 · 4 comments · Fixed by #508
Closed
1 task

[Bug] Can't import @vitejs/plugin-vue2 properly when using vue2.7 #506

emosheeep opened this issue Oct 4, 2022 · 4 comments · Fixed by #508
Labels
bug Something isn't working

Comments

@emosheeep
Copy link

emosheeep commented Oct 4, 2022

Describe the Bug

I got this error message while I'm using vue2.7 and @storybook/[email protected]:

@storybook/builder-vite requires vite-plugin-vue2 to be installed when using @storybook/vue. Please install it and start storybook again.

It seems that @storybook/[email protected] has resolved the problems(#503) about compatibility between vue2.6&2.7, which can auto import @vitejs/plugin-vue2 when using vue2.7, but actually not. I tried to print a log as below:

image

but the result is false:

image

Link to Minimal Reproducible Example

https://codesandbox.io/s/storybook-builder-vite-0-2-3s-bug-wtyj2u?file=/package.json

What version of vite are you using?

3.1.0

System info and storybook versions

System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - ~/.pnpm/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Browsers:
Chrome: 105.0.5195.125
Safari: 16.0
npmPackages:
@storybook/addon-actions: ^6.5.12 => 6.5.12
@storybook/addon-backgrounds: ^6.5.12 => 6.5.12
@storybook/addon-docs: ^6.5.12 => 6.5.12
@storybook/addon-essentials: ^6.5.12 => 6.5.12
@storybook/addon-links: ^6.5.12 => 6.5.12
@storybook/addon-measure: ^6.5.12 => 6.5.12
@storybook/addon-outline: ^6.5.12 => 6.5.12
@storybook/builder-vite: ^0.2.3 => 0.2.3
@storybook/client-api: ^6.5.12 => 6.5.12
@storybook/client-logger: ^6.5.12 => 6.5.12
@storybook/core-common: ^6.5.12 => 6.5.12
@storybook/node-logger: ^6.5.12 => 6.5.12
@storybook/vue: ^6.5.12 => 6.5.12

Participation

  • I am willing to submit a pull request for this issue.
@emosheeep emosheeep added the bug Something isn't working label Oct 4, 2022
@emosheeep emosheeep changed the title [Bug] [Bug] Can't import @vitejs/plugin-vue2 properly when using vue2.7 Oct 4, 2022
@IanVS
Copy link
Member

IanVS commented Oct 4, 2022

Doh, you're right, not sure why I thought that would work. I'll fix it up, but for now, I think you could use "vue": "^2.7.0" for the dependency as a workaround (the latest 2.7 will still be installed).

@riaanduplessis
Copy link

Doh, you're right, not sure why I thought that would work. I'll fix it up, but for now, I think you could use "vue": "^2.7.0" for the dependency as a workaround (the latest 2.7 will still be installed).

I can confirm changing it to "vue": "^2.7.0" works. This was quite interesting to track down since I still had vite-plugin-vue2 installed, in which case Storybook runs fine until you try and render a component using <script setup>.

@IanVS
Copy link
Member

IanVS commented Oct 5, 2022

😬 I'll try to get a fix out as soon as I can.

@emosheeep
Copy link
Author

Really appreciate

IanVS added a commit that referenced this issue Oct 6, 2022
Fixes: #506

This corrects the vue 2.6 / 2.7 logic, and also finds a slightly-better way to handle module resolution from within `builder-vite` when running examples.  Instead of adding dev dependencies into the builder, this sets a `node_path` environment variable, so that the node_modules of the example is used as a global lookup from within the builder.
@IanVS IanVS closed this as completed in #508 Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants