Skip to content

fix: treat all optimizeDeps.entries values as globs #20045

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jamesopstad
Copy link
Contributor

Description

This fixes an issue introduced in #15853 that meant globs containing \\ could be treated as literals rather than globs. This would then lead the filesystem check here -

fs.existsSync(entry),
- to fail because the path would include \. It also improves upon the previous approach because entries explicitly including node_modules can now be used alongside other glob entries.

These changes mean that explicitly passing entries containing the environment's build output directory no longer work. It's not clear why this feature was introduced but if it would be considered breaking to remove it then I can add in the extra handling.

@jamesopstad jamesopstad changed the title Treat all optimizeDeps.entries as globs Treat all optimizeDeps.entries values as globs May 15, 2025
@jamesopstad jamesopstad changed the title Treat all optimizeDeps.entries values as globs fix: treat all optimizeDeps.entries values as globs May 15, 2025
@Jinjiang
Copy link
Contributor

For more information, I've created a reproduction of #15853 originally trying to solve:
https://github.com/Jinjiang/reproductions/tree/vite-entries-in-node_modules-20250516

From what I've tested it works as expected.

Thanks.

@sapphi-red sapphi-red added p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) feat: deps optimizer Esbuild Dependencies Optimization breaking change labels May 20, 2025
@github-project-automation github-project-automation bot moved this to Discussing in Team Board May 20, 2025
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

optimizeDeps.entries: ['**/node_modules/foo/**', '!**/bar/**'] will match /project/node_modules/foo/bar/somefile.js, but probably not a big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change feat: deps optimizer Esbuild Dependencies Optimization p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
Status: Discussing
Development

Successfully merging this pull request may close these issues.

3 participants