Skip to content
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

fix(@angular/build): remove Vite "/@id/" prefix for explicit external dependencies #28039

Merged

Conversation

kfrederix
Copy link
Contributor

@kfrederix kfrederix commented Jul 11, 2024

This PR adds a Vite plugin to remove the /@id/ prefix (which gets inserted by Vite during import-analysis) for explicit externalDependencies.

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: #28028

What is the new behavior?

The /@id/ prefix gets removed from a new Vite plugin.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kfrederix kfrederix force-pushed the bug/28028_external_dependencies_id_prefix branch from 0d14195 to 6feabeb Compare July 12, 2024 08:44
Copy link
Member

@clydin clydin left a comment

Choose a reason for hiding this comment

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

This approach appears viable as a workaround.
I left several initial comments.
There is the potential for a false positive replacement. However, the likelihood is very low and would only occur if externalDependencies is used which is not overly common in its own. So I think that is acceptable as a (hopefully) temporary workaround.

packages/angular/build/src/tools/vite/id-prefix-plugin.ts Outdated Show resolved Hide resolved
packages/angular/build/src/tools/vite/id-prefix-plugin.ts Outdated Show resolved Hide resolved
Copy link
Member

@clydin clydin left a comment

Choose a reason for hiding this comment

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

This approach appears viable as a workaround.
I left several initial comments.
There is the potential for a false positive replacement. However, the likelihood is very low and would only occur if externalDependencies is used which is not overly common in its own. So I think that is acceptable as a (hopefully) temporary workaround.

@clydin clydin linked an issue Jul 13, 2024 that may be closed by this pull request
1 task
@kfrederix kfrederix force-pushed the bug/28028_external_dependencies_id_prefix branch from 6feabeb to 9ddef76 Compare July 13, 2024 10:12
@kfrederix
Copy link
Contributor Author

Also added a test now. Let me know if you have more suggestions or concerns.

Copy link
Member

@clydin clydin left a comment

Choose a reason for hiding this comment

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

Just one comment otherwise LGTM.

Thank you for the contribution.

packages/angular/build/src/tools/vite/id-prefix-plugin.ts Outdated Show resolved Hide resolved
@kfrederix kfrederix force-pushed the bug/28028_external_dependencies_id_prefix branch from 9ddef76 to 5d2320e Compare July 14, 2024 06:52
… dependencies

Adds a Vite plugin which will remove the /@id/ prefix (which gets inserted by Vite during import-analysis) for explicit externalDependencies.
@kfrederix kfrederix force-pushed the bug/28028_external_dependencies_id_prefix branch from 5d2320e to 9212c77 Compare July 14, 2024 07:00
@kfrederix
Copy link
Contributor Author

Thank you for the fast reviews!

@clydin clydin added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Jul 14, 2024
@dgp1130 dgp1130 merged commit 394f9ce into angular:main Jul 15, 2024
32 checks passed
@dgp1130
Copy link
Collaborator

dgp1130 commented Jul 15, 2024

The changes were merged into the following branches: main, 18.1.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 Aug 15, 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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

externalDependencies not working as expected during serve with Vite
4 participants