Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

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

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kit/src/internal/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/config/_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down