Skip to content
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

chore: bump query-string to ^8.1.0 and update jest config #2319

Merged
merged 5 commits into from Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/config.ts
Expand Up @@ -9,6 +9,8 @@ export default {
type: 'none',
exclude: [],
},
// https://github.com/alibaba/hooks/issues/2155
extraBabelIncludes: ['filter-obj'],
extraBabelPlugins: [
[
'babel-plugin-import',
Expand Down
11 changes: 10 additions & 1 deletion jest.config.js
@@ -1,3 +1,12 @@
/** esm modules to transform */
const esmModules = [
// `query-string` and its related dependencies
'query-string',
'decode-uri-component',
'split-on-first',
'filter-obj',
];

module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'jsdom',
Expand All @@ -18,7 +27,7 @@ module.exports = {
'!**/lib/**',
'!**/dist/**',
],
transformIgnorePatterns: ['^.+\\.js$'],
transformIgnorePatterns: [`node_modules/(?!(?:.pnpm/)?(${esmModules.join('|')}))`],
moduleNameMapper: {
'lodash-es': 'lodash',
},
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -67,10 +67,10 @@
"react-shadow": "^19.0.3",
"rimraf": "^3.0.2",
"surge": "^0.21.3",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.1",
"typescript": "^5.1.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.10",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-merge": "^4.2.2"
},
"commitlint": {
Expand Down
2 changes: 1 addition & 1 deletion packages/use-url-state/package.json
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@babel/runtime": "^7.21.0",
"ahooks": "^3.4.1",
"query-string": "^6.9.0",
"query-string": "^8.1.0",
"tslib": "^2.4.1"
},
"gitHead": "11f6ad571bd365c95ecb9409ca3050cbbfc9b34a"
Expand Down
8 changes: 4 additions & 4 deletions packages/use-url-state/src/index.ts
@@ -1,5 +1,5 @@
import { useMemoizedFn, useUpdate } from 'ahooks';
import { parse, stringify } from 'query-string';
liuyib marked this conversation as resolved.
Show resolved Hide resolved
import qs from 'query-string';
import type { ParseOptions, StringifyOptions } from 'query-string';
import { useMemo, useRef } from 'react';
import type * as React from 'react';
Expand Down Expand Up @@ -50,7 +50,7 @@ const useUrlState = <S extends UrlState = UrlState>(
);

const queryFromUrl = useMemo(() => {
return parse(location.search, mergedParseOptions);
return qs.parse(location.search, mergedParseOptions);
}, [location.search]);

const targetQuery: State = useMemo(
Expand All @@ -71,7 +71,7 @@ const useUrlState = <S extends UrlState = UrlState>(
history[navigateMode](
{
hash: location.hash,
search: stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
search: qs.stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
},
location.state,
);
Expand All @@ -80,7 +80,7 @@ const useUrlState = <S extends UrlState = UrlState>(
navigate(
{
hash: location.hash,
search: stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
search: qs.stringify({ ...queryFromUrl, ...newQuery }, mergedStringifyOptions) || '?',
},
{
replace: navigateMode === 'replace',
Expand Down