fix(nuxi, kit): enable esmResolve flag for jiti (#6356)

This commit is contained in:
pooya parsa 2022-08-04 15:22:32 +02:00 committed by GitHub
parent 1f00a9f011
commit e3534bcda5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import { interopDefault } from 'mlly'
import jiti from 'jiti'
// TODO: use create-require for jest environment
const _require = jiti(process.cwd(), { interopDefault: true })
const _require = jiti(process.cwd(), { interopDefault: true, esmResolve: true })
export interface ResolveModuleOptions {
paths?: string | string[]

View File

@ -115,7 +115,7 @@ function normalizeConfigModule (module, rootDir) {
function getNuxtConfig (rootDir) {
try {
return jiti(rootDir, { interopDefault: true })('./nuxt.config')
return jiti(rootDir, { interopDefault: true, esmResolve: true })('./nuxt.config')
} catch (err) {
// TODO: Show error as warning if it is not 404
return {}

View File

@ -154,7 +154,7 @@ export default {
val = process.env.NUXT_CREATE_REQUIRE || val ||
(typeof globalThis.jest !== 'undefined' ? 'native' : 'jiti')
if (val === 'jiti') {
return p => jiti(typeof p === 'string' ? p : p.filename)
return p => jiti(typeof p === 'string' ? p : p.filename, { esmResolve: true })
}
if (val === 'native') {
return p => createRequire(typeof p === 'string' ? p : p.filename)