Skip to content

fix: detection module type from extension - #18562

Merged
Jarred-Sumner merged 3 commits into
mainfrom
chloe/module-detect-type
Mar 28, 2025
Merged

Jarred-Sumner merged 3 commits into
mainfrom
chloe/module-detect-type

Conversation

@small-angel

@small-angel small-angel commented Mar 28, 2025 •

Copy link
Copy Markdown
Contributor

Fixes #18533.

Additionally this fixes having a CJS file with ES import statement, which unregresses another 1.2.7 bug tho idk if its reported.

In 1.2.7 (specifically #18086) we regressed how Bun picks what module type a file is. The patch there did not consider file extensions. No we do this logic.

  • explicit cjs or mjs will set the module type to that module type
  • ts or js will refer to package json type (intent of the other pr)
  • tsx and jsx files use the old 1.2.6 behavior and do not refer to package.json

to see this visually, here is the drift from 1.2.6

[type field in package.json] [filename] -> [resolved module type]

CleanShot 2025-03-27 at 17 56 28@2x

for comparison, the drift from 1.2.7. notice how MJS and CJS is not respected.

CleanShot 2025-03-27 at 18 02 58@2x

@robobun

robobun commented Mar 28, 2025 •

Copy link
Copy Markdown
Collaborator
Updated 8:00 PM PT - Mar 27th, 2025

✅ @paperclover, your commit 7589a68bda4cfe8dd8ed7eab9ab31ea5f5169488 passed in Build #14118! 🎉


🧪   try this PR locally:

bunx bun-pr 18562

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.

Can't run standard on 1.2.7

3 participants