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

Lazy compilation during development #608

Closed
rauchg opened this issue Jan 1, 2017 · 11 comments
Closed

Lazy compilation during development #608

rauchg opened this issue Jan 1, 2017 · 11 comments
Assignees

Comments

@rauchg
Copy link
Member

rauchg commented Jan 1, 2017

In order to make Next.js very performant, we need to address the following problems:

  • When you run next, everything gets compiled eagerly
  • Every time you save a file, whether it's relevant to the rendered routes in your browser or not, it gets eagerly compiled

The beautiful thing about our new compilation output is that it makes these problems very obvious and clear :)

@rauchg
Copy link
Member Author

rauchg commented Jan 1, 2017

Added bonus: pre-fetching would trigger the lazy compilation of additional routes, so that's a very neat way of "doing work in the background".

Side note: a priority queue in place to always put direct routing work ahead of prefetching would be nice (but not a must)

@arunoda
Copy link
Contributor

arunoda commented Jan 1, 2017

I didn't get this 100%. Is this what do you mean.

  • When run next, we don't compile any pages. (No webpack build for pages)
  • Then a user hit a page on the browser, we compile that page.

@rauchg
Copy link
Member Author

rauchg commented Jan 2, 2017

Correct. Right now it builds everything. If anything, I'd rather bind to the port immediately, and then we could start compiling / since that's what the user is likely to hit next

@arunoda
Copy link
Contributor

arunoda commented Jan 2, 2017

Okay. That's interesting.
We need to chat with @nkzawa with a bit on how we could do it.
And we need to figure our whether it actually improves the build time.

@nkzawa
Copy link
Contributor

nkzawa commented Jan 2, 2017

We used to have most of this feature on the old unpublished version of next.js. So actually, we can say it definitely improves your development experience a lot. The only issue I feel on this feature is it makes response time of your app totally different compared to production.

I have no concrete idea how we could do it but maybe should wait for webpack/webpack#3634 to be merged, which should make things a lot easier.

@arunoda
Copy link
Contributor

arunoda commented Jan 2, 2017

@nkzawa I thought dynamic entries are something already supported by webpack.
Okay, I think waiting for that seems like a pretty good idea.

@rauchg
Copy link
Member Author

rauchg commented Jan 3, 2017

@nkzawa it's true that it introduces a difference with production. We should have a flag next --eager perhaps to achieve an accurate simulation

@arunoda
Copy link
Contributor

arunoda commented Jan 30, 2017

@rauchg @nkzawa I think we need to find a better solution than this one.
See this repo: https://github.com/tgoldenberg/next-sample (##918)

Basically it only have a single page, but with source maps enabled it took around ~10 seconds. Even without webpack it took around ~2 seconds for changes. Mostly this is because of the use of material-ui.

@arunoda
Copy link
Contributor

arunoda commented Jan 30, 2017

I'm going to see whether adding tree-shaking support gives us something better.

@arunoda
Copy link
Contributor

arunoda commented Jan 30, 2017

There's a way to do this properly. We could pick all the common modules and serve them as a DDL. So, nothing inside pages directory deals with Webpack at all. So, that's where we could get the speed.

I think we need to work hard to do this automatically, but we don't wanna do it like that. I'll try to work on this. If we can land this before 2.0, that would be huge.

@timneutkens
Copy link
Member

This was implemented in #1111. Please do re-open if needed 😄

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 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

4 participants