Skip to content

optimizeDeps.include glob should ignore null exports #22586

Description

@simonihmig

Describe the bug

When using the "experimental" feature to use globs in optimizeDeps.include, it will expand all matching export paths based on package.json exports. However, it will also expand keys that have a null value. null can be used to declare private modules though:

To exclude private subfolders from patterns, null targets can be used:

So these keys should be explicitly ignored, not expanded.

I have a local patch working on my machine, will work on a proper upstream PR next!

Reproduction

https://stackblitz.com/edit/vitejs-vite-pvd2ygpz?file=vite.config.js

Steps to reproduce

Build error triggers immediately after opening stackblitz (pnpm install && pnpm run dev)

System Info

System:
    OS: macOS 26.2
    CPU: (8) arm64 Apple M2
    Memory: 99.75 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.16.0 - /Users/simonihmig/.volta/tools/image/node/24.16.0/bin/node
    Yarn: 1.22.19 - /Users/simonihmig/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 11.13.0 - /Users/simonihmig/.volta/tools/image/node/24.16.0/bin/npm
    pnpm: 10.15.0 - /Users/simonihmig/.volta/tools/image/pnpm/10.15.0/bin/pnpm
  Browsers:
    Safari: 26.2

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerDependencies Optimizationp2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions