Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

dynamic: 'circular reference when looking for export' for re-exports in a cycle closed by a namespace import (Node resolves it)

オープン
#576 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, node.js, typescript

調査の方向性

Start by reproducing the failure with the minimal package graph in the issue, then compare it with Node’s successful run. The issue does not identify whether the cause is scriptc’s module graph emission or the embedded QuickJS-ng linker, so trace the dynamic build and link path to locate it. Done means the binary runs and prints tool for this reproduction, including when runtime.js imports the package namespace.

索引モデルが issue の本文から書いたものです。

説明

Summary

In embedded npm code, build --dynamic produces a binary that fails at module link time with Uncaught SyntaxError: circular reference when looking for export '<name>'. This happens when an export is resolved through a re-export chain that is also part of an import cycle containing a namespace import (import * as ns) plus export *. Node resolves the same graph without problems. There's no build-time diagnostic.

Real-world trigger: @earendil-works/[email protected]. Here dist/index.js re-exports createBashTool from ./core/sdk.js, which imports it from ./tools/index.js, re-exports it locally, and also does export * from "./agent-session-runtime.js". Somewhere below that, dist/core/extensions/loader.js does import * as _bundledPiCodingAgent from "../../index.js". Importing anything from the package fails:

Uncaught SyntaxError: circular reference when looking for export 'createBashTool' in module '.../node_modules/@earendil-works/pi-coding-agent/dist/index.js'
Minimal reproduction (plain JS package)
node_modules/pkg/package.json      {"name":"pkg","type":"module","exports":{".":"./index.js"}}
node_modules/pkg/index.d.ts        export declare function makeTool(): string;
node_modules/pkg/index.js          export { makeTool } from "./core/sdk.js";
node_modules/pkg/core/sdk.js       import { makeTool } from "./tools/index.js";
                                   export * from "./runtime.js";
                                   export { makeTool };
node_modules/pkg/core/runtime.js   import * as ns from "../index.js";
                                   export const runtime = () => typeof ns.makeTool;
node_modules/pkg/core/tools/index.js  export { makeTool } from "./bash.js";
                                      import { makeTool } from "./bash.js";
                                      export const all = [makeTool];
node_modules/pkg/core/tools/bash.js   export function makeTool() { return "tool"; }
main.ts                            import { makeTool } from "pkg";
                                   console.log(`${makeTool()}`);
$ node main.ts
tool
$ scriptc build --dynamic -o ./r main.ts   # exit 0
$ ./r
Uncaught SyntaxError: circular reference when looking for export 'makeTool' in module '.../node_modules/pkg/index.js'

The binary runs correctly (tool) when runtime.js has no import * as ns from "../index.js", so the namespace import that closes the cycle is what triggers it. I haven't confirmed whether this comes from scriptc's module graph emission or from the embedded QuickJS-ng linker itself.

Versions

Reproduced on scriptc 0.1.7 (npm) and on main at 0d9d946 (built from source), linux-x64-gnu, Node 26.10.0.

主要言語
TypeScript
スター
5.1k
フォーク
130
平均マージ
1時間 13分
マージ済み PR(30日)
254

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel-labs/scriptc のほかの issue

vercel-labs/scriptc の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。