feat: full Node.js ESM runtime support #54
Merged
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.
BREAKING CHANGE: umd builds are removed and all middleware imports are moved to
get-it/middleware
. Imports such asimport promise from 'get-it/lib-node/middleware/promise'
are no longer supported. The default import is replaced with a named one: changeimport getIt from 'get-it'
toimport {getIt} from 'get-it'
Other changes
any
is out of scope for this PR but linter rules are setup to make it easier to do this refactor in a later PR.pkg.exports
.@sanity/pkg-utils
, gone is@babel/cli
,browserify
,esbuild
,uglifyjs
, and more.mocha
testing suite withvitest
to ensure the new ESM codebase runs the same way it'll run in production with codebases such assanity
.pkg.exports
are refactored to follow our updated ESM best practices, spearheaded by@sanity/pkg-utils
. It implements the Node.jsdual package hazard
technique to steer the Node.js ESM runtime back into CJS mode as half ourdependencies
aren't shipping ESM-runtime code yet.pkg.exports
and build setup is also configured to generate browser code that is picked up by modern and legacy bundlers alike. It no longer usespkg.browser
to redirect package imports, instead there'sindex.ts
andindex.browser.ts
entrypoints, andmiddleware.ts
andmiddleware.browser.ts
. These entrypoints use different imports on things that diverge depending on wether it's anode
orbrowser
runtime environment. The generated bundles are then self-contained and have much wider support than today's super-complexpkg.exports
andpkg.browser
.pkg.type
is changed fromcommonjs
tomodule
.pkg.sideEffects: false
to enable much better tree-shaking in bundlers such aswebpack
.Deno
testing suite is updated to follow current best practice for deno's node.js interop.browserslist
setup as we do in the rest of our modern ecosystem as well assanity
.@sanity/timed-out
andsimple-concat
Lock thread
workflow that locks closed issues and PRs to avoid people commenting on them as we don't get notified by that, and it's best to help nudge people towards making new issues instead.main
forgot to apply it.