mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- The bundler-CJS rewrite erases recognized __toESM(require("x")) wrappers — module-scope bindings, the `, 1` node-mode variant, inline member reads — down to the bare require at its original offsets; .default accesses pad to the binding where Node's answer is the module (plain-CJS targets, node mode) and stay member reads for __esModule-stamped targets, decided by a require-resolution probe over the target's shipped source (forwarding chains followed)
- Interop the recognizer cannot finish — deviant helper text, escaping interop objects, non-literal arguments, ESM-output calls — answers { degrade }: the fs shadow reports the package as an offender with a note naming the construct and the fallback loop islands it, never a failed build and never the silent alternative (a live helper chain's `var __create = Object.create;` fences at module load while the report claims static); auto and explicit opt-ins share the path
- Bare requires of opted-in packages now behave like relative ones end to end: requireInitStmt emits the dep's inline %init (previously the module never initialized before its exports were read), and cjsLocalModuleBindingOf/resolveValueSymbol resolve member reads and namespace method calls through the npm-static dep's export table
- Erased wrappers join the neutralize set so the helper sweep drops the whole dead chain, hoisted canonical-table texts copied off the source drop .default on module-valued bindings exactly like the pads do, and a file with interop pads but no canonical table still rewrites pads-only
- Fixtures gtcore/gtwrap/gtdrift with cases 2556-toesm-external (byte-matches Node across both dep shapes and the comma-call spelling) and 2557-toesm-drift (construct-naming degrade under explicit and auto opt-ins), excluded from the flagless island lane like the 246x family
16 lines
632 B
JavaScript
16 lines
632 B
JavaScript
// A hand-rolled __toESM whose text deviates beyond the recognizer's
|
|
// structural contract (a block body building the namespace imperatively —
|
|
// no __copyProps result, no conditional default stamp). The static
|
|
// rewrite must NOT guess at its semantics: the package degrades to the
|
|
// island with a note naming the construct, never a failed build.
|
|
"use strict";
|
|
var __toESM = (mod) => {
|
|
var ns = { default: mod };
|
|
for (var key in mod) ns[key] = mod[key];
|
|
return ns;
|
|
};
|
|
var import_gtcore = __toESM(require("gtcore"));
|
|
exports.drift = function drift() {
|
|
return import_gtcore.default.label(7) + ":" + import_gtcore.tag;
|
|
};
|