mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
fix: make exports prop of proxy point to exports object (#1260)
This commit is contained in:
parent
030dd61bf2
commit
cd4bed5ad3
@ -168,7 +168,7 @@ export class ViteNodeRunner {
|
||||
exports.default = value
|
||||
},
|
||||
get exports() {
|
||||
return exports.default
|
||||
return exports
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
2
test/core/src/module-cjs.ts
Normal file
2
test/core/src/module-cjs.ts
Normal file
@ -0,0 +1,2 @@
|
||||
module.exports.a = 1
|
||||
module.exports.b = 2
|
||||
3
test/core/src/module-esm.ts
Normal file
3
test/core/src/module-esm.ts
Normal file
@ -0,0 +1,3 @@
|
||||
const c = 1
|
||||
export default c
|
||||
export const d = 2
|
||||
15
test/core/test/module.test.ts
Normal file
15
test/core/test/module.test.ts
Normal file
@ -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)
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user