Skip to content

Commit

Permalink
fix(nitro): add temporary workarouind for ufo resolution in nuxt2
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 6, 2021
1 parent 55d913d commit e5ecf6b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/compat.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e5ecf6b

Please sign in to comment.