Skip to content
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

Rollup-Incompatible getModuleInfo behavior #18914

Open
7 tasks done
ef4 opened this issue Dec 8, 2024 · 0 comments
Open
7 tasks done

Rollup-Incompatible getModuleInfo behavior #18914

ef4 opened this issue Dec 8, 2024 · 0 comments
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) rollup plugin compat

Comments

@ef4
Copy link

ef4 commented Dec 8, 2024

Describe the bug

This tiny plugin always succeeds in rollup (and vite build) and always fails in vite dev:

{
  name: 'example",
  load(id) {
    if (!this.getModuleInfo(id)) {
      throw new Error(`load should always see module info`);
    }
  },
}

Rollup promises to construct moduleInfo synchronously when any load is first started, and even shows an example of calling this.load({ id }) and not awaiting the promise as a way to force this.getModuleInfo(id).meta to exist.

I think this disconnect is at the root of issues like #6766.

From some commentary on a related PR it sounds like it's a goal for Vite's module graph to not contain modules that haven't finished loading yet, but if that is true getModuleInfo needs to be driven at least partly from a different source of truth that does have entries for not-yet-loaded modules.

Reproduction

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

Steps to reproduce

See reproduction URL and description above.

System Info

vite/6.0.3 linux-x64 node-v18.20.3

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red sapphi-red added rollup plugin compat p3-minor-bug An edge case that only affects very specific usage (priority) labels Dec 9, 2024
@sapphi-red sapphi-red added pending triage p2-edge-case Bug, but has workaround or limited in scope (priority) and removed p3-minor-bug An edge case that only affects very specific usage (priority) labels Dec 9, 2024
ef4 added a commit to embroider-build/embroider that referenced this issue Dec 9, 2024
Vite's own meta is unreliable due to vitejs/vite#18914
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) rollup plugin compat
Projects
None yet
Development

No branches or pull requests

2 participants