Back to Tsx

Node integration points

notes/node/node-integration-points.md

4.23.13.8 KB
Original Source

Node integration points

tsx follows Node's loader behavior closely, including a few implementation details that are not formal public APIs. This file is a re-verification map: when a new Node line changes loader internals, check these points and update tests or code only when behavior actually changed.

Integration pointtsx siteNode sourceBehavior to re-verify
cjsPreparseModuleExports stack framesrc/cjs/api/module-resolve-filename/is-from-cjs-lexer.tsFunction name in v24.15.0 translators.js#L381Whether tsx still identifies resolution initiated by Node's CJS named-export preparse path and applies query/cache handling only there.
CJS lexer grammar for module.exports = { ... }src/esm/hook/load.ts transform-before-preparse path; tests/fixtures.ts annotation fixtureVendored JS grammar docs in v24.11.1 README.md#L7-L51; native Merve grammar docs in v24.14.0 merve.h#L82-L102Whether esbuild's dead-code CJS export annotation still produces detectable named exports.
Module._cache keying by resolved filename/data URLsrc/cjs/api/module-resolve-filename/interop-cjs-exports.ts, preserve-query.ts, src/cjs/api/module-extensions.tsCache lookup in v24.15.0 loader.js#L1250-L1256 and ESM-loader cache marker handling loader.js#L1297-L1308Whether data-URL transformed CJS modules and query-preserved modules still share the intended CJS identity and export parsing state.
require.extensions / Module._extensions enumeration and longest-extension lookupsrc/cjs/api/module-extensions.tsExtension table initialization loader.js#L355; longest registered extension lookup loader.js#L591-L600; extension dispatch loader.js#L1545-L1553Whether tsx's CJS loader still receives explicit .ts/.tsx/.cts and unknown-explicit-extension cases the same way Node routes extension handlers.
loadWithHooks/resolveWithHooks sync hook call sitessrc/esm/api/register.ts, src/esm/hook/resolve.ts, src/esm/hook/load.tsv24.15.0 customization_hooks.js#L365, customization_hooks.js#L408Whether sync-hook behavior still matches the assumptions in tsx's sync/async registration split.
shouldBeReloadedByCJSLoader load/translate handshakesrc/esm/hook/load.ts (shouldBeReloadedByCJSLoader result field)v24.11.1 load.js#L144-L171, translators.js#L334-L363Whether transformed CJS still re-enters Module._load where tsx needs CJS cache, globals, and evaluation semantics.

Maintenance rule

When touching any tsx site above, check the latest Node source for the corresponding integration point and prefer a runtime test when the behavior matters. This file is an index for what to re-verify; tests are the enforcement.