Skip to content

Cleaned up public-app vite configs (.js → .jsx + dead preview/loader cruft)#28973

Merged
9larsons merged 7 commits into
mainfrom
public-app-vite-config
Jun 29, 2026
Merged

Cleaned up public-app vite configs (.js → .jsx + dead preview/loader cruft)#28973
9larsons merged 7 commits into
mainfrom
public-app-vite-config

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

Summary

Frontend (public-app) vite config prep — pure cleanup, no behavior change. Continues #28968, which moved the public apps to a vite build --watch-only dev loop (no preview servers, no upfront build).

Sets the stage for a follow-up PR that extracts a shared helper at apps/_shared/vite-public-app.ts for the 6 public-app vite configs.

Commits

  1. Removed dead tolerateMissingOutDir plugin + preview block from admin-toolbar (71af77c222) — Cleaned up public-app dev scripts #28968 dropped the preview server flow, leaving the no-op plugin from Changed admin-toolbar dev to opt out of vite preview's outDir guard via plugin #28964 and the preview: {host, allowedHosts, port: 4176} block with no consumer.

  2. Added secretlint allowlist entries (483e20771b) — Two pre-existing patterns (scriptTag.dataset.key DOM reference in portal; a fake-hex test fixture API key in sodo-search) trip the credential assignment rule once their files are re-staged by the following commit.

  3. Renamed JSX-containing .js files to .jsx (5ab602327b) — 101 files across portal/announcement-bar/sodo-search where JSX was hidden behind a .js extension and worked around by per-app esbuild loader overrides. Also: 3 vite.config entry paths and 5 portal test files' explicit '../src/app.js' imports.

  4. Removed esbuild jsx-loader hacks (1e26a9d1aa) — With the rename in place, esbuild infers the right loader per extension. Dropped the esbuild: {loader: 'tsx'|'jsx', include: /...\.jsx?$/} block + the optimizeDeps.esbuildOptions.plugins[load-js-files-as-jsx] inline plugin + the now-unused fs/promises import from portal/announcement-bar/sodo-search configs.

  5. Removed dead preview/server blocks from 3 more configs (3cb7b17047) — portal, announcement-bar, sodo-search. comments-ui and signup-form intentionally kept their preview: blocks — both have a dev:test script that still calls vite preview and may rely on the host: '0.0.0.0' / allowedHosts settings for the Playwright flow.

Verification

  • All 6 public-app builds succeed from clean.
  • Bundle .js + .css byte-identical to baseline for admin-toolbar, announcement-bar, comments-ui, signup-form.
  • Portal bundle shrinks 301 bytes (0.012%) and sodo-search bundle same size but different hash — the post-rename esbuild defaults emit subtly different code than the old TSX-loader-over-everything override. Semantically identical; confirmed by:
    • portal: 582/583 tests passing (1 skipped)
    • sodo-search: 11/11 tests passing
    • announcement-bar: 1/1 tests passing
  • Sourcemaps reference the new .jsx filenames in sources arrays (expected, not a runtime change).

Test plan

  • Run pnpm dev from a clean clone — verify all 6 public apps build, no preview-server crashes
  • Smoke-test portal in the dev gateway (subscribe/sign-in/email-preferences flows)
  • Smoke-test comments-ui (post a comment, like, reply)
  • Smoke-test sodo-search (open search, type query)
  • CI: all test suites green

9larsons added 5 commits June 29, 2026 15:21
#28968 dropped the public-app preview servers in favor of a plain
`vite build --watch` dev loop, so the configurePreviewServer no-op
plugin added in #28964 and the `preview` block (host/port/allowedHosts)
no longer have a consumer.

- removed the tolerateMissingOutDir plugin definition + its plugins[] entry
- removed the preview block

The five peer public-app configs (portal/announcement-bar/comments-ui/
sodo-search/signup-form) also still carry dead preview blocks; those
are folded into a later commit in the same PR.
no ref

Two long-stable identifiers in apps/portal and apps/sodo-search trigger
the `credential assignment` rule but are not secrets:

- `scriptTag.dataset.key` (portal/src/index — DOM variable reference,
  not a literal value at all)
- `69010382388f9de5869ad6e558` (sodo-search test fixture API key, in
  tree since #25461 and used purely to assert the App component
  receives the prop)

Neither has tripped the hook historically because the files weren't
staged in any commit since the rule was tightened. A follow-up rename
commit (.js → .jsx for JSX-containing files) re-stages both, so add
allowlist entries now to keep the rule green for future edits too.
no ref

Long-standing convention drift: portal, announcement-bar and sodo-search
had JSX in plain .js files (~77 across src + test), worked around by two
esbuild loader overrides in each vite.config — a global `esbuild.loader:
'jsx'` over /src|test\.jsx?$/ and an `optimizeDeps` plugin that
load-files-as-jsx on the .js subset. Renaming the files to match their
content lets esbuild infer the loader from the extension and lets both
hacks be dropped in a follow-up commit.

- 39 portal src + 28 portal test files
- 5 announcement-bar src files
- 3 sodo-search src + 2 test files
- 3 vite.config entry paths updated (announcement-bar/portal/sodo-search
  hardcoded `src/index.js`)
- 5 portal test files updated to drop the explicit '.js' from
  `../src/app.js` imports (extensionless lets Vite resolve to the new
  .jsx file)

Verified: bundle .js + .css are byte-identical to pre-rename baselines
across all 6 public apps; sourcemaps reference the new .jsx filenames in
their `sources` arrays (expected, not a runtime change).
no ref

With JSX-containing files now correctly named .jsx (previous commit),
the explicit loader overrides in portal, announcement-bar and
sodo-search vite.configs are redundant — esbuild infers the right
loader from the extension. Removed:

- the `esbuild: {loader: 'tsx'|'jsx', include: /...\.jsx?$/}` block
- the `optimizeDeps.esbuildOptions.plugins[load-js-files-as-jsx]`
  inline plugin that re-loaded .js files as jsx during dep prebundling
- the now-unused `fs/promises` import each of those needed

### Bundle drift (benign)

Bundle .js shrinks ~300 bytes in portal (0.012%) and stays the same
size in sodo-search (different hash). The drift comes from esbuild's
default per-extension loader emitting subtly different output than the
TSX-loader-on-everything override that used to apply — semantically
identical, no behavior change. Verified by running each app's full
test suite:

- portal:        582 passed, 1 skipped
- sodo-search:   11 passed
- announcement-bar: 1 passed

admin-toolbar, comments-ui and signup-form bundle output is unchanged
(byte-identical to baseline).
no ref

Continuation of commit 71af77c (admin-toolbar cleanup). With #28968
having dropped the public-app preview-server flow in favor of
`vite build --watch` plus Caddy-served UMDs, the per-app
`preview: {host, allowedHosts, port, cors}` blocks no longer have a
consumer. Removed from:

- portal           (plus its dead `server: {port: 5368}` block — no
                    vite dev script consumes it)
- announcement-bar
- sodo-search

comments-ui and signup-form intentionally kept their `preview` blocks
— each has a `dev:test` script that still invokes `vite preview` and
relies on `host: '0.0.0.0'` / `allowedHosts` for the Playwright
acceptance flow.
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 03f302f2-3c7a-4465-a60a-7bb6181e947f

📥 Commits

Reviewing files that changed from the base of the PR and between 3cb7b17 and 8986fc0.

📒 Files selected for processing (4)
  • apps/admin-toolbar/package.json
  • apps/announcement-bar/package.json
  • apps/portal/package.json
  • apps/sodo-search/package.json
✅ Files skipped from review due to trivial changes (3)
  • apps/admin-toolbar/package.json
  • apps/portal/package.json
  • apps/announcement-bar/package.json

Walkthrough

Multiple Vite configuration files across apps/announcement-bar, apps/portal, apps/sodo-search, and apps/admin-toolbar are simplified by removing custom fs/promises-based optimizeDeps plugins, esbuild loader overrides, and preview/server configuration blocks. Library build entrypoints are renamed from src/index.js to src/index.jsx in announcement-bar, portal, and sodo-search. Five portal test files drop the explicit .js extension from their App import paths. Three additional regex patterns are added to the secretlint credential assignment rule's allows list.

Possibly related PRs

  • TryGhost/Ghost#28962: Removes admin-toolbar's custom Vite preview guard logic, which is the same configuration area adjusted here.
  • TryGhost/Ghost#28964: Introduces the tolerate-missing-outdir Vite preview hook in apps/admin-toolbar/vite.config.mjs, which this change removes.
  • TryGhost/Ghost#28970: Updates the public app Vite build setup around src/index.jsx entrypoints and related config removal, matching the same app set touched here.

Suggested reviewers

  • acburdine
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed It clearly summarizes the main cleanup around public-app Vite configs and JSX file renames.
Description check ✅ Passed The description accurately covers the Vite cleanup, JSX renames, secretlint allowlist, and version bumps in the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch public-app-vite-config

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.

@nx-cloud

nx-cloud Bot commented Jun 29, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 3cb7b17

Command Status Duration Result
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 3s View ↗
nx run-many -t test:unit -p @tryghost/admin-too... ✅ Succeeded 57s View ↗
nx run-many -t lint -p ghost-monorepo,@tryghost... ✅ Succeeded 19s View ↗
nx run @tryghost/admin:build ✅ Succeeded 6s View ↗
nx run ghost:build:assets ✅ Succeeded 2s View ↗
nx run ghost:build:tsc ✅ Succeeded 6s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-29 21:04:44 UTC

9larsons added 2 commits June 29, 2026 15:59
no ref

The earlier commits in this PR (vite config cleanup, .js → .jsx
rename, esbuild hack removal) trigger the app-version-bump CI check
for the apps whose files changed. Patch-only bumps; MAJOR.MINOR in
ghost/core/core/shared/config/defaults.json is unchanged.

- admin-toolbar:    0.1.9  → 0.1.10
- announcement-bar: 1.1.25 → 1.1.26
- portal:           2.69.13 → 2.69.14
- sodo-search:      1.8.28 → 1.8.29

comments-ui and signup-form had no file changes, no bump needed.
no ref

Missed in the previous bump commit (baefc91) — admin-toolbar's
vite.config.mjs was touched in commit 71af77c (dead preview config
removal), so the CI app-version-bump check requires the version
bump too.
@9larsons 9larsons enabled auto-merge (squash) June 29, 2026 21:04
@9larsons 9larsons merged commit d99bbaa into main Jun 29, 2026
40 checks passed
@9larsons 9larsons deleted the public-app-vite-config branch June 29, 2026 21:13
9larsons added a commit that referenced this pull request Jun 29, 2026
The merge of main into this branch brought in #28973, which bumped
sodo-search to 1.8.29 and announcement-bar to 1.1.26 — matching the
values this PR had already bumped to. check-app-version-bump.js then
fails because the PR is no longer ahead of main on those two apps.
Bump both patches once more.

- sodo-search:      1.8.29 -> 1.8.30
- announcement-bar: 1.1.26 -> 1.1.27

no ref
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