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
[Server bundle]: add a possibility to include the node_modules deps with the server bundle #4292
Comments
I'd very much like this feature as well. Currently it looks like most but not all app files are bundled but none of the node modules are bundled. When deploying an SSR artefact you therefore have to either have node modules globally installed on the hosting destination, run npm install on the hosting destination or bundle the folder yourself. None of these make deploying a smooth experience and the node_modules folder can be huge ( > 100mb). If webpack could bundle, minify and tree-shake an SSR bundle you can then run directly with node (rather than nuxt-cli start) it would make deploy faster, cheaper, easier and more secure while also reducing the possibility of mismatched package versions between test, staging and production. |
It is currently possible by using |
If the capability already exists then that's great news! But I couldn't find any documentation on the Now I know what to search for I've found https://github.com/nuxt/docs/issues/1097 - is |
It is being used by now builder without problems. So probably worth making out of experimental and document now. |
@pi0 I suggest to document it first and keep it experimental for another 1-2 minors |
@manniL I think It was experimental enough (and mainly I flagged as experimental/not-documented to first test on some projects which we already did) |
@pi0 If you think it's mature enough, then go for it! 👍 I only thought that more ppl would try it as soon as it's actually documented, which would lead to more feedback. |
Nuxt Version: 2.8.1 It would be great to know how to actually run nuxt after using as a test case I tried the following.
however, upon running and making the first request to the app, I am presented with the following error: my expectation would be that |
Put modules into devModules instead of modules if they are not required for runtime (axios is build only) Standalone deployment is in the plan |
I actually got this working, the issue was how I was bootstrapping
The key here is to NOT include the I have successfully deployed a Nuxt SSR app to AWS Lambda, serving |
Have you got any news or insider information about this feature? |
@lionskape both We are also working on new |
Can I have link for documentation of "--standalone" and "buildModules"? |
2.9 Docs PR is WIP (nuxt/docs#1472) will release soon. For |
Can I find anywhere description or examples, how to use it? |
in nuxt 2.9, i will add '@nuxt/typescript-build' in buildModule. in package.json @nuxt/typescript-build is devDependencies.
why is the buildModule still needed during runtime? |
@zzmark This is not related to this issue. Please create another issue in typescript repo and provide nuxt.config.js or a reproduction :) |
@shainegordon any way you could share your working codes with me? struggling to make it work in AWS lambda |
Hi folks, I am struggling with a similar scenario. I am running nuxt on AWS Lambda and when I bundle my lambda (with webpack) it does not includes some modules in the bundle causing it fail in runtime. The workaround was to include an import in the serverless file
and it includes some modules that Nuxt is not bundling in the
I am building with |
Greetings, I deploy my Nuxt website on GCloud Kubernetes using a Docker image. The recommended way I have found in every blog posts or tutorials is to copy the entire source in the image, install all the node_modules and build the Nuxt app there. It resulted in a ~800MB image (from node:alpine 117MB, so almost 700MB of sources, deps and built files) ! The recommended minimal Dockerfile was :
The installation of all the node_modules were resulting in ~450Mo of fresh layers that needed to be pushed to our docker repository for each deployment, and then pulled by kubernetes. Not really efficient ! I tried to find a way to dramatically reduce the docker image size and build more efficient image (new layers that weight only few Mo). At the present time, I did not found any clear documentation about Then I have come across this issue. The previous answers led me to the solution but I used a slightly different method that I'll share here for the record. So here is my method:
Final image size => 266MB (For the record, I have 90MB of images and videos in /static dir). Hope this will help. Best regards. |
@qnp look at docker multi-stage builds. this wont solve your issue completely, but it will let you get smaller images |
Hi @qnp Indeed it would worth trying multistage builds as @shainegordon mentioned :) Here is an example: https://github.com/nuxt/nuxt.js/blob/dev/examples/docker-build/Dockerfile The current base for image size is ~134MB |
Yes indeed, |
Indeed :) Excluding source may help even less bundle size. BTW telemetry prompt shouldn't happen with latest update for non tty environments (you can try |
Thanks for your answer. |
Hi guys, one year later...
What do you think about adding |
@freefri feel free to create an issue on https://github.com/nuxt/nuxtjs.org/issues 👍🏻 |
Issue is there: nuxt/website-v2#499 Closing issue as main question is resolved. There are still improvement areas like inlining serverMiddleware, config and runtime modules which we will work on. |
What problem does this feature solve?
During the CI, when you build the final artifact, after you can't actually run it independently (at least server side) if depends on some node_modules packages. The offer is to provide some option to make it possible to bundle all the dependencies into the final artifact for the server side part.
What does the proposed changes look like?
Some new options in the nuxt configuration.
The text was updated successfully, but these errors were encountered: