Skip to content

Migrated public UMD apps to rolldown-vite#29141

Draft
9larsons wants to merge 1 commit into
mainfrom
steve/pla-96-f1-public-apps-rolldown
Draft

Migrated public UMD apps to rolldown-vite#29141
9larsons wants to merge 1 commit into
mainfrom
steve/pla-96-f1-public-apps-rolldown

Conversation

@9larsons

@9larsons 9larsons commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

ref PLA-96

Summary

Workstream F1 of the Rolldown migration: puts Ghost's public UMD apps (portal, comments-ui, signup-form, sodo-search, announcement-bar) on rolldown-vite@7.3.1. These ship to site visitors via CDN, so this is a draft pending review + the runtime gate before merge.

Admin apps are untouched — they stay on stock vite@7.3.2. The migration is scoped via a new named catalog.

Changes

  • pnpm-workspace.yaml: new rolldown catalog → vite: npm:rolldown-vite@7.3.1. The 5 public apps' vite dep now points at catalog:rolldown; every other workspace keeps catalog: (stock vite@7.3.2).
  • apps/portal/vite.config.mjs: removed build.rollupOptions.output.manualChunks: false. Rolldown rejects the false literal (manualChunks is not a function); lib mode + cssCodeSplit:false already yield a single chunk.
  • apps/_shared/vite-public-app.mjs: replaced the @rollup/plugin-commonjs dynamicRequireTargets glob with a new i18nLocaleBundlePlugin.

The i18n regression this fixes

ghost/i18n's generateResources() loads translations with a dynamic require(\../locales/${locale}/${ns}.json`). Under Rollup this was resolved at build time by @rollup/plugin-commonjs's dynamicRequireTargets`, which eagerly bundled every locale file.

Rolldown does not implement dynamicRequireTargets. Left as-is, the dynamic require fell through and portal shrank from 2.4 MB → 907 KB, shipping English only — every non-English site would silently lose its translations.

The new plugin re-expresses the same intent bundler-agnostically: it enumerates every locales/<locale>/<ns>.json for the app's namespace, statically imports them, and rewrites the dynamic require to read from that registry. All 62 locale files bundle again.

Output verification (Rolldown vs. prior Rollup build)

App Baseline Rolldown Δ Locales Notes
portal 2,423,157 2,429,323 +0.3% 62/62 ✅
comments-ui 860,427 856,531 −0.5% 252/252 unit tests pass
signup-form 264,049 256,153 −3.0%
sodo-search 274,869 267,218 −2.8% umd/main.css still emitted (load-bearing)
announcement-bar 136,094 133,210 −2.1% n/a
  • UMD wrapper: identical self-executing define.amd ? define([],e) : e() form in every app (empty AMD deps array vs. Rollup's no-arg define(e) — semantically equivalent).
  • i18n: all locale files bundle for all 4 i18n apps (verified string-presence across de/fr/es/ja/ru/zh/nb + full 62-file sweep for portal).
  • sodo-search still emits umd/main.css by name — theme templates reference it via sodoSearch.styles.

Size deltas are within noise (rolldown-vite's oxc minifier vs. esbuild/terser). No output-correctness risks found.

Not in scope / follow-ups

  • Runtime gate (loading the built bundles in a real theme) — required before un-drafting.
  • Empty rollupOptions: {output: {}} blocks in comments-ui/signup-form left as-is (no-ops under Rolldown, which aliases rollupOptions).

ref PLA-96

- Pointed the 5 public/CDN apps (portal, comments-ui, signup-form,
  sodo-search, announcement-bar) at a new `rolldown` catalog entry
  (`vite: npm:rolldown-vite@7.3.1`); admin apps stay on stock vite@7.3.2.
- Dropped `output.manualChunks: false` from portal's config (Rolldown
  rejects the `false` literal; lib mode + cssCodeSplit:false already emit
  a single chunk).
- Replaced the `@rollup/plugin-commonjs` `dynamicRequireTargets` glob in
  the shared factory with an `i18nLocaleBundlePlugin`. Rolldown does not
  implement dynamicRequireTargets, so ghost/i18n's dynamic
  `require(../locales/${locale}/${ns}.json)` no longer statically bundled
  the locales — portal shrank from 2.4MB to 907KB and shipped English
  only. The plugin statically imports every locales/*/<ns>.json and
  rewrites the dynamic require to read from that registry, restoring full
  translation coverage (all 62 locale files bundle again).

UMD output verified against the prior Rollup build: same self-executing
UMD wrapper, sizes within ~3%, all locales bundle, and sodo-search still
emits the load-bearing umd/main.css.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f24594ea-2528-4456-815f-74c39fbbd71d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch steve/pla-96-f1-public-apps-rolldown

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant