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

2x size of the initial bundle load #1637

Closed
mohitgupta1918 opened this issue Apr 6, 2017 · 3 comments
Closed

2x size of the initial bundle load #1637

mohitgupta1918 opened this issue Apr 6, 2017 · 3 comments

Comments

@mohitgupta1918
Copy link

mohitgupta1918 commented Apr 6, 2017

I am using next.js with express server.

I have created a single page(pages/index.js) that has a extremely long text( 9 Mb size ).

when i am running the application
{
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
}

after running npm run build, npm run start
The browser is loading a 18.5 Mb bundle.

image

after running the webpack-bundle-analyser I have identified
{
"name": "dist/pages/index.js",
"size": 9771946,
"chunks": [],
"chunkNames": [],
"emitted": true,
"isOverSizeLimit": true
},
{
"name": "bundles/pages/index.json",
"size": 9771839,
"chunks": [],
"chunkNames": [],
"emitted": true,
"isOverSizeLimit": true
},
Repo link :
Can someone explain ?

@bringking
Copy link

bringking commented Apr 6, 2017

@mohitgupta1918 this PR should address this - #1611. Essentially, next 2.0 inlines the current route bundle and component bundle into the __NEXT_DATA__ object so it can be bootstrapped by the app on the client, which results in basically doubling the size of your HTML document since it contains the rendered HTML + strings, and the JSON representation of your component. @arunoda's PR moves the components into JS bundles that are loaded as plain script tags that are async. Does that make sense?

@arunoda
Copy link
Contributor

arunoda commented Apr 7, 2017

Anyway, @mohitgupta1918 18MB is so wrong. I assume you are sending a lot of data via getInitialProps.

@arunoda
Copy link
Contributor

arunoda commented Apr 7, 2017

Wow. That component is 9MB :)
Don't load it as a component. Use a HTTP API or similar to load chunk by chunk. I hope no one is going to read that 9MB at once.

Anyway, #1611 should fix double loading issue.

@arunoda arunoda closed this as completed Apr 7, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants