Skip to content

Commit

Permalink
fix(vite-node): don't fail when importing Promise module
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jul 4, 2023
1 parent 83a86a7 commit 0819275
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite-node/src/client.ts
Expand Up @@ -509,7 +509,7 @@ function exportAll(exports: any, sourceModule: any) {
if (exports === sourceModule)
return

if (isPrimitive(sourceModule) || Array.isArray(sourceModule))
if (isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)
return

for (const key in sourceModule) {
Expand Down
7 changes: 7 additions & 0 deletions test/core/test/imports.test.ts
Expand Up @@ -3,6 +3,13 @@ import { resolve } from 'pathe'
import { describe, expect, test } from 'vitest'
import { dynamicRelativeImport } from '../src/relative-import'

// @ts-expect-error module is not typed
import promiseExport from '../src/cjs/promise-export'

test('promise export works correctly', async () => {
await expect(promiseExport).resolves.toEqual({ value: 42 })
})

test('dynamic relative import works', async () => {
const stringTimeoutMod = await import('./../src/timeout')

Expand Down

0 comments on commit 0819275

Please sign in to comment.