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

perf/size: smaller nuxt-start size #4377

Closed
rlindskog opened this issue Nov 21, 2018 · 11 comments
Closed

perf/size: smaller nuxt-start size #4377

rlindskog opened this issue Nov 21, 2018 · 11 comments

Comments

@rlindskog
Copy link

rlindskog commented Nov 21, 2018

What problem does this feature solve?

Cold starts on serverless platforms like Now 2.0 would be more efficient.

What does the proposed changes look like?

When I have a package.json file that looks like this (working example)

dependencies: {
  "nuxt": "^2.3.2"
}

Run with nuxt-start

npm ci —production

nu -sch ./node_modules: > 100mb

When I have a package.json file that looks like this (working example)

"dependencies": {
  "@nuxt/core": "^2.3.2",
  "core-js": "^2.5.7"
},
devDependencies: {
  "nuxt": "^2.3.2"
}

and programatically run with nuxt.render

npm ci
npm run build
npm ci —production
nu -sch ./node_modules is 26mb

Which is still pretty big.

(this installation pattern was taken from @now/next)

I noticed the nuxt-start package, but it doesn’t work unless nuxt is installed as well, which brings us back to where we started at > 100mb.

In comparison react, react-dom, next-server@canary has a 2.8mb 12mb node_modules footprint

next-server is used in the @next/builder.

Conclusion

There should be an npm module similar to next-server, but for nuxt. This would make it easier to make a nuxt-builder for Now 2.0

This feature request is available on Nuxt community (#c8183)
@ghost ghost added the cmty:feature-request label Nov 21, 2018
@aldarund
Copy link

aldarund commented Nov 21, 2018

I noticed the nuxt-start package, but it doesn’t work unless nuxt is installed as well, which brings us back to where we started at > 100mb.

That shouldnt happen. It work without nuxt and im using it for aws lambda serverless.
Maybe u just encountered a this bug in it #4384

@rlindskog
Copy link
Author

rlindskog commented Nov 21, 2018

@aldarund I was able to get nuxt-start working with the recent updates, but also had to run npm install --production core-js (+7mb) to get it to work. Even with nuxt-start, the node_modules output is still 26mb (it's basically the same as the @nuxt/core implementation), which seems relatively large compared to what it could be.

@aldarund
Copy link

@rlindskog its not 26mb even with core-js. Its 15,7 MB (16 561 152 bytes) Other is your deps.

@rlindskog
Copy link
Author

rlindskog commented Nov 22, 2018

If you calculate it with du -sh ./node_modules (finds the logical filesize), it will be 26mb with just nuxt-start and core-js as dependencies.

Anyway, I found that next-server should've been installed as next-server@canary, which brings up the NextJS production node_modules up to 12mb (just react, react-dom, next-server@canary dependencies).

That's 26mb for Nuxt (19mb without core-js) and 12mb for Next.

@aldarund
Copy link

aldarund commented Nov 22, 2018

@rlindskog core-js shouldnt be needed. its a bug in babel that should be fixed in next release of preset-env babel/babel#9048 and it should appear only in node 10+. You use node 10 or 11 right?
As for size. Its 16mb with core js. Less than 11mb without core-js. And yes, its logical filesize. Here my node modules archive so you can compare ( with core-js). https://www.dropbox.com/s/4t09a5u0pz2rbn8/node_modules_nuxt-start.zip?dl=0
here gist https://gist.github.com/pi0/dcf528794d29fa455c9ca745fb85fe04

@rlindskog
Copy link
Author

@aldarund Good work! I think lodash is still being installed in @nuxtjs/core because of consola@1.4.5 @nuxtjs/opencollective

After npm install in nuxt/packages/core

nuxt.js/packages/core$ npm ls lodash
@nuxt.js/packages/core
└─┬ @nuxtjs/opencollective@0.1.0
  └─┬ consola@1.4.5
    └── lodash@4.17.11

It looks like consola, has been already updated in @nuxtjs/opencollective to 2.0.7, which doesn't contain lodash. Maybe @nuxtjs/opencollective just needs a release?

@pi0
Copy link
Member

pi0 commented Nov 25, 2018

@rlindskog Good catch!

@manniL manniL changed the title Nuxt node_modules exceeds 100mb in production and could be a lot smaller perf/size: smaller nuxt-start size Nov 26, 2018
@manniL
Copy link
Member

manniL commented Nov 26, 2018

Current nuxt-start-edge size: current nuxt-start-edge size

@pi0
Copy link
Member

pi0 commented Dec 3, 2018

It is now install size after #4439. More optimizations on the way.

@manniL
Copy link
Member

manniL commented Dec 11, 2018

Closing as most "issues" and questions are solved.

Current size: install size

Thanks for the heads up! 👍

@manniL manniL closed this as completed Dec 11, 2018
@lock
Copy link

lock bot commented Jan 10, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

No branches or pull requests

5 participants