Skip to content

Commit 1db0058

Browse files
committed
fix: temporary workaround for non ssr app
1 parent 63aa015 commit 1db0058

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

packages/nuxt/src/module.ts

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -203,34 +203,40 @@ const VueFire: NuxtModule<VueFireNuxtModuleOptions> =
203203
{ from: 'vuefire', name: 'useDatabaseList' },
204204
{ from: 'vuefire', name: 'useDatabaseObject' },
205205
])
206-
},
207-
208-
// NOTE: workaround until https://github.com/vitejs/vite/issues/11114 is fixed
209-
hooks: {
210-
// Resolve the correct firebase/firestore path on server only since vite is resolving the wrong one in dev
211-
'vite:extendConfig': async (config, { isServer }) => {
212-
config.resolve ??= {}
213-
config.resolve.alias ??= {}
214-
const aliases: Record<string, string> = config.resolve.alias as Record<
215-
string,
216-
string
217-
>
218-
219-
const promises: Promise<void>[] = []
220-
221-
if (isServer) {
222-
promises.push(
223-
addMissingAlias(aliases, 'firebase/firestore', 'index.mjs')
224-
)
225-
promises.push(
226-
addMissingAlias(aliases, '@firebase/firestore', 'index.node.mjs')
227-
)
228-
}
229-
230-
promises.push(addMissingAlias(aliases, 'firebase/app', 'index.mjs'))
231206

232-
await Promise.all(promises)
233-
},
207+
// NOTE: Because of https://github.com/nuxt/framework/issues/9865
208+
// otherwise, move to the `hooks` option
209+
if (nuxt.options.ssr) {
210+
// NOTE: workaround until https://github.com/vitejs/vite/issues/11114 is fixed
211+
nuxt.addHooks({
212+
// Resolve the correct firebase/firestore path on server only since vite is resolving the wrong one in dev
213+
'vite:extendConfig': async (config, { isServer }) => {
214+
config.resolve ??= {}
215+
config.resolve.alias ??= {}
216+
const aliases: Record<string, string> = config.resolve
217+
.alias as Record<string, string>
218+
219+
const promises: Promise<void>[] = []
220+
221+
if (isServer) {
222+
promises.push(
223+
addMissingAlias(aliases, 'firebase/firestore', 'index.mjs')
224+
)
225+
promises.push(
226+
addMissingAlias(
227+
aliases,
228+
'@firebase/firestore',
229+
'index.node.mjs'
230+
)
231+
)
232+
}
233+
234+
promises.push(addMissingAlias(aliases, 'firebase/app', 'index.mjs'))
235+
236+
await Promise.all(promises)
237+
},
238+
})
239+
}
234240
},
235241
})
236242

0 commit comments

Comments
 (0)