fix(nitro): add temporary workarouind for ufo resolution in nuxt2

This commit is contained in:
Pooya Parsa 2021-04-06 14:57:10 +02:00
parent 7b5bd53a02
commit f66d917729

View File

@ -1,5 +1,6 @@
import fetch from 'node-fetch'
import { resolve } from 'upath'
import { resolveModule } from '@nuxt/kit'
import { build, generate, prepare } from './build'
import { getNitroContext, NitroContext } from './context'
import { createDevServer } from './server/dev'
@ -55,6 +56,15 @@ export default function nuxt2CompatModule () {
src: resolve(nitroContext._internal.runtimeDir, 'app/nitro.client.js')
})
// Fix module resolution
nuxt.hook('webpack:config', (configs) => {
for (const config of configs) {
if (config.name === 'client') {
config.resolve.alias.ufo = resolveModule('ufo/dist/index.mjs')
}
}
})
// Resolve middleware
nuxt.hook('modules:done', () => {
const { middleware, legacyMiddleware } = resolveMiddleware(nuxt)