island: ESM module with 'module.exports' named export loses its default export across the boundary

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

Los mantenedores suelen responder en 1 día

@espetro ya está trabajando en esto.

Desde el 8/11/2026.

  • #3446 de @espetro — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
node.js, typescript
Área
api, backend

Línea de trabajo

Read packages/runtime/src/scr_node_island_host.cjs and packages/compiler/src/frontend/lowering/lower-node-island.ts, then reproduce the failure with the provided ESM module and build command. The issue says a pull request is already underway; compare the boundary’s default import behavior with and without the named module.exports export. Done means the default import remains callable across the island boundary.

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

Descripción

Summary

An ESM module running in a Node island that contains export {x as 'module.exports'} — an export named the string module.exports — resolves to undefined on the native side's default import. import shout from "pkg" gives undefined; calling it throws TypeError: value is not a function. This is what breaks yargs under islands: yargs/index.mjs ends with export {Yargs as 'module.exports'}.

Reproduction

SCRIPTC_LIBNODE=<pack> scriptc build main.mts -o app --node-island=islpkg && ./app
// node_modules/islpkg/index.mjs
function factory(shim) { return function shout(s) { return shim(s).toUpperCase(); }; }
const shim = (s) => s;
const shout = factory(shim);
export default shout;
export {shout as 'module.exports'};   // <-- this line breaks it

// main.mts
import shout from "islpkg";
console.log("default:", typeof shout, shout("hi"));
  • Without the 'module.exports' export: default: function HI ✅
  • With it: Uncaught TypeError: value is not a function ❌
  • --node-islands=off (fully native): works ✅ — island-boundary specific.

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

Likely location

packages/runtime/src/scr_node_island_host.cjs (namespace[name] reads) and/or packages/compiler/src/frontend/lowering/lower-node-island.ts — the presence of a 'module.exports' export name seems to make the boundary treat the ESM module as CJS-facade-shaped, reading the wrong slot for default.

A PR is underway.

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.