Skip to content

Commit b928077

Browse files
authored
Merge pull request #167 from xnimorz/yarn_to_npm
Update packages for the lib
2 parents 667618b + 3dfaf50 commit b928077

19 files changed

+13473
-10908
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"extends": ["plugin:@typescript-eslint/recommended", "prettier/@typescript-eslint", "plugin:prettier/recommended"],
3+
"extends": [
4+
"plugin:@typescript-eslint/recommended",
5+
"prettier",
6+
"plugin:prettier/recommended"
7+
],
48
"parserOptions": {
59
"ecmaVersion": 2018,
610
"sourceType": "module"

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v1
17-
- name: Use Node.js 16.x
17+
- name: Use Node.js 21.x
1818
uses: actions/setup-node@v1
1919
with:
20-
node-version: 16.x
20+
node-version: 21.x
2121
- name: install and tests
2222
run: |
23-
yarn install
24-
yarn test
25-
yarn size
23+
npm install
24+
npm run test
25+
npm run size
2626
env:
2727
CI: true

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"printWidth": 120,
2+
"printWidth": 80,
33
"tabWidth": 2,
44
"singleQuote": true,
55
"trailingComma": "es5",

CHANGELOG.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,59 @@
1+
## 10.0.0
2+
3+
- _Major breaking change_: replaced `index.modern.js` with `index.mjs`. Might require a little change in your build pipeline
4+
- _Major breaking change_: New option `debounceOnServer`: if you put the option to true, it will run debouncing on server (via `setTimeout`). The new option can break your current server behaviour, as v9.x, it runs all the time and might cause unnessesary server CPU utilisation. Now, by default, debounced callbacks do not happen on server.
5+
- _Minor breaking change_: Replaced `useState` for `useDebounce` with `useReducer`. It might lead to reduced amount of re-renders, as useState is known to have excess re-renders in some corner: https://stackoverflow.com/questions/57652176/react-hooks-usestate-setvalue-still-rerender-one-more-time-when-value-is-equal
6+
- _Minor breaking change_: `useDebouncedCallback` now updates function to call asap. Meaning, if you re-called the hook and it should trigger immediately, it will trigger the newest function all the time.
7+
- Lib size:
8+
914 B: index.js.gz
9+
851 B: index.js.br
10+
883 B: index.mjs.gz
11+
826 B: index.mjs.br
12+
938 B: index.module.js.gz
13+
873 B: index.module.js.br
14+
989 B: index.umd.js.gz
15+
919 B: index.umd.js.br
16+
- [Internal] Replaced Enzyme with @testing-library
17+
- [Internal] yarn classic => npm
18+
- [Internal] Updated devDependencies
19+
120
## 9.0.4
21+
222
- Tweak exports, see [PR](https://github.com/xnimorz/use-debounce/pull/160), thanks to [@Andarist](https://github.com/Andarist)
323
- Changed types, see [PR](https://github.com/xnimorz/use-debounce/pull/158), thanks to [@wangcch](https://github.com/wangcch)
424

525
## 9.0.3
26+
627
- Represent correct return type from useDebounce(), see [issue](https://github.com/xnimorz/use-debounce/pull/155), thanks to [@appden](https://github.com/appden)
728

829
## 9.0.2
30+
931
- Reverted 9.0.0. We will revisit these changes later
1032

1133
## 9.0.0
34+
1235
- Moved use-debounce to support modules see [issue](https://github.com/xnimorz/use-debounce/issues/147) Thanks to [@matewilk](https://github.com/matewilk)
1336
- _breaking change_ The path to `dist/index.js` is changed. Now it's `dist/index.cjs`.
1437

1538
## 8.0.4
39+
1640
- Changes types for `useDebouncedCallback` args: https://github.com/xnimorz/use-debounce/pull/140 Thanks to [@sarunast](https://github.com/sarunast)
1741

1842
## 8.0.3
43+
1944
- Added `types` to package json to mitigate https://github.com/microsoft/TypeScript/issues/49160. https://github.com/xnimorz/use-debounce/pull/138 Thanks to [@wuzzeb](https://github.com/wuzzeb)
2045

2146
## 8.0.2
47+
2248
- Added type exports. https://github.com/xnimorz/use-debounce/pull/136 Thanks to [@tryggvigy](https://github.com/tryggvigy)
2349
- Improved code comments. https://github.com/xnimorz/use-debounce/pull/135 Thanks to [@tryggvigy](https://github.com/tryggvigy)
2450

2551
## 8.0.1
52+
2653
- update library exports section to make exports work correctly with jest@28
2754

2855
## 8.0.0
56+
2957
- _breaking change_ `useDebounce` changed its build system to microbundle. For now we have several entries:
3058

3159
`index.js` is for commonJS approach
@@ -36,10 +64,13 @@ All the files are in `dist` folder.
3664
If you have any paths which have `esm` or `lib`, please, replace them to `dist`:
3765

3866
Before:
67+
3968
```js
40-
import useDebounceCallback from 'use-debounce/lib/useDebounceCallback'
69+
import useDebounceCallback from 'use-debounce/lib/useDebounceCallback';
4170
```
71+
4272
After:
73+
4374
```js
4475
import { useDebounceCallback } from 'use-debounce';
4576
```
@@ -49,10 +80,12 @@ import { useDebounceCallback } from 'use-debounce';
4980
- Fixed issue with `leading: true` https://github.com/xnimorz/use-debounce/issues/124 Thanks to [@mntnoe](https://github.com/mntnoe) for reporting
5081

5182
## 7.0.1
83+
5284
- `debounced` object now is preserved for `use-debounce` between the renders. Thanks to [@msharifi99](https://github.com/msharifi99) for reporting.
5385

5486
## 7.0.0
55-
- _breaking change_ `useDebounce` hook changed `isPending` behavior from `async` reacting to the sync. Now `isPending` returns `True` as soon as the new value is sent to the hook.
87+
88+
- _breaking change_ `useDebounce` hook changed `isPending` behavior from `async` reacting to the sync. Now `isPending` returns `True` as soon as the new value is sent to the hook.
5689
- Dev dependencies updated
5790

5891
## 6.0.1
@@ -193,7 +226,8 @@ import { useDebounceCallback } from 'use-debounce';
193226
Old:
194227

195228
```js
196-
const [debouncedCallback, cancelDebouncedCallback, callPending] = useDebouncedCallback(/*...*/);
229+
const [debouncedCallback, cancelDebouncedCallback, callPending] =
230+
useDebouncedCallback(/*...*/);
197231
```
198232

199233
New:
@@ -236,7 +270,10 @@ import { useDebounceCallback } from 'use-debounce';
236270

237271
```js
238272
function Component({ text }) {
239-
const debounced = useDebouncedCallback(useCallback(() => {}, []), 500);
273+
const debounced = useDebouncedCallback(
274+
useCallback(() => {}, []),
275+
500
276+
);
240277

241278
expect(debounced.pending()).toBeFalsy();
242279
debounced.callback();
@@ -404,7 +441,12 @@ function InputWhichFetchesSomeData({ defaultValue, asyncFetchData }) {
404441
[]
405442
);
406443

407-
return <input defaultValue={defaultValue} onChange={(e) => debouncedFunction(e.target.value)} />;
444+
return (
445+
<input
446+
defaultValue={defaultValue}
447+
onChange={(e) => debouncedFunction(e.target.value)}
448+
/>
449+
);
408450
}
409451
```
410452

jest.config.cjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

jest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'jsdom',
5+
roots: ['<rootDir>/test'],
6+
setupFilesAfterEnv: ["<rootDir>/setupTests.ts"],
7+
};

0 commit comments

Comments
 (0)