Skip to content

Commit 7843f02

Browse files
dxsun97liuyib
andauthored
chore: bump query-string to ^8.1.0 and update jest config (#2319)
* chore: upgrade query-string to ^8.1.0 * chore: update jest config * style: update import * style: update --------- Co-authored-by: liuyib <[email protected]>
1 parent b6fbcfd commit 7843f02

File tree

7 files changed

+1210
-715
lines changed

7 files changed

+1210
-715
lines changed

config/config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default {
99
type: 'none',
1010
exclude: [],
1111
},
12+
// https://github.com/alibaba/hooks/issues/2155
13+
extraBabelIncludes: ['filter-obj'],
1214
extraBabelPlugins: [
1315
[
1416
'babel-plugin-import',

jest.config.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/** esm modules to transform */
2+
const esmModules = [
3+
// `query-string` and its related dependencies
4+
'query-string',
5+
'decode-uri-component',
6+
'split-on-first',
7+
'filter-obj',
8+
];
9+
110
module.exports = {
211
preset: 'ts-jest/presets/js-with-ts',
312
testEnvironment: 'jsdom',
@@ -18,7 +27,7 @@ module.exports = {
1827
'!**/lib/**',
1928
'!**/dist/**',
2029
],
21-
transformIgnorePatterns: ['^.+\\.js$'],
30+
transformIgnorePatterns: [`node_modules/(?!(?:.pnpm/)?(${esmModules.join('|')}))`],
2231
moduleNameMapper: {
2332
'lodash-es': 'lodash',
2433
},

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
"react-shadow": "^19.0.3",
6969
"rimraf": "^3.0.2",
7070
"surge": "^0.21.3",
71-
"ts-jest": "^29.0.5",
71+
"ts-jest": "^29.1.1",
7272
"typescript": "^5.1.3",
73-
"webpack": "^4.43.0",
74-
"webpack-cli": "^3.3.10",
73+
"webpack": "^5.88.2",
74+
"webpack-cli": "^5.1.4",
7575
"webpack-merge": "^4.2.2"
7676
},
7777
"commitlint": {

packages/use-url-state/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"@babel/runtime": "^7.21.0",
3636
"ahooks": "^3.4.1",
37-
"query-string": "^6.9.0",
37+
"query-string": "^8.1.0",
3838
"tslib": "^2.4.1"
3939
},
4040
"gitHead": "11f6ad571bd365c95ecb9409ca3050cbbfc9b34a"

packages/use-url-state/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemoizedFn, useUpdate } from 'ahooks';
2-
import { parse, stringify } from 'query-string';
2+
import qs from 'query-string';
33
import type { ParseOptions, StringifyOptions } from 'query-string';
44
import { useMemo, useRef } from 'react';
55
import type * as React from 'react';
@@ -50,7 +50,7 @@ const useUrlState = <S extends UrlState = UrlState>(
5050
);
5151

5252
const queryFromUrl = useMemo(() => {
53-
return parse(location.search, mergedParseOptions);
53+
return qs.parse(location.search, mergedParseOptions);
5454
}, [location.search]);
5555

5656
const targetQuery: State = useMemo(
@@ -71,7 +71,7 @@ const useUrlState = <S extends UrlState = UrlState>(
7171
history[navigateMode](
7272
{
7373
hash: location.hash,
74-
search: stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
74+
search: qs.stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
7575
},
7676
location.state,
7777
);
@@ -80,7 +80,7 @@ const useUrlState = <S extends UrlState = UrlState>(
8080
navigate(
8181
{
8282
hash: location.hash,
83-
search: stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
83+
search: qs.stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
8484
},
8585
{
8686
replace: navigateMode === 'replace',

0 commit comments

Comments
 (0)