dynamic: 'circular reference when looking for export' for re-exports in a cycle closed by a namespace import (Node resolves it)
メンテナーはふだん 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vercel-labs/scriptc のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
vercel-labs/scriptc#577 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
vercel-labs/scriptc#575 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
vercel-labs/scriptc#522 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
vercel-labs/scriptc#293 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
vercel-labs/scriptc#265 ·
メンテナーはふだん 1 日以内に返信
vercel-labs/scriptc の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
callstackincubator/rozenite#518 ·
メンテナーはふだん 1 日以内に返信
-
Area/Workflow Priority/Blocker Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
wso2/product-integrator#2622 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
area:bash bug has repro platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
anthropics/claude-code#98644 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
allure-framework/allure-js#1603 ·
メンテナーはふだん 1 日以内に返信