Skip to content

fix(ssr): throw on missing named exports in inlined modules - #23359

Closed
bun-unsafe wants to merge 1 commit into
vitejs:mainfrom
bun-unsafe:fix/ssr-inlined-named-exports
Closed

fix(ssr): throw on missing named exports in inlined modules#23359
bun-unsafe wants to merge 1 commit into
vitejs:mainfrom
bun-unsafe:fix/ssr-inlined-named-exports

Conversation

@bun-unsafe

@bun-unsafe bun-unsafe commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • Local ESM files loaded through the module runner (ssrLoadModule / runner.import) skipped analyzeImportedModDifference. import { missing } from './file.js' therefore succeeded, while Node throws SyntaxError.
  • Externalized ESM/CJS already ran that check. This applies the same ESM check to Vite-transformed modules, using module as the type (inlined fetch results have no type).
  • Circular graphs can observe a partial exports object before evaluation finishes. Named-export checks run only after the module is complete, so existing cycle fixtures keep working.

Test plan

  • vitest run packages/vite/src/node/ssr/runtime/__tests__/server-runtime.spec.ts packages/vite/src/node/ssr/__tests__/ssrLoadModule.spec.ts
  • New fixtures: missing named export throws; existing named export still resolves
  • CI test-unit on this PR

Vite-transformed SSR modules skipped analyzeImportedModDifference, so import { missing } from a local ESM file succeeded while Node throws SyntaxError. Run the same check after the module finishes evaluating, and skip it on incomplete circular graphs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically flagged as likely to be created by a bot, LLM, or agent, and will be automatically closed. These contributions harm the maintenance of the project. Please read our AI policy for more information.

If you believe this is a mistake, please reply to this comment and we will review it.

@github-actions github-actions Bot closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant