Skip to content

Commit

Permalink
fix: make exports prop of proxy point to exports object
Browse files Browse the repository at this point in the history
  • Loading branch information
nieyuyao committed May 8, 2022
1 parent 336e4af commit 0fd8228
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite-node/src/client.ts
Expand Up @@ -168,7 +168,7 @@ export class ViteNodeRunner {
exports.default = value
},
get exports() {
return exports.default
return exports
},
}

Expand Down
2 changes: 2 additions & 0 deletions test/core/src/module-cjs.ts
@@ -0,0 +1,2 @@
module.exports.a = 1
module.exports.b = 2
3 changes: 3 additions & 0 deletions test/core/src/module-esm.ts
@@ -0,0 +1,3 @@
const c = 1
export default c
export const d = 2
15 changes: 15 additions & 0 deletions test/core/test/module.test.ts
@@ -0,0 +1,15 @@
import { expect, it } from 'vitest'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import { a, b } from '../src/module-cjs'
import c, { d } from '../src/module-esm'

it('should work when using cjs module', () => {
expect(a).toBe(1)
expect(b).toBe(2)
})

it('should work when using esm module', () => {
expect(c).toBe(1)
expect(d).toBe(2)
})

0 comments on commit 0fd8228

Please sign in to comment.