Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support swc target for mjs #1081

Merged
merged 1 commit into from Feb 10, 2024
Merged

fix: support swc target for mjs #1081

merged 1 commit into from Feb 10, 2024

Conversation

haydnhkim
Copy link
Contributor

@haydnhkim haydnhkim commented Feb 3, 2024

If it is mjs, it is not included in the swcTarget even if I set it as an ES5 target.
I think the reason for the exclusion of mjs is that if the browser supports import, it is guaranteed to run ES6 or later code.
However, if you use a process like the one below, you'll run into problems.

  • generate cjs, mjs code for target: es5 with tsup and publish it as a package named foo.
  • a project named bar installs and uses the foo package. This project is set "type": "module".
  • the bar project has imported the foo package.
  • the bar project runs with ESM, it reads foo/index.mjs.
  • when we build the bar project, the foo package is in node_modules, so it won't run in older browsers unless we transpile it further.

In addition to this issue, I think it's also a problem that tsup's target is set to ES5 and it doesn't transpile as expected.
So I've included MJS as well to solve this problem.

closes #1080

Copy link

codesandbox bot commented Feb 3, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Feb 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tsup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 3, 2024 7:54am

@haydnhkim
Copy link
Contributor Author

@sxzz Could you please review this PR?

@sxzz sxzz merged commit 83c7c7f into egoist:dev Feb 10, 2024
8 checks passed
@haydnhkim
Copy link
Contributor Author

Thank you for your review!

Copy link

🎉 This PR is included in version 8.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants