-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: ESM support #25
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rexxars
approved these changes
Sep 14, 2022
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.
Wow. That's a huge amount of work - thank you!
Let's make sure to release this as a major version just in case?
Yeah let's err on the side of caution |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Can be tested using
npm i get-it@esm
.There's also a
@sanity/client@esm
that lets you try it out.Changelog:
--dry-run
flag for until it's run on main and we've verified it's good to go..cjs
and a.mjs
file. Uses Node 18's new built-in test runner to ensure the testing env doesn't handle pkg.exports differently than native node ESM.-C browser
to test pkg exports when thebrowser
conditional is active, just to catch easy mistakes like typos.browser
anddeno
that's native ESM.get-it
as it is today.--platform=browser
mode to applypkg.browser
mappings to ensure minimal changes to existing code is required, and greatly reducing the risk of regression bugs.type: commonjs
instead oftype: module
for the same reason, to avoid introducing breaking changes in systems that currently work withget-it
but would break if we started moving around files. By usingtype: commonjs
and.mjs
file extensions we ensure every flavor of Node.js keep working.Why both
deno
andbrowser
conditions? Because deno doesn't supportbrowser
when it's in compat mode: https://client-runtimes-dashboard.sanity.build/#:~:text=deno%2C%20import%2C%20node%2C%20node.deno%2C%20node.importThe list over supported ESM browser/deno/worker mode exports is based on looking at how
get-it
is commonly imported: