Skip to content

Commit

Permalink
feat: make fallbackCJS mode try resolve from /es/... and /lib/... (
Browse files Browse the repository at this point in the history
  • Loading branch information
zthxxx committed Jul 16, 2022
1 parent daf9886 commit 7be1cd5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite-node/src/externalize.ts
Expand Up @@ -4,7 +4,7 @@ import type { DepsHandlingOptions } from './types'
import { slash } from './utils'

const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/
const ESM_FOLDER_RE = /\/esm\/(.*\.js)$/
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/

const defaultInline = [
/virtual:/,
Expand Down Expand Up @@ -32,6 +32,7 @@ export function guessCJSversion(id: string): string | undefined {
for (const i of [
id.replace(ESM_FOLDER_RE, '/umd/$1'),
id.replace(ESM_FOLDER_RE, '/cjs/$1'),
id.replace(ESM_FOLDER_RE, '/lib/$1'),
id.replace(ESM_FOLDER_RE, '/$1'),
]) {
if (existsSync(i))
Expand Down

0 comments on commit 7be1cd5

Please sign in to comment.