-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
fix: Nuxt App created only when story vue app rendered first time, #830
Conversation
… nuxtContext for storyContext.id exists
✅ Deploy Preview for nuxt-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…son and pnpm-lock.yaml
…ories to fix linting errors
This has the same problem as the other PRs adding the vue alias: the playground build is failing...no idea why :( |
Hi @tobiasdiez,what can we do to get this PR merged? could you review it when you have some time? Let me know if you need any clarifications.I tried to recreate the Playground, but it's still failing. Do you think bypassing it could cause any issues? |
I have no idea why the playground is failing, and only the playground. I was afraid that if we add the vue alias then users will experience similar issues. I didn't had time yet to debug why it occurs. You said you re-generated the playground. Do you mean you tried to update the code to be aligned with the starter / storybook init? That was my plan to approach the problem: recreate the starter, playground and the other examples with the version from storybookjs/storybook#28607 (which we should do anyway). And then see try again with adding the vue compiler alias... |
I tried that but i got an error while using the |
…y issues in storybook build
…d memory issues in storybook build
Hi @tobiasdiez. i have debugged further the build command.
The file ID keeps changing with each importer step. I suspect this is caused by faulty string replacement logic in one of the plugins or configurations. Let me know if this can help debug further or give you an idea who can help us. |
Thanks for looking into this. So it comes down now to figuring out why vue is constantly replaced? |
Yes, I think so. We should start by investigating how the replacement of 'vue' with the alias 'vue/dist/vue.esm-bundler.js' is being handled and identify where the logic goes wrong. This seems to be the root cause of the recursive replacements |
…ub.com/nuxt-modules/storybook into chaks/fix-nuxtapp-for-rerendered-story
… chaks/fix-nuxtapp-for-rerendered-story
🔗 Linked issue
📚 Description
The issue arose because, in the setup function, the code was checking if the Nuxt context with storyContext.id was already used by the Nuxt app. This prevented the recreation of the Nuxt app, which led to a bug where revisiting the same story caused its Vue app to lack a Nuxt instance.
The bug specifically occurred when using modules that register plugins with the Vue app, such as i18n. On the first render, the story was correctly displayed with the registered plugin (e.g., translations). However, on subsequent renders, the Vue app couldn't find the registered plugin.
Solution:
Use canvasElement.id as a unique key for differentiation.
Create a new Nuxt app each time a story’s Vue app is rendered.
Remove the check for context.tryUse() since a new Vue app is always created and mounted for each story.
This ensures that every story render gets a fresh and fully initialized Nuxt app.
Changes:
I added i18n example to playground and example/showcase
I configured Vite bundler to alias "vue" to "vue/dist/vue.esm-bundler.js, to solve the runtime compilation issue for custom string template