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

Add React's production aliases #1855

Merged
merged 1 commit into from
May 3, 2017
Merged

Add React's production aliases #1855

merged 1 commit into from
May 3, 2017

Conversation

lukeed
Copy link
Contributor

@lukeed lukeed commented May 2, 2017

Using examples/hello-world as a basic starting point, these changes produce a bundle that is 1kB (min) smaller. The compilation process is also faster!

On my workhorse, I'm seeing 5.6s vs 6.0s. <-- Really marginal here, but this difference translates to a larger difference on more standard hardware. Eg, the difference is 1.5s on my laptop... and the difference will only increase with more complex projects!

Relevant thread: Twitter

@lukeed
Copy link
Contributor Author

lukeed commented May 2, 2017

The change is located such that users' next.config.js can add to or override the resolve.alias field.

@arunoda
Copy link
Contributor

arunoda commented May 3, 2017

This is great @lukeed.
I think we may need to add server aliasing as well.
I'll try something around today.

@lukeed
Copy link
Contributor Author

lukeed commented May 3, 2017

Thanks! Tim mentioned the same thing earlier today so i checked it out and it's not the case. The server picks up the webpack aliases.

@rauchg rauchg merged commit 87773b9 into vercel:master May 3, 2017
@rauchg
Copy link
Member

rauchg commented May 3, 2017

😍

@lukeed lukeed deleted the prod-aliases branch May 3, 2017 02:04
@arunoda
Copy link
Contributor

arunoda commented May 3, 2017

I tested this with few different types of app for multiple times.
(All of these times, babel loader cache has been removed)

There's no comparable time and size differences using this PR.
(Sometimes, without this PR it'll speed up 1-2 secs. But I think it's due to some other random processes running in my MBP)

But,

The improvement comes when the user turned off uglifyjs. (Stopping that will give us around 2x-3x build time reduction)
Also it'll will reduce bundle size significantly. For our https://zeit.co, using this will reduce the size of the app.js to 1.1MB to 600KB.
(That's a huge difference)

@lukeed
Copy link
Contributor Author

lukeed commented May 3, 2017

@arunoda Thanks for this! Is there anyway you can show me some of the apps you tested this on? I should be able to dig into it more this weekend. But with the hello-world demo, I consistently got a 0.5s reduction. 🤔

For our https://zeit.co, using this will reduce the size of the app.js to 1.1MB to 600KB.

This was the main incentive for the PR. 😄 'Twas the start of that Twitter thread.

@arunoda
Copy link
Contributor

arunoda commented May 3, 2017

@lukeed check this for a mid-size app.
Unfortunately, I can't give you access to https://zeit.co :D

@lukeed
Copy link
Contributor Author

lukeed commented May 3, 2017

Understandable 😜 I'll check this out.

Btw, I don't think there should be a huge time difference here -- UglifyJS still has to be slow & methodical in order to do its job well.

A possible next step might be to uglify the application code only and then inject the prod-ready React afterwards? Might not be worth the experimentation, since it'd only avoid parsing ~45kb.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants