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

Update build target to es2018 #2249

Merged
merged 2 commits into from
Nov 25, 2022
Merged

Update build target to es2018 #2249

merged 2 commits into from
Nov 25, 2022

Conversation

shuding
Copy link
Member

@shuding shuding commented Nov 24, 2022

For most use cases of SWR, users either have a modern browser (e.g. using modules in the browser + CDN), or have a bundler (esbuild, Webpack). If you still need to target old browsers, it's easy to target a lower version with the bundler.

This change makes sense for the 2.0 version. For the majority this improves the performance of SWR by a lot. According to #2095, the new bundle size will be ~80% of the es5 target. And measured by the SSR benchmark, switching from Object.assign to the native spread operator makes SSR 4.7x faster (P50) in Node.js 16. This scales linearly with the app size, because each useSWR() call contains around 3 Object.assign operations.

@shuding shuding requested a review from huozhi as a code owner November 24, 2022 14:50
@shuding shuding requested a review from koba04 November 24, 2022 14:50
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1c9c578:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

Copy link
Collaborator

@koba04 koba04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM!! That's a great optimization!

@koba04 koba04 mentioned this pull request Nov 24, 2022
13 tasks
@huozhi huozhi merged commit a0a4f10 into main Nov 25, 2022
@huozhi huozhi deleted the shu/b155 branch November 25, 2022 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants