Repository navigation
Commit 3941818
fix: preserve Bundler on the CJS path under TypeScript >= 6
Follow-up to #5280, which closed #4198 but deliberately scoped out this
scenario to keep its change tied to a single release line. The present
change picks it up now that the TS 6 relaxation can be honored via a
runtime version check.
TypeScript 6 relaxed TS5095 to allow `module: CommonJS` paired with
`moduleResolution: bundler`, but `isBundlerCompatibleModuleKind` still
treated CommonJS as Bundler-incompatible across the entire peerDependency
range, so user-set Bundler was silently substituted to Node10 on the CJS
path even on TS 6+.
Detect the TypeScript major version at runtime via `this._ts.version` and
treat CommonJS as Bundler-compatible when the version is >= 6. Other non-ES
module kinds (AMD / UMD / System / None) remain Bundler-incompatible on
every TypeScript version, matching TypeScript's own rules.
Side effect: on TS >= 6, user-supplied Node16/NodeNext on the CJS path now
substitutes to Bundler (mirroring the existing ESM-path substitution) rather
than to Node10. Bundler is the closer semantic match for users who
explicitly chose Node-aware resolution, and the pair is valid under TS 6.
TSDoc on `resolveCompatibleModuleResolution` and `isBundlerCompatibleModuleKind`
updated to reflect the new behavior. The inline TS < 6 test block keeps its
existing assertions (still correct on the dev TypeScript 5.9.3) and gains a
sibling TS >= 6 block that simulates the TS 6 runtime via a `version`-proxied
ts module. Validated end-to-end against real TypeScript 6.0.3 via a smoke
test running through the built ts-jest dist.
Refs #41981 parent efb3c2f commit 3941818
2 files changed
Lines changed: 72 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | | - | |
552 | | - | |
| 551 | + | |
| 552 | + | |
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
| 560 | + | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
| |||
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
595 | 645 | | |
596 | 646 | | |
597 | 647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
301 | 300 | | |
302 | 301 | | |
303 | 302 | | |
| |||
313 | 312 | | |
314 | 313 | | |
315 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
316 | 322 | | |
317 | 323 | | |
318 | 324 | | |
| |||
0 commit comments