Skip to content
This repository was archived by the owner on May 1, 2021. It is now read-only.

Commit 02c5bf3

Browse files
committed
Add a dev check to ensure query-string is installed correctly #32
1 parent 4bb9d05 commit 02c5bf3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,24 @@ export {
5656
} from './updateLocation';
5757
export { encodeQueryParams } from './encodeQueryParams';
5858
export { decodeQueryParams } from './decodeQueryParams';
59+
60+
if (process.env.NODE_ENV !== 'production') {
61+
/*
62+
* run checks to ensure a valid version of query-string is installed
63+
* see https://github.com/pbeshai/use-query-params/issues/127 for discussion
64+
*/
65+
const queryStringVersion = require('query-string/package.json').version;
66+
// simple check of versions since we don't anticipate any new minor v5s and
67+
// don't want to require the semver package as a dependency for just a simple
68+
// dev check.
69+
const validQueryStringInstalled =
70+
/^5.1.[1-9][0-9]*/.test(queryStringVersion) ||
71+
/^6\./.test(queryStringVersion);
72+
if (!validQueryStringInstalled) {
73+
throw new Error(
74+
`serialize-query-params requires query-string ^5.1.1 || ^6, ` +
75+
`but ${queryStringVersion} is installed. Note: you may also ` +
76+
`see this message if you're using use-query-params.`
77+
);
78+
}
79+
}

0 commit comments

Comments
 (0)