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

Reduce the client bundle size of App Router #51806

Merged
merged 8 commits into from
Jun 28, 2023

Conversation

SukkaW
Copy link
Contributor

@SukkaW SukkaW commented Jun 26, 2023

After migrating a Next.js app from Pages Router to App Router and using as many RSC as possible, I notice that the client js bundle size actually increases by 5%. It turns out that Next.js has introduced a lot of code to the client bundle.

image

The PR is an attempt to reduce the client bundle size.

@ijjk
Copy link
Member

ijjk commented Jun 26, 2023

Allow CI Workflow Run

  • approve CI run for commit: f9505e4

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Sorry, something went wrong.

@SukkaW SukkaW force-pushed the app-router-reduce-bundle-size branch from b7eb6ef to b346280 Compare June 26, 2023 04:46
SukkaW added 5 commits June 26, 2023 15:42

Verified

This commit was signed with the committer’s verified signature.
bjoerge Bjørge Næss

Verified

This commit was signed with the committer’s verified signature.
bjoerge Bjørge Næss
@SukkaW SukkaW force-pushed the app-router-reduce-bundle-size branch from 26b84b2 to 68776f0 Compare June 26, 2023 07:44
@SukkaW SukkaW marked this pull request as ready for review June 28, 2023 11:43
@SukkaW SukkaW changed the title [WIP] Reduce the client bundle size of App Router Reduce the client bundle size of App Router Jun 28, 2023
Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

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

Thanks! BTW did you measure the diff after this PR?

@kodiakhq kodiakhq bot merged commit e7a6925 into vercel:canary Jun 28, 2023
@SukkaW
Copy link
Contributor Author

SukkaW commented Jun 28, 2023

Thanks! BTW did you measure the diff after this PR?

Yeah. But it seems that I can only remove some of the bytes. I am only able to drop a few module imports, which eliminates some Object.defineProperty(t, "__esModule", { value: !0 }) and ("function" == typeof t.default || ("object" == typeof t.default && null !== t.default)) && void 0 === t.default.__esModule && (Object.defineProperty(t.default, "__esModule", { value: !0 }), Object.assign(t.default, t), (e.exports = t.default));.

On the other hand, I do notice that there are some tree-shaking problems. E.g. the whole next/navigation is introduced to my bundle, while I don't use any of the Router API at all. I am going to work on that in my next PR.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2023
@SukkaW SukkaW deleted the app-router-reduce-bundle-size branch October 24, 2023 08:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants