Skip to content

fix(ts-node compiler option mismatch in runtime module loader)#42

Merged
priyanshus merged 4 commits into
mainfrom
fix-tsnode-issue-#41
Apr 23, 2026
Merged

fix(ts-node compiler option mismatch in runtime module loader)#42
priyanshus merged 4 commits into
mainfrom
fix-tsnode-issue-#41

Conversation

@priyanshus

@priyanshus priyanshus commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

Fixed ts-node compiler option mismatch in runtime module loader.

  • Refactor importEvalFile - Separate loadRuntimeModule
  • Consume same loadRuntimeModule in configLoader too.
  • add unit tests.

@vercel

vercel Bot commented Apr 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evaliphy Ready Ready Preview, Comment Apr 23, 2026 0:49am

@quanticsoul4772

Copy link
Copy Markdown
Contributor

Design is the right direction — centralizing module loading addresses a real spread of inconsistent import/require sites. A few notes.

Why ts-node over tsx? ts-node isn't on main today — this PR introduces it as a new runtime dependency alongside tsx, which is already in dependencies. tsx exposes a register API (tsx/cjs/api) that covers the same CommonJS hook use case with a lighter footprint. Unless there's a specific reason ts-node was preferred, consolidating on tsx would avoid shipping two TypeScript runtimes in published artifacts. Worth a line in the PR body either way.

Formatting regression in packages/core/src/index.ts:

-  export { mergeConfigs } from './config/mergeConfig.js';
+    export { mergeConfigs } from './config/mergeConfig.js';

Looks like an editor slip (2→4 space indent on one line). Fix before merge.

.js fallback detection: robust for ERR_REQUIRE_ESM, fragile for the SyntaxError message matches. A cleaner path: always use await import() for .js — modern Node's dynamic import() loads both ESM and CJS, so the error-introspection branch goes away. Reserve require for .cjs where it's unambiguous.

.mts behavior: routed through ts-node + CommonJS with the other TypeScript extensions. Works for plain export default usage, but .mts files using top-level await or import.meta will fail to compile (CJS can't express either). Might be worth a short note in the docstring that .mts is transpiled to CJS, so ESM-only syntax isn't supported.

Tests cover TS / CJS .js / ESM-in-.js fallback / fresh reload in both directions — good coverage. One gap: no .mts test, which would pin down the actual behavior (and catch regressions if the handling later changes).

@priyanshus

Copy link
Copy Markdown
Collaborator Author

Reverted to tsx.

@priyanshus priyanshus force-pushed the fix-tsnode-issue-#41 branch from 03d81cc to 7f2420c Compare April 23, 2026 12:48
@priyanshus priyanshus merged commit c92bae0 into main Apr 23, 2026
3 checks passed
@priyanshus priyanshus deleted the fix-tsnode-issue-#41 branch April 23, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Fix ts-node runtime loader, it fails with TS5110 when loading typescript modules.

2 participants