vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.29k stars 925 forks source link

[Feature request] Constant Memory Usage #1262

Closed KnorpelSenf closed 1 year ago

KnorpelSenf commented 1 year ago

Clear and concise description of the problem

Currently, as you add pages to the project, the RAM consumption will grow and grow. Already with a few hundred pages, the default amount of RAM available to Node is insufficient.

Suggested solution

Build the site page by page with a memory overhead that scales with the size of the largest/most complex page, rather than with the number of pages.

Alternative

Allow building the site incrementally based on the cache, so only the assets that have changed must be rebuilt. That way, we could use caching in CI and still be able to build the site. This is probably less favorable because it means that builds now depend on an external cache.

Additional context

There are systems like https://lume.land/ that require no build step at all. I understand that this is not really possible to do anymore with where Vuepress is at today. However, it would still be nice if we could use at least less resources than we currently do.

Mister-Hope commented 1 year ago

Your question is reasonable.

During the build process, this cannot be done, webpack and vite all need to load and analyze all codes to pack the application, this means the more you put inside a project, the more codes they need to handle, so the compiling stage needs a linear space of memory comparing to content. These memory are taken by bundler, and it's not quite related to VuePress itselfs, unless we do not require a bundler to pack our spa anymore.

During the SSG process, we should ensure all previous contents can be "GC"ed when generating a new page, and I think that vuepress official plugin and default theme is doing a great job here. If you notice that memory usage keep increasing when rendering page htmls, then there might be some issues in 3rd party plugins and themes.

KnorpelSenf commented 1 year ago

Thanks for responding. Do I understand it correctly that this would have to be fixed in both webpack and vite before we could achieve this?

It's great to see vuepress itself doing a better job :)

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.

KnorpelSenf commented 1 year ago

Maybe add a different label to prevent the bot from marking this issue as stale.

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.

github-actions[bot] commented 1 year ago

This issue is marked as stale because it has not had recent activity. Issues marked with stale will be closed if they have no activity within 7 days.