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

Doen't work with compatibilityVersion: 4 and /app folder #805

Open
luca-smartpricing opened this issue Oct 11, 2024 · 1 comment · May be fixed by #823
Open

Doen't work with compatibilityVersion: 4 and /app folder #805

luca-smartpricing opened this issue Oct 11, 2024 · 1 comment · May be fixed by #823
Labels
type: bug Something isn't working

Comments

@luca-smartpricing
Copy link
Contributor

luca-smartpricing commented Oct 11, 2024

Environment

  • Operating System: Darwin
  • Node Version: v20.18.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-xhr4cw?file=.storybook%2Fpreview.js

Describe the bug

But i'm sure that with nuxt compatibilityVersion: 4 with components under the app folder when you use slots in a story render function, it doesn't work (don't render the template).

  render: (args) => ({
    components: { CustomComponent },
    setup() {
      return { args }
    },
    template: '<CustomComponent v-bind="args">Hello</CustomComponent>',
  }),

Additional context

No response

@luca-smartpricing luca-smartpricing added the type: bug Something isn't working label Oct 11, 2024
@bnachtweh
Copy link

@luca-smartpricing I'm not sure if this fixes your issue, but I ran into the same issue. It also seems that you need to run the Nuxt dev server to be able to run Storybook in the first place. Otherwise other Nuxt related implementations will trigger errors in my Storybook env. The problem with the Nuxt dev server is that the Vue alias that is resolved seems to be the runtime variant (vue.runtime.esm-bundler.js).

Overriding the Vite config for Storybook to use the "regular" esm builder could allow you to view your components with the template option again. Can you try this (specifically the viteFinal option):

Obviously this is something that needs to be addressed, buy maybe you could continue your work with this fix in the meantime.

// .storybook/main.ts
import type { StorybookConfig } from '@storybook-vue/nuxt';
import { mergeConfig } from 'vite';

const config: StorybookConfig = {
  stories: ['../stories/**/*.stories.ts'],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
  ],
  framework: '@storybook-vue/nuxt',
  docs: {
    autodocs: 'tag',
  },
  async viteFinal(config) {
    return mergeConfig(config, {
      resolve: {
        alias: {
          vue: 'vue/dist/vue.esm-bundler.js',
        },
      },
    });
  },
};
export default config;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
2 participants