fix(types): only strip extensions that ts retries#4297
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR refactors path extension normalization in ChangesPath Extension Stripping Refactoring
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/build/types.ts (1)
1-292: 💤 Low valueConsider future refactoring to reduce file length.
The file is now 292 lines, which exceeds the 200 LoC guideline. While this PR only adds 7 lines to an existing file, consider splitting this module in a future refactor to improve maintainability.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/build/types.ts` around lines 1 - 292, The file exceeds the 200 LoC guideline and should be split for maintainability; extract logical parts into separate modules (for example move type-file generation helpers and TS config logic into new modules) by splitting responsibilities around writeTypes (keep core orchestration here), move helper utilities relativeWithDot and stripPathsExt into a small utils/types.ts, and relocate TS config building (the tsConfig construction and related path normalization loop) into a separate buildTsConfig function in a new module that writeTypes imports and calls; ensure exported symbols and imports are updated so writeTypes, relativeWithDot, and stripPathsExt references resolve correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/build/types.ts`:
- Around line 286-288: The PATHS_STRIPPABLE_EXT_RE constant currently misses
.mts and .cts and should be updated so module resolution strips those too;
update the regex assigned to PATHS_STRIPPABLE_EXT_RE to include mts and cts
alongside ts/tsx/jsx/[cm]js (so it matches .ts .tsx .mts .cts .jsx .cjs .mjs) so
path normalization behaves like TypeScript's moduleNameResolver retry logic.
---
Nitpick comments:
In `@src/build/types.ts`:
- Around line 1-292: The file exceeds the 200 LoC guideline and should be split
for maintainability; extract logical parts into separate modules (for example
move type-file generation helpers and TS config logic into new modules) by
splitting responsibilities around writeTypes (keep core orchestration here),
move helper utilities relativeWithDot and stripPathsExt into a small
utils/types.ts, and relocate TS config building (the tsConfig construction and
related path normalization loop) into a separate buildTsConfig function in a new
module that writeTypes imports and calls; ensure exported symbols and imports
are updated so writeTypes, relativeWithDot, and stripPathsExt references resolve
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
🔗 Linked issue
❓ Type of change
📚 Description
spotted this when testing nuxt v5. this also needs to be fixed in nuxt, and is very weird. I was not aware of this behaviour, but here's what it looks like:
https://stackblitz.com/edit/node-4mtandbr?file=tsconfig.json,index.ts
📝 Checklist