Skip to content

fix(config): preserve rewriteRelativeImportExtensions setting#5213

Merged
kulshekhar merged 2 commits intokulshekhar:mainfrom
SergioChan:fix-issue-5196-rewrite-relative-import-extensions
Mar 8, 2026
Merged

fix(config): preserve rewriteRelativeImportExtensions setting#5213
kulshekhar merged 2 commits intokulshekhar:mainfrom
SergioChan:fix-issue-5196-rewrite-relative-import-extensions

Conversation

@SergioChan
Copy link
Contributor

@SergioChan SergioChan commented Mar 7, 2026

Summary

  • stops ts-jest from forcibly overriding rewriteRelativeImportExtensions to false in ConfigSet compiler overrides
  • preserves user/compiler behavior so ESM setups using .mts imports are not rewritten into TS5097 failures
  • updates the config-set spec to assert this option is no longer forced off

Fixes #5196

Test plan

  • npx jest -c=jest.config.ts src/legacy/config/config-set.spec.ts -t "preserve rewriteRelativeImportExtensions"
  • Result: 1 passed, 0 failed

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • Change is intentionally minimal and scoped to compiler option overrides used by ts-jest transpilation.

Summary by CodeRabbit

  • Bug Fixes

    • Preserve user-provided rewriteRelativeImportExtensions compiler setting instead of forcing it to false, so user config is respected during builds.
  • Tests

    • Updated tests to assert preservation of the rewriteRelativeImportExtensions setting and to validate related compiler option behaviors.

@SergioChan SergioChan requested a review from kulshekhar as a code owner March 7, 2026 18:22
@coderabbitai
Copy link

coderabbitai bot commented Mar 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c5931509-2ffa-4a93-b972-50be4d070555

📥 Commits

Reviewing files that changed from the base of the PR and between 2fe6a37 and 628bd61.

📒 Files selected for processing (2)
  • src/legacy/config/config-set.spec.ts
  • src/legacy/config/config-set.ts
💤 Files with no reviewable changes (1)
  • src/legacy/config/config-set.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/legacy/config/config-set.spec.ts

📝 Walkthrough

Walkthrough

Removed the forced override that set rewriteRelativeImportExtensions to false and updated tests to assert that a true value from tsconfig is preserved after parsing rather than being reset.

Changes

Cohort / File(s) Summary
Config Override Adjustment
src/legacy/config/config-set.ts
Removed the explicit rewriteRelativeImportExtensions: false override from _overriddenCompilerOptions, allowing the option to remain undefined so user tsconfig values are preserved.
Test Verification
src/legacy/config/config-set.spec.ts
Renamed/updated test to assert parsed options are stored locally and that rewriteRelativeImportExtensions: true from tsconfig is preserved; other compiler option expectations adjusted accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A nibble here, a careful mend,
I stopped forcing rules to bend,
Let configs whisper what is true,
Small hop forward, skies more blue,
Happy builds and tests anew! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(config): preserve rewriteRelativeImportExtensions setting' directly and accurately describes the main change: removing the forced override of rewriteRelativeImportExtensions to false, allowing the option to be preserved as configured.
Linked Issues check ✅ Passed The PR successfully addresses issue #5196 by removing the rewriteRelativeImportExtensions: false override in ConfigSet, preserving user-configured settings and allowing ESM .mts imports to work without TS5097 errors.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective: removing the rewriteRelativeImportExtensions override from config-set.ts and updating the corresponding test to verify preservation behavior. No unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/legacy/config/config-set.spec.ts`:
- Around line 71-98: The test in src/legacy/config/config-set.spec.ts is too
weak: after calling getParsedTsconfig(...) and extracting options, the assertion
expect(options.rewriteRelativeImportExtensions).not.toBe(false) can pass if the
property is missing; change it to assert the actual preserved value by using
expect(options.rewriteRelativeImportExtensions).toBe(true) so the test verifies
that rewriteRelativeImportExtensions set to true in the input remains true in
the parsed options (reference getParsedTsconfig and the options object).

In `@src/legacy/config/config-set.ts`:
- Around line 180-181: Current code leaves rewriteRelativeImportExtensions:
undefined inside _overriddenCompilerOptions which still overrides and clears a
user-supplied true; remove the rewriteRelativeImportExtensions entry entirely
from the _overriddenCompilerOptions object in config-set (do not set it to
undefined) so the user tsconfig value is preserved, and ensure the code path
that prunes compiler options (the block that deletes options with forced
undefined) is relied on instead of keeping this key.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a9e29cb-289c-4c34-aace-a779fc415dae

📥 Commits

Reviewing files that changed from the base of the PR and between fbac3d0 and 2fe6a37.

📒 Files selected for processing (2)
  • src/legacy/config/config-set.spec.ts
  • src/legacy/config/config-set.ts

@SergioChan
Copy link
Contributor Author

Thanks for the review — I applied both suggestions:\n\n- removed the key from (instead of setting it to )\n- tightened the test assertion to so it verifies preservation explicitly\n\nValidation run:\n- ✅

@SergioChan
Copy link
Contributor Author

Thanks for the review — addressed both actionable points in 628bd61:

  • removed rewriteRelativeImportExtensions from _overriddenCompilerOptions entirely (no undefined key left)
  • strengthened the regression test to assert rewriteRelativeImportExtensions is preserved as true

Validation run:

  • npx jest -c=jest.config.ts src/legacy/config/config-set.spec.ts -t "preserve rewriteRelativeImportExtensions" (pass)

@kulshekhar kulshekhar merged commit 5fa2592 into kulshekhar:main Mar 8, 2026
19 of 20 checks passed
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.

[Bug]: rewriteRelativeImportExtensions is always overriden to false

2 participants