Skip to content

Conversation

@celluj34
Copy link

@celluj34 celluj34 commented Jan 15, 2026

All text copied from #12236

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:

  1. Exists
  2. Contains the item being imported

Fixes #12081
Main credit goes to @orrin-naylor-instacart for the initial PR, I have just rebased against latest master

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

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.

  • Refactors
    • Replace models/index imports with per-file imports in ApiEntitiesRecord, apis, sagas, allSagas, and sagaApiManager; add explicit file extensions and correct model vs record paths.
    • Point runtime and saga imports to specific files instead of barrels.
    • No behavior changes to generated APIs or types.

Written for commit a991213. Summary will update on new commits.

@celluj34 celluj34 marked this pull request as ready for review January 15, 2026 18:30
Copy link

@cubic-dev-ai cubic-dev-ai bot left a 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.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a 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.

@celluj34
Copy link
Author

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.

[typescript-fetch] Remove barrel imports

2 participants