Skip to content

fix(@angular/build): fix setup files duplicate modules#31791

Closed
yjaaidi wants to merge 2 commits intoangular:mainfrom
yjaaidi:fix/fix-test-bed-usage-in-setup-files
Closed

fix(@angular/build): fix setup files duplicate modules#31791
yjaaidi wants to merge 2 commits intoangular:mainfrom
yjaaidi:fix/fix-test-bed-usage-in-setup-files

Conversation

@yjaaidi
Copy link
Copy Markdown
Contributor

@yjaaidi yjaaidi commented Nov 13, 2025

This includes setup files in the initial build and avoids lazy discovery and thus module duplicates.
Module duplicates can break many things such as dependency injection.

⚠️ this only handles setupFiles directly provided to the builder.
Handling setupFiles from the Vitest config requires substantial additional effort.

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #31732

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This includes setup files in the initial build and avoids lazy discovery and thus module duplicates.
Module duplicates can break many things such as dependency injection.

Closes angular#31732
@yjaaidi
Copy link
Copy Markdown
Contributor Author

yjaaidi commented Nov 13, 2025

I tried to keep this the less intrusive possible but I wonder if the right fix wouldn't involve changes to TestRunner API.
Feel free to either pick this a quick fix and revert it after the release for a proper fix, or just see it as a spike and throw it away 😊

* @param options Configuration options for generating entry points.
* @returns A map where keys are the generated unique bundle names and values are the original file paths.
*/
export function getSetupEntrypoints(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not happy with this.
I would rather have a single getEntrypoints that returns both test files and setup files then we would have to forward the setup file names to the executor somehow.

projectSourceRoot,
workspaceRoot,
removeTestExtension,
prefix: 'setup',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This produces bundles named setup-test-setup which is weird.
An empty string would be better but collisions could happen with a setup file called spec-setup... or something.

@hybrist hybrist requested a review from clydin November 14, 2025 17:10
@hybrist hybrist added angular/build:unit-test action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 14, 2025
@alan-agius4
Copy link
Copy Markdown
Collaborator

Closing as this original issue has been solved via #32428

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer angular/build:unit-test area: @angular/build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants