-
Notifications
You must be signed in to change notification settings - Fork 92
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
[BREAKING] switch package to module type #1472
Conversation
BREAKING CHANGE: the package is of ESM type now (`"type": "module"`). Distributed code compiled with `ESNext` target. `cjs` and `esm` folders are not existent anymore.
BREAKING CHANGE: all hooks now can be imported several different ways that will lead to same result: - `import { useFirstMountState } from '@react-hookz/web';` - `import { useFirstMountState } from '@react-hookz/web/';` - `import { useFirstMountState } from '@react-hookz/web/useFirstMountState/';` - `import { useFirstMountState } from '@react-hookz/web/useFirstMountState/index.js';`
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1472 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 62 62
Lines 1072 1074 +2
Branches 169 171 +2
=======================================
+ Hits 1068 1070 +2
Misses 2 2
Partials 2 2 ☔ View full report in Codecov by Sentry. |
# [24.0.0](v23.1.0...v24.0.0) (2023-12-20) ### Features * switch package to module type ([#1472](#1472)) ([50921ef](50921ef)) ### BREAKING CHANGES * Hooks are now distrubutes as JS built form TS with target ESNext and ESM module resolution. There is no more sense to distribute CJS version as package is ESM-only. Consequent of above - no more esm and cjs subfolders - hooks are importable from index.js or its own directory which don't have a prefix anymore, thanks to exports directive. All of below examples will lead to same result, choose any on your taste: import { useFirstMountState } from '@react-hookz/web'; import { useFirstMountState } from '@react-hookz/web/'; import { useFirstMountState } from '@react-hookz/web/useFirstMountState/'; import { useFirstMountState } from '@react-hookz/web/useFirstMountState/index.js'; Thought is seems not to have subfolder, it is only due to exports directive, in real it is @react-hookz/web/dist/useFirstMountState/index.js. Pakage uses imports directive to define path alias #root - it stays so even in distributed code, thus, some may be affected in case their bundler configured to somehow handle such alias. Those developer shoud configure import rewriter not to handle node_modules or @react-hookz/web package exclusively. Side-effect for current PR - documentation is broken, as storybook 6 is not working within ESM packages and I'm planning to switch to another domenting engine anyway.
🎉 This PR is included in version 24.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
"engines": { | ||
"node": ">=20.0.0" | ||
}, |
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.
what's the rationale behind requiring node 20+ now? node 18 is still in LTS and will be in widespread use
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.
No particular reason except lockfile differs if being built with 18 and 20 versions.
As i understand it forces users to have node20+ - ill lower requirement to node18 (as it is lowest for ESM packages)
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.
As i understand it forces users to have node20+
yes this is the trouble we are having while trying to upgrade
ill lower requirement to node18
much appreciated, thank you!
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.
24.0.2
is live
As part of migration to react 18 and docosaurus - i made a decision to switch package to
"type": "module"
.By itself it leads to following BREAKING CHANGES:
Hooks are now distrubutes as JS built form TS with target
ESNext
and ESM module resolution. There is no more sense to distribute CJS version as package is ESM-only.Consequent of above - no more
esm
andcjs
subfolders - hooks are importable fromindex.js
or its own directory which don't have a prefix anymore, thanks toexports
directive. All of below examples will lead to same result, choose any on your taste:import { useFirstMountState } from '@react-hookz/web';
import { useFirstMountState } from '@react-hookz/web/';
import { useFirstMountState } from '@react-hookz/web/useFirstMountState/';
import { useFirstMountState } from '@react-hookz/web/useFirstMountState/index.js';
Thought is seems not to have subfolder, it is only due to
exports
directive, in real it is@react-hookz/web/dist/useFirstMountState/index.js
.Pakage uses
imports
directive to define path alias#root
- it stays so even in distributed code, thus, some may be affected in case their bundler configured to somehow handle such alias. Those developer shoud configure import rewriter not to handlenode_modules
or@react-hookz/web
package exclusively.Side-effect for current PR - documentation is broken, as storybook 6 is not working within ESM packages and Im planning to switch to docosaurus anyways.