Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Replace leftover modules with exports in tests #58627

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

Closed

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 13, 2024

Includes the following changes in an attempt to keep more tests working in the standalone migration:

refactor(compiler-cli): broaden type of getPotentialImportsFor

Currently the getPotentialImportsFor only accepts a ClassDeclaration as the context for generating an import, but that's not necessary because it doesn't require any class-specific information. These changes expand it to any Node so that it can be used when generating imports in testing declarations.

fix(migrations): replace removed NgModules in tests with their exports

In #57684 the standalone migration was changed so that it replaces any leftover modules with their exports, in an attempt to preserve more working code. These changes expand that logic to also cover tests since it's somewhat common internally to only import a component's module without having any references to the component.

Note that tests are a bit of a special case, because we don't have access to the template type checker, so instead we copy over all of the exports of that module.

Currently the `getPotentialImportsFor` only accepts a `ClassDeclaration` as the context for generating an import, but that's not necessary because it doesn't require any class-specific information. These changes expand it to any `Node` so that it can be used when generating imports in testing declarations.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Nov 13, 2024
@angular-robot angular-robot bot added the area: migrations Issues related to `ng update` migrations label Nov 13, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 13, 2024
@crisbeto crisbeto requested a review from devversion November 13, 2024 13:38
@crisbeto crisbeto marked this pull request as ready for review November 13, 2024 13:38
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker labels Nov 13, 2024
In angular#57684 the standalone migration was changed so that it replaces any leftover modules with their `exports`, in an attempt to preserve more working code. These changes expand that logic to also cover tests since it's somewhat common internally to only import a component's module without having any references to the component.

Note that tests are a bit of a special case, because we don't have access to the template type checker, so instead we copy over all of the `exports` of that module.
@crisbeto crisbeto force-pushed the testing-imports-standalone-copy branch from 23200bb to ba570cf Compare November 13, 2024 16:53
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Nov 13, 2024
thePunderWoman pushed a commit that referenced this pull request Nov 13, 2024
Currently the `getPotentialImportsFor` only accepts a `ClassDeclaration` as the context for generating an import, but that's not necessary because it doesn't require any class-specific information. These changes expand it to any `Node` so that it can be used when generating imports in testing declarations.

PR Close #58627
thePunderWoman pushed a commit that referenced this pull request Nov 13, 2024
#58627)

In #57684 the standalone migration was changed so that it replaces any leftover modules with their `exports`, in an attempt to preserve more working code. These changes expand that logic to also cover tests since it's somewhat common internally to only import a component's module without having any references to the component.

Note that tests are a bit of a special case, because we don't have access to the template type checker, so instead we copy over all of the `exports` of that module.

PR Close #58627
thePunderWoman pushed a commit that referenced this pull request Nov 13, 2024
#58627)

In #57684 the standalone migration was changed so that it replaces any leftover modules with their `exports`, in an attempt to preserve more working code. These changes expand that logic to also cover tests since it's somewhat common internally to only import a component's module without having any references to the component.

Note that tests are a bit of a special case, because we don't have access to the template type checker, so instead we copy over all of the `exports` of that module.

PR Close #58627
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository by commit 89256e6.

The changes were merged into the following branches: main, 19.0.x

@angular-automatic-lock-bot
Copy link

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 Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: migrations Issues related to `ng update` migrations target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants