chore(clerk-js): Replace qs library with custom implementation#3430
Conversation
🦋 Changeset detectedLatest commit: 371c22d The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Good job so far. Please go through the PR comments and once you're ready, don't forget to:
|
e8c83ab to
4878289
Compare
|
@EmmanouelaPothitou This looks good to me. Can you include the size reduction in the description? |
f95319b to
773d959
Compare
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com>
f43bc02 to
cb77adf
Compare
dimkl
left a comment
There was a problem hiding this comment.
🤔 In case the stringifyQueryParams is being used in the request url, i think we should also urlEncode the values to avoid cases of strings containing invalid url symbols (eg =).
Could we test how the qs behaves in those cases?
2b83e76 to
34313aa
Compare
Using the append method on a URLSearchParams instance automatically encodes the value, so I think we don't need to use urlEncode. https://url.spec.whatwg.org/#example-constructing-urlsearchparams |
34313aa to
11a5fcc
Compare
|
!snapshot |
|
Hey @EmmanouelaPothitou - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/chrome-extension@1.0.18-snapshot.v11a5fcc --save-exact
npm i @clerk/clerk-js@5.6.1-snapshot.v11a5fcc --save-exact
npm i @clerk/clerk-expo@1.2.1-snapshot.v11a5fcc --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact |
|
Will be released once #3518 is out |
|
Great job @EmmanouelaPothitou! |
| // The return value isn't as expected. | ||
| // The buildUrl function converts an undefined value to the string 'undefined' | ||
| // and includes it in the search parameters. | ||
| it.skip('parses search params when value is undefined', () => { |
There was a problem hiding this comment.
The buildUrl function converts an undefined value to the string 'undefined' and includes it in the search parameters. This issue existed before removing the qs library, so I didn't address it in this PR.
The qs library used to exclude keys with undefined values from the search parameter string. The stringifyQueryParams function should behave like qs.
I will now create a task in Linear to investigate it further. Therefore, I think we should skip this test for now.
Description
Removing the qs library and using the native URLSearchParams API instead reduced the bundle size of clerk.browser.js by 13.5% (from 70.14KB to 60.62KB) and clerk.headless.js by 22% (from 46.5KB to 36.5KB).
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change