Skip to content

feat: add esm support #55

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

Merged
merged 1 commit into from
May 24, 2022
Merged

feat: add esm support #55

merged 1 commit into from
May 24, 2022

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented May 19, 2022

Resolves #50
Resolves #36

What:

This adds support for importing this library as ESM. Therefore we are also introducing the concept of export maps as this will allow people to use esm for all things testing library.

Why:

We are increasingly growing towards ESM as a baseline so we should support both modes.

How:

We initiate two Babel runs, one resulting in ESM and one resulting in CJS.

Checklist:

  • Documentation added
  • Tests
  • Typescript definitions updated
  • Ready to be merged

@JoviDeCroock JoviDeCroock requested a review from nickserv May 19, 2022 07:34
@@ -1,6 +1,6 @@
{
"presets": [
["@babel/preset-env", { "targets": { "node": "8" } }]],
["@babel/preset-env", { "targets": { "node": "12" } }]],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is our supported version according to pkg.json

@JoviDeCroock JoviDeCroock merged commit ce46ca7 into master May 24, 2022
@github-actions
Copy link

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Comment on lines +10 to +17
"types": "./types/index.d.ts",
"import": "./dist/esm/index.js",
"browser": "./dist/cjs/index.js"
},
"./pure": {
"types": "./pure.d.ts",
"import": "./dist/esm/pure.js",
"browser": "./dist/cjs/pure.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ESM output as .js with no "type": "module"? Any reason not to support Node here?

"browser" being CJS also looks a bit odd to me, though could be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I realised a moment ago as well, we have to output these as mjs as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, apologies then!

Thanks for doing all of this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to apologize, was a very good shout, thanks 😄

@JoviDeCroock JoviDeCroock deleted the esm-support branch May 24, 2022 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ESM support Feature: Support native ESM
2 participants