Skip to content

compileScript drops template imports from __returned__ when analysis re-runs on a transformed template AST #15126

Closed

Description

@freb97

Vue version

3.5.40

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-evwepvbu?file=package.json

Steps to reproduce

Compile more than 500 unique SFCs for client + SSR (non-inline mode), share each file's descriptor between the two passes (the same way @vitejs/plugin-vue does). The client pass compileTemplate changes the shared template.ast in place, when the analysis cache (capped at 500) evicts a file entry, its SSR compileScript pass re-runs the import usage analysis on that already transformed AST

What is expected?

__returned__ contains every import the template references, same output as when fewer than 500 templates are compiled. The analysis should re-parse when the AST was already transformed, the same guard compileTemplate has with if (inAST?.transformed) in line 214.

What is actually happening?

Imports referenced only from template expressions or with v-for are dropped from __returned__. While the render function still emits $setup.foo(...) and throws TypeError: $setup.foo is not a function at runtime. Because it only happens with more than 500 unique templates it only comes up in large apps in development, in production builds the template are inlined and are unaffected.

System Info

Any additional comments?

Might be the cause for vitejs/vite-plugin-vue#764, vitest-dev/vitest#9855?

Activity

  1. added
    🔨 p3-minor-bug
    on Jul 21, 2026
  2. added a commit that references this issue on Aug 4, 2026
    a4440c0
  3. locked and limited conversation to collaborators on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugscope: sfc

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions