Skip to content

fix(@angular/build): exclude JSON imports from Vite dependency optimization#33292

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vite-exclude-json-optimize
Open

fix(@angular/build): exclude JSON imports from Vite dependency optimization#33292
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix/vite-exclude-json-optimize

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Jun 2, 2026

Importing .json files (such as package.json files from third-party packages) causes Vite's dependency optimizer to throw errors and warnings during ng serve, as Vite is unable to optimize non-JS/TS modules:

Cannot optimize dependency: @pkg-name/package.json, present in client 'optimizeDeps.include'

This fix filters out any implicit dependencies ending in .json in the updateExternalMetadata utility, preventing them from being included in Vite's optimizeDeps.include array.

Closes #33280

…zation

Importing `.json` files (such as package.json files from third-party packages)
causes Vite's dependency optimizer to throw errors and warnings during
`ng serve`, as Vite is unable to optimize non-JS/TS modules:

`Cannot optimize dependency: @pkg-name/package.json, present in client 'optimizeDeps.include'`

This fix filters out any implicit dependencies ending in `.json` in the
`updateExternalMetadata` utility, preventing them from being included
in Vite's `optimizeDeps.include` array.

Closes angular#33280
@clydin clydin marked this pull request as ready for review June 3, 2026 01:15
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the external metadata utility in the Angular build tools to filter out .json files from both implicit server and implicit browser metadata arrays. The reviewer suggested a more robust check to handle import paths with query parameters (e.g., package.json?raw) by stripping query parameters before checking the file extension.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/angular/build/src/tools/vite/utils.ts
@clydin clydin added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot optimize dependency: @pkg-name/package.json, present in client 'optimizeDeps.include'

1 participant