Skip to content

Commit

Permalink
fix(nuxt): remove useNuxtApp mock in nuxt plugin preventing some beha…
Browse files Browse the repository at this point in the history
…viors

remove useNuxtApp mock since it prevents some plugins to run (e.g. @nuxtjs/i18n). It fixes the issue #703 .
  • Loading branch information
jhery authored and juleshry committed Apr 12, 2024
1 parent 6d5ba5c commit 5162bd5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/histoire-plugin-nuxt/runtime/composables.mjs

This file was deleted.

12 changes: 0 additions & 12 deletions packages/histoire-plugin-nuxt/src/index.ts
Expand Up @@ -135,7 +135,6 @@ async function useNuxtViteConfig() {
}
const runtimeDir = fileURLToPath(new URL('../runtime', import.meta.url))
nuxt.options.build.templates.push(
{ src: join(runtimeDir, 'composables.mjs'), filename: 'histoire/composables.mjs' },
{ src: join(runtimeDir, 'components.mjs'), filename: 'histoire/components.mjs' },
)

Expand All @@ -144,17 +143,6 @@ async function useNuxtViteConfig() {
app.templates.push({ src: join(runtimeDir, 'app-component.mjs'), filename: 'app-component.mjs' })
})

nuxt.hook('imports:sources', (presets) => {
const stubbedComposables = ['useNuxtApp']
for (const appPreset of presets.filter(p => p.from?.startsWith('#app'))) {
appPreset.imports = appPreset.imports.filter(i => typeof i !== 'string' || !stubbedComposables.includes(i))
}
presets.push({
from: '#build/histoire/composables.mjs',
imports: stubbedComposables,
})
})

return {
viteConfig: await new Promise<ViteConfig>((resolve, reject) => {
nuxt.hook('modules:done', () => {
Expand Down

0 comments on commit 5162bd5

Please sign in to comment.