Skip to content

import.meta.glob searches in dist/ #1985

@brillout

Description

@brillout

Describe the bug

Similarly to #1974 (Ignore node_modules/ when running import.meta.glob), import.meta.glob searches inside dist/.

This is problematic because:

  1. First $ vite build run generates files in dist/.
  2. Second $ vite build run includes files inside dist/ of the previous build.
  3. Third $ vite build run includes files of both the second and the first build.

This leads dist/ to grow indefinitely after each vite build. This also leads to recursively growing bundle sizes.

Simply adding config.build.outDir to fast-glob's ignore is not sufficient. For example, following builds don't know each other's config.build.outDir:

  • $ vite build --ssrManifest --outDir dist/client
  • $ vite build --ssr src/entry-server.js --outDir dist/server

For the same reason, removing dist/ before $ vite build isn't a solution either.

Instead, I'm proposing the more drastic but also more powerful solution #1986 - Programmatic definition of entries (alternatively to import.meta.glob).

(The rest of the bug template is not applicable.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions