This PR is a combination of various fixes, project setup improvements, and chore/dependencies updates.
It includes some major (and possibly breaking) changes, so make sure to test it before the release. Also, please consider releasing this as a new major version (v8).
✅ ChangeLog:
Dependencies
Update all dev dependencies to the latest version
Remove unused/redundant dependencies
Regenerate yarn.lock
Docs
Update License copyright year to 2023
Fix License copyright name
Refactor
Minor code cleanup
Remove redundant isSSR check inside the useEffect hook
Cleanup examples, remove unused imports
Types
Add missing TS types
Fixed some problematic TS types
Swap any with unknown where possible
Add stricter template requirements for the useResizeDetector hook
Note about Terser and Build size
In my tests adding `terser` rollup plugin reduces the build output from ~200kb to ~56kb `(-72% reduction)` by removing
comments, and spaces, and minimizing variable names:
![image](https://user-images.githubusercontent.com/15171036/211223292-12b3c7d8-340d-4f06-b8cb-5903db447a8a.png)
But it uglifies the source code, so I'm not sure if it makes sense to keep it or not. Will probably remove it after some more
testing.
This PR is a combination of various fixes, project setup improvements, and chore/dependencies updates.
It includes some major (and possibly breaking) changes, so make sure to test it before the release. Also, please consider releasing this as a new major version (v8).
✅ ChangeLog:
Dependencies
Docs
Refactor
isSSR
check inside theuseEffect
hookTypes
any
withunknown
where possibleuseResizeDetector
hookEslint + Prettier
.vscode
prettier config.eslintrc
package.json
:prettier
- run Prettier formatting on all files,lint
- run Eslint linting on all files,lint-fix
- run Eslint linting on all files and fix all auto-fixable problems,fix
- run both Prettier + EslintRollup v3
rollup-plugin-typescript2
=>@rollup/plugin-typescript
@rollup/plugin-terser
addedrollup-plugin-node-externals
addedResizeDetectorProps
anduseResizeDetectorProps
types in the rootprepublishOnly
script⚠️ Breaking Changes:
build
folder moved to thetypes
folderwithPolyfill.d.ts
fileComponentsProps
=>ResizeDetectorProps
patchResizeHandlerType
=>PatchedResizeObserverCallback
handleWidth
andhandleHeight
are turned off,ResizeObserver
andresizeCallback
won't be createdTesting Fork
You can test this PR by installing my fork
npm i @snelsi/react-resize-detector
: https://www.npmjs.com/package/@snelsi/react-resize-detectorNote about Terser and Build size
In my tests adding `terser` rollup plugin reduces the build output from ~200kb to ~56kb `(-72% reduction)` by removing comments, and spaces, and minimizing variable names: ![image](https://user-images.githubusercontent.com/15171036/211223292-12b3c7d8-340d-4f06-b8cb-5903db447a8a.png) But it uglifies the source code, so I'm not sure if it makes sense to keep it or not. Will probably remove it after some more testing.