Skip to content

Detect output format from Vite config, not importer format#3

Merged
biw merged 2 commits intomainfrom
biw/synthetic-exports-test
Dec 31, 2025
Merged

Detect output format from Vite config, not importer format#3
biw merged 2 commits intomainfrom
biw/synthetic-exports-test

Conversation

@biw
Copy link
Owner

@biw biw commented Dec 31, 2025

Summary

Fix module format detection to use Vite output format instead of importer format. This prevents "Cannot determine intended module format" errors when CommonJS files import native modules in ESM builds.

Changes

  • Detect output format from rollupOptions.output.format or lib.formats in Vite config
  • Generate code matching the build output format, not the importer's format
  • Revert syntheticNamedExports to true (equivalent to previous change)
  • Add comprehensive test coverage for output format detection scenarios

Test Coverage

All 162 tests pass, including new integration tests for multi-format builds.

🤖 Generated with Claude Code

biw and others added 2 commits December 30, 2025 18:09
Changes module format detection from importer-based (was it ESM or CJS?) to
output-based (what format is Vite building for?). This fixes the bug where CJS
files importing native modules in an ESM build output cause "Cannot determine
intended module format" errors. Also adds comprehensive test coverage and
documentation about multi-format build limitations.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@biw biw merged commit 9f6226e into main Dec 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant