Skip to content

Commit

Permalink
feat: interopDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 19, 2020
1 parent 3dcdfca commit 44117ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createHash } from 'crypto'
import mkdirp from 'mkdirp'
import createRequire from 'create-require'
import resolve from 'resolve'
import { isDir } from './utils'
import { isDir, interopDefault } from './utils'
import { TransformOptions } from './types'

export type JITIOptions = {
Expand Down Expand Up @@ -138,7 +138,7 @@ export default function createJITI (_filename: string = process.cwd(), opts: JIT
_require.cache[filename] = mod

// Return exports
return mod.exports
return interopDefault(mod.exports)
}

jiti.resolve = _resolve
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ export function isDir (filename: string): boolean {
return false
}
}

export function interopDefault (ex: any): any {
return (ex && (typeof ex === 'object') && 'default' in ex) ? ex.default : ex
}

0 comments on commit 44117ef

Please sign in to comment.