Skip to content

[Bug]: cycle reference when using import() #1573

@colinaaa

Description

@colinaaa

Version

System:
    OS: Linux 5.15 veLinux GNU/Linux
    CPU: (64) x64 Intel(R) Xeon(R) Platinum 8457C
    Memory: 97.90 GB / 251.61 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  npmPackages:
    @rslib/core: ^0.20.3 => 0.20.3

Details

index.js (entrypoint):

#!/usr/bin/env node

import { foo } from "./foo.js";

async function main() {
  const { bar } = await import("./index.ts");
  foo();
  bar();
}

await main();

foo.js:

import { foo } from './foo.js'

export function bar() {
  console.log('bar')
  foo()
}

bar.js:

import { foo } from './foo.js'

export function bar() {
  console.log('bar')
  foo()
}

Reproduce link

https://github.com/colinaaa-reproductions/rslib-repro-cyclic-reference

Reproduce Steps

  1. pnpm install
  2. pnpm build
  3. node dist/index.js

which would result in a warning:

Warning: Detected unsettled top-level await at file:///root/rslib-repro-cyclic-reference/dist/356.js:50
await main();
^

Metadata

Metadata

Assignees

Labels

RspackRspack related issue

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions