-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fix(typescript-fetch): remove barrel imports #22706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6 issues found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache:7">
P2: Per-API saga import omits `{{importFileExtension}}`, breaking ESM extension handling used elsewhere in the generator.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache:7">
P1: Hard-coded saga import path "./classFilename" produces invalid imports; should reference the per-API saga file</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache:17">
P2: Per-model model import omits `{{importFileExtension}}`, producing extensionless paths that can break ESM/NodeNext consumers.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache:17">
P1: Saga template now imports model files by class name, ignoring configured/sanitized filenames, breaking imports for non-default model file naming</violation>
<violation number="3" location="modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache:23">
P2: Passthrough model import drops `{{importFileExtension}}`, leading to extensionless imports that can fail under ESM/NodeNext.</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache:10">
P2: Per-model imports omit configurable `{{importFileExtension}}`, breaking ESM builds requiring explicit extensions (.js)</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/allSagas.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/sagas.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="modules/openapi-generator/src/main/resources/typescript-fetch/sagaApiManager.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-fetch/sagaApiManager.mustache:4">
P2: Missing `{{importFileExtension}}` in runtime import breaks ESM extension resolution</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/typescript-fetch/sagaApiManager.mustache:10">
P2: Missing `{{importFileExtension}}` in per-API imports causes ESM resolution failures</violation>
</file>
<file name="modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesRecord.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesRecord.mustache:8">
P2: Generated import uses `{{classname}}` instead of `{{classFilename}}`, breaking paths when filenames differ</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
modules/openapi-generator/src/main/resources/typescript-fetch/sagaApiManager.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/sagaApiManager.mustache
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/typescript-fetch/ApiEntitiesRecord.mustache
Show resolved
Hide resolved
|
/cc Typescript committee members (@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha) |
Removing barrel exports significantly improves performance in situation where tree shaking is not possible. EG testing via jest. See #12081
Barrel exports are files that import and export a group of files. EG models/index.ts
This does not remove the index files. It just removes the internal dependency on them.
To verify, just make sure all the new imports point to a file that:
Fixes #12081
Main credit goes to @orrin-naylor-instacart for the initial PR, I have just rebased against latest master
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Remove barrel imports from the TypeScript Fetch generator and switch to per-file model imports to improve performance where tree shaking isn’t available (e.g., Jest). Index files remain but are no longer used internally. Fixes #12081.
Written for commit a991213. Summary will update on new commits.