island: ESM entry with top-level await fails via sync call path (ERR_REQUIRE_ASYNC_MODULE)

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

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

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

評価

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

調査の方向性

Start by tracing the island call path through packages/runtime/src/scr_node_island_host.cjs, especially load(path, esm) and the createRequire/Module._load path described in the issue. Reproduce with the Ink example and inspect how ESM entries with top-level await reach callSync. Done when the reproduction loads without ERR_REQUIRE_ASYNC_MODULE through the appropriate async island call path.

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

説明

Summary

An island package whose module graph contains top-level await fails to load: the island's call path require()s the ESM entry, and Node throws ERR_REQUIRE_ASYNC_MODULE inside the embedded libnode — the error propagates out of callSync.

This is where ink stops on main (all its former SC9001 build ICEs are fixed — it now compiles fully, with react/es-toolkit/react-reconciler correctly routed to islands).

Reproduction

import { render, Text } from "ink";
render(React.createElement(Text, null, "hello"));

Builds ✅, then at runtime:

Error [ERR_REQUIRE_ASYNC_MODULE]: require() cannot be used on an ESM graph with top-level await
Required module: ~/.cache/scriptc/node-islands/<hash>/node_modules/ink/build/index.js
    at ModuleLoader.importSyncForRequire

packages/runtime/src/scr_node_island_host.cjs load(path, esm) does have an import() branch for esm modules — but the call path that reaches ink's entry apparently goes through createRequire/Module._load instead. A fix likely needs esm entries routed through import() (and therefore an async island call) when the module graph has TLA.

Verified on main (d4c82a5c3), darwin-arm64, libnode pack per packages/libnode-common/build-pack.mjs.

主要言語
TypeScript
スター
6.7k
フォーク
229
平均マージ
14時間 29分
マージ済み PR(30日)
787

環境構築

はじめの一歩

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

vercel-labs/scriptc のほかの issue

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

似ている issue

TypeScript の issue をもっと見る

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

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