Skip to content

Commit 0819275

Browse files
committed
fix(vite-node): don't fail when importing Promise module
1 parent 83a86a7 commit 0819275

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/vite-node/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ function exportAll(exports: any, sourceModule: any) {
509509
if (exports === sourceModule)
510510
return
511511

512-
if (isPrimitive(sourceModule) || Array.isArray(sourceModule))
512+
if (isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)
513513
return
514514

515515
for (const key in sourceModule) {

test/core/test/imports.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { resolve } from 'pathe'
33
import { describe, expect, test } from 'vitest'
44
import { dynamicRelativeImport } from '../src/relative-import'
55

6+
// @ts-expect-error module is not typed
7+
import promiseExport from '../src/cjs/promise-export'
8+
9+
test('promise export works correctly', async () => {
10+
await expect(promiseExport).resolves.toEqual({ value: 42 })
11+
})
12+
613
test('dynamic relative import works', async () => {
714
const stringTimeoutMod = await import('./../src/timeout')
815

0 commit comments

Comments
 (0)