fix(core): emit NodeNext .js suffixes in workspace barrel and mutator imports - #3615
Conversation
… imports orval-labs#3603 fixed NodeNext schema imports inside the split/tags writers but two emission sites still dropped the required .js suffix under module: nodenext: - The workspace index.ts barrel (write-specs.ts) built each re-export from pathWithoutExtension and never re-applied getImportExtension, so mode: 'tags-split' + output.workspace produced extensionless `export * from './pets/pets'`. - The mutator import (mutator.ts) defaulted to mutator.extension ?? '', forcing users to manually pin extension: '.js'. The barrel now derives the specifier from the full path and strips output.fileExtension once before appending the import extension, which also avoids doubling multi-part extensions (.generated.ts). The mutator now derives the suffix from the mutator file's real extension via path.extname + getImportExtension when mutator.extension is unset. Directory re-exports (operationSchemas barrel, output.schemas dir in the workspace barrel) are intentionally left as-is: they need an /index.js suffix under NodeNext, a separate transformation tracked elsewhere. Refs orval-labs#3596.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (11)
📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesNodeNext .js Extension Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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 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 |
Follow-up to #3603. Two emission sites still dropped the required
.jsimport suffix undermodule: "nodenext", reported in #3596.Changes
Workspace barrel (
packages/orval/src/write-specs.ts)mode: "tags-split"+output.workspacegenerated anindex.tsbarrel whose re-exports were built frompathWithoutExtensionwith no extension re-applied, producingexport * from './pets/pets'. The barrel now derives each specifier from the full path, stripsoutput.fileExtensiononce, and appendsgetImportExtension(...). Stripping the full extension (not just trailing.ts) also avoids doubling multi-part extensions like.generated.ts.Mutator import (
packages/core/src/generators/mutator.ts)getImportdefaulted tomutator.extension ?? '', so a relativeoverride.mutatorunder NodeNext lost its suffix unless the user manually pinnedextension: '.js'. It now threadstsconfigthrough and, whenmutator.extensionis unset, derives the suffix from the mutator file's real extension (path.extname) viagetImportExtension—.ts→.js,.mts→.mjs, etc.Intentionally not changed
Directory re-exports (
addOperationSchemasReExport, and theoutput.schemas/output.operationSchemasdirectory branches in the workspace barrel) target directories, so a bare.jssuffix would be wrong — the correct NodeNext form is/index.js, a separate transformation. These are left as-is with an explanatory NOTE onaddOperationSchemasReExport.Tests
Three new axios configs + focused assertions:
petstoreTagsSplitNodeNextWorkspace— workspace barrel under NodeNextpetstoreTagsSplitNodeNextMutator— relative mutator under NodeNext (no pinned extension)petstoreTagsSplitWorkspaceGeneratedExt— workspace barrel with.generated.ts(guards against the multi-part doubling regression caught in review)Full suite green: 5009 snapshot tests, 165 core/orval unit tests, typecheck, lint, and
typecheck-generated(16/16 clients). No existing snapshots changed.Refs #3596.
Summary by CodeRabbit
Bug Fixes
.jssuffixes for module specifiers.Tests