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

Export both esm and cjs #42

Merged
merged 3 commits into from
Jan 21, 2022
Merged

Export both esm and cjs #42

merged 3 commits into from
Jan 21, 2022

Conversation

dgreif
Copy link
Member

@dgreif dgreif commented Jan 20, 2022

Alternate approach to #39 using tsc instead of babel. This allows consumers of the package to use either CommonJS or ESM.

@changeset-bot
Copy link

changeset-bot bot commented Jan 20, 2022

🦋 Changeset detected

Latest commit: a58db56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/behaviors Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"./utils": {
"types": "./dist/utils/index.d.ts",
"require": "./dist/cjs/utils/index.js",
"module": "./dist/esm/utils/index.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw there were many options we can provide here including import, default, node. How did you choose these two?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to remember where exactly I pulled these from, but there are many sources that don't all give the same keys. https://nodejs.org/api/packages.html#conditional-exports is a good source, and it lines up more with the values you gave. We should probably switch to node and default

@pksjce
Copy link
Contributor

pksjce commented Jan 21, 2022

I tested the published canary package and it works so well. Thanks so much for your help!

@pksjce pksjce merged commit 03fea81 into main Jan 21, 2022
@pksjce pksjce deleted the esm-and-cjs-with-tsc branch January 21, 2022 04:30
@primer-css primer-css mentioned this pull request Jan 21, 2022
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.

2 participants