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

Commit

Permalink
fix(nuxi, kit): enable esmResolve flag for jiti (#6356)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 4, 2022
1 parent 1f00a9f commit e3534bc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
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

0 comments on commit e3534bc

Please sign in to comment.