-
Notifications
You must be signed in to change notification settings - Fork 30
chore: add export maps to support native ESM #69
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
chore: add export maps to support native ESM #69
Conversation
"./core.js": { | ||
"default": "./dist/cjs/core.js" | ||
}, | ||
"./package.json": "./package.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added as it's useful to import it sometimes.
"./core.esm": { | ||
"default": "./dist/esm/core.js" | ||
}, | ||
"./core.esm.js": { | ||
"default": "./dist/esm/core.js" | ||
}, | ||
"./core.js": { | ||
"default": "./dist/cjs/core.js" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left for compat to avoid breaking changes.
36e45b9
to
ece5766
Compare
Codecov Report
@@ Coverage Diff @@
## main #69 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 243 243
Branches 45 45
=========================================
Hits 243 243 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool. I've never used the exports map before. Thanks for the help!
@all-contributors please add @layershifter for code |
@layershifter already contributed before to code |
🤦♂️ |
There was an issue with a patch release, so this manual-releases.md change is to release a new patch version. Reference: #69
🎉 This PR is included in version 1.16.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What:
Fixes #68.
Why:
We would like to use
/core
as an entrypoint in our code, currently it impossible asrtl-css-js/core
is a directory and we will getERR_UNSUPPORTED_DIR_IMPORT
from Node/bundlers 😨How:
This PR adds import maps, I initially wanted to use
import
&require
pair (see docs), but then I will have to change bundling process drastically and use something that emits.cjs
/.js
or.js
/.mjs
like tsup.Why?!
type: "module"
tells Node to have all.js
as ESM, to use CJS - use.cjs
filestype: "commonjs"
tells Node to have all.js
as CJS, to use ESM - use.mjs
filesSo, I went with another option that I have seen in Babel's packages (reference):
type
(yeah, reference sets it, but this confuses Webpack)node
(specific to Node env),import
(for bundlers) &default
Tests
Node / CJS
⬇️⬇️⬇️
Node, ESM
⬇️⬇️⬇️
Webpack
⬇️⬇️⬇️
Checklist: