Skip to content

Commit

Permalink
fix(ssr): fix externalized cjs deps that exports compiled esmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 3, 2021
1 parent d021506 commit 8ec2d6f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vite/src/node/ssr/ssrModuleLoader.ts
Expand Up @@ -131,10 +131,11 @@ function nodeRequire(id: string, importer: string | null) {
const mod = importer
? require(resolveFrom(id, path.dirname(importer), true))
: require(id)
const defaultExport = mod.__esModule ? mod.default : mod
// rollup-style default import interop for cjs
return new Proxy(mod, {
get(mod, prop) {
if (prop === 'default') return mod
if (prop === 'default') return defaultExport
return mod[prop]
}
})
Expand Down

0 comments on commit 8ec2d6f

Please sign in to comment.