Skip to content

Commit 4a261f2

Browse files
authored
test(module-runner): add TLA circular import case (#23299)
1 parent d9b10a9 commit 4a261f2

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { b } from './b.js'
2+
3+
await Promise.resolve()
4+
5+
export const a = 'a'
6+
export const getB = () => b
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { a } from './a.js'
2+
3+
await Promise.resolve()
4+
5+
export const b = 'b'
6+
export const getA = () => a
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { a, getB } from './a.js'
2+
import { b, getA } from './b.js'
3+
4+
export { a, b, getA, getB }

packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ describe('module runner initialization', async () => {
272272
expect(action).toBeDefined()
273273
})
274274

275+
it('resolves circular imports between modules with top-level await', async ({
276+
runner,
277+
}) => {
278+
const mod = await runner.import('/fixtures/tla-circular/index.js')
279+
280+
expect(mod.a).toBe('a')
281+
expect(mod.b).toBe('b')
282+
expect(mod.getA()).toBe('a')
283+
expect(mod.getB()).toBe('b')
284+
})
285+
275286
it('this of the exported function should be undefined', async ({
276287
runner,
277288
}) => {

0 commit comments

Comments
 (0)