Skip to content

meta is missing from this.getModuleInfo during rebuilds in build --watch #20591

@dominikg

Description

@dominikg

Describe the bug

according to https://rollupjs.org/plugin-development/#this-getmoduleinfo

meta itself should not be overwritten, but it is ok to mutate its properties at any time to store meta information about a module. The advantage of doing this instead of keeping state in a plugin is that meta is persisted to and restored from the cache if it is used, e.g. when using watch mode from the CLI.

so returning meta from a transform hook for an id one can expect it to be available for the remainder of build --watch running.

but if you check out the 2 plugins in this vite config https://github.com/dominikg/getmoduleinfo-build-watch-repro/blob/main/vite.config.js and follow the reproduction steps, its not the case.

discovered in sveltejs/vite-plugin-svelte#1186

possibly related:
#18914 (during dev and same id instead of different id)

Reproduction

https://github.com/dominikg/getmoduleinfo-build-watch-repro

Steps to reproduce

  • run pnpm i && pnpm build --watch
  • edit src/counter.js to add a new empty line and save
  • observe error on console

System Info

vite 7.1.1

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions