Skip to content

Speed up dev startup by pre-bundling external deps in optimizeDeps#134

Open
arybakov05 wants to merge 4 commits into
mainfrom
optimize_vite_deps
Open

Speed up dev startup by pre-bundling external deps in optimizeDeps#134
arybakov05 wants to merge 4 commits into
mainfrom
optimize_vite_deps

Conversation

@arybakov05

@arybakov05 arybakov05 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

before:
image

after:
image


📚 Documentation preview 📚: https://plone-aurora--134.org.readthedocs.build/

@arybakov05

arybakov05 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

@sneridagh @pnicolli Could this be useful? It does speed up the dev mode and it removes the three reloads when opening the page initially

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Aurora’s Vite dev startup performance by (1) avoiding unnecessary regeneration of the registry-generated Vite loader (which can trigger restart loops) and (2) pre-declaring dependency pre-bundling via optimizeDeps.include for both the app and key workspace packages/add-ons. It also documents the intended workflow for declaring optimizeDeps entries in a pnpm monorepo.

Changes:

  • Prevents .plone/vite.loader.js from being rewritten when its content is unchanged (avoids Vite restart loops).
  • Adds optimizeDeps.include entries in apps/aurora/vite.config.ts and introduces vite.extend.js files for core add-ons to pre-bundle external deps.
  • Adds documentation describing how to declare optimizeDeps (and where to do so depending on add-on vs non-add-on packages).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/registry/vite-plugin.js Avoids rewriting generated Vite loader when content is unchanged to prevent restart loops.
packages/registry/news/+vite-extend-support.internal Changelog entry for the loader write-change behavior.
packages/plate/vite.extend.js Declares @plone/plate external deps for Vite pre-bundling.
packages/plate/news/+vite-optimize-deps.internal Changelog entry for Plate optimizeDeps pre-bundling.
packages/layout/vite.extend.js Declares @plone/layout external deps for Vite pre-bundling.
packages/layout/news/+vite-optimize-deps.internal Changelog entry for Layout optimizeDeps pre-bundling.
packages/cmsui/vite.extend.js Declares @plone/cmsui external deps for Vite pre-bundling.
packages/cmsui/news/+vite-optimize-deps.internal Changelog entry for CMS UI optimizeDeps pre-bundling.
docs/development/vite-optimize-deps.md New guide documenting how/where to declare optimizeDeps (add-ons vs app).
docs/development/index.md Adds the new optimizeDeps doc page to the development docs index.
apps/aurora/vite.config.ts Adds app-level optimizeDeps.include declarations for faster dev startup.
apps/aurora/news/+vite-optimize-deps.internal Changelog entry for app-level optimizeDeps declarations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +53 to +55
'i18next-browser-languagedetector',
'i18next-fs-backend/cjs',
'i18next-http-backend',
Comment on lines +59 to +61
'remix-i18next/client',
'remix-i18next/react',
'remix-i18next/server',
'@plone/helpers > jotai/utils',
'@plone/helpers > jotai-optics',
],
},
Comment on lines +65 to +66
If a dependency exports subpaths you use (for example `some-lib/react` or `some-lib/client`), add a separate entry for each subpath.
Vite does not discover subpath exports automatically from the main entry.
@pnicolli

Copy link
Copy Markdown
Collaborator

Could this be useful? It does speed up the dev mode and it removes the three reloads when opening the page initially

YES, definitely! Thanks!
I asked Copilot for a review as well since it should have a pretty good vite knowledge. I want to take a moment to review it myself anyway, in addition to Copilot's suggestions that I would recommend checking already.

Assigning Steve as well for docs review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants