Skip to content

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

Open
bun-unsafe wants to merge 5 commits into
vitejs:mainfrom
bun-unsafe:fix/ssr-inlined-named-export-check
Open

fix(ssr): throw on missing named exports in inlined modules#23360
bun-unsafe wants to merge 5 commits into
vitejs:mainfrom
bun-unsafe:fix/ssr-inlined-named-export-check

Conversation

@bun-unsafe

Copy link
Copy Markdown

ssrLoadModule and the module runner accept import { missing } from a local ESM file. Node throws SyntaxError for the same graph.

I compared Node import() with Vite SSR on the same files. External packages already go through analyzeImportedModDifference. Inlined modules did not: processImport returned early, and inlined fetch results have no type.

This runs that ESM check after the imported module has finished evaluating, with type module. Circular graphs can observe a partial exports object, so the check is skipped until evaluation finishes.

Tests: server-runtime.spec.ts fixtures esm-internal-non-existing.js and esm-internal-existing.js.

xiachao added 2 commits August 25, 2026 18:12
Vite-transformed SSR modules skipped analyzeImportedModDifference.
A missing named import from a local ESM file succeeded, while Node throws SyntaxError.
Run the same ESM check after the module finishes evaluating; skip it on incomplete circular graphs.
Vite-transformed SSR modules skipped analyzeImportedModDifference.
A missing named import from a local ESM file succeeded, while Node throws SyntaxError.
Run the same ESM check after the module finishes evaluating; skip it on incomplete circular graphs.
@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
@bun-unsafe
bun-unsafe deleted the fix/ssr-inlined-named-export-check branch August 25, 2026 10:28
@bun-unsafe

Copy link
Copy Markdown
Author

This is a bugfix, not a feature.

Node throws SyntaxError for import { missing } from a local ESM file. Vite's module runner / ssrLoadModule did not, because inlined modules skipped analyzeImportedModDifference (external packages already used that check).

The patch runs the same ESM check after the module has finished evaluating, and skips it on incomplete circular graphs so existing cycle tests stay valid. Tests are in server-runtime.spec.ts with the new fixtures.

Please review the diff. If the bot misfired, could a maintainer apply bot: skip and reopen?

@bluwy

bluwy commented Aug 26, 2026

Copy link
Copy Markdown
Member

Is this fixing a specific issue, or one you encountered yourself?

@bun-unsafe

Copy link
Copy Markdown
Author

No existing GitHub issue. I hit this myself.

I compared Node import() with Vite ssrLoadModule on the same local ESM files: Node throws SyntaxError for a missing named export; Vite did not. I did not find an open issue for that gap, so I sent the fix with tests.

Happy to open an issue for tracking if you prefer.

@bun-unsafe
bun-unsafe restored the fix/ssr-inlined-named-export-check branch August 26, 2026 06:11
@bluwy bluwy added bot: skip Skip AgentScan analysis and removed bot: likely Likely a bot, LLM, or agent. Automatically comments and closes the issue or PR labels Aug 26, 2026
@bluwy bluwy reopened this Aug 26, 2026
@bun-unsafe

Copy link
Copy Markdown
Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: skip Skip AgentScan analysis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants