From e5ecf6b029e657f7f097f1a8e4b19a9cb8821cc8 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 6 Apr 2021 14:57:10 +0200 Subject: [PATCH] fix(nitro): add temporary workarouind for ufo resolution in nuxt2 --- src/compat.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/compat.ts b/src/compat.ts index 725f446b3f..1d8b0b16ee 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -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)