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

Abierto
#3,415 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, react, typescript
Área
backend, devtools

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
6.7k
Forks
229
Merge medio
14 h 29 min
PR fusionados (30 d)
787

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel-labs/scriptc

Todos los issues de vercel-labs/scriptc

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.