Skip to content

fix: pre-bundle lowlight and highlight.js for inline Portable Text editor hydration - #2921

Merged
ascorbic merged 2 commits into
mainfrom
bot/fix-2916
Sep 6, 2026
Merged

fix: pre-bundle lowlight and highlight.js for inline Portable Text editor hydration#2921
ascorbic merged 2 commits into
mainfrom
bot/fix-2916

Conversation

@emdashbot

@emdashbot emdashbot Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds lowlight, highlight.js, and highlight.js/lib/core to the client optimizeDeps.include list so Vite pre-bundles the CommonJS highlight.js/lib/core entry with ESM interop. This fixes the inline Portable Text editor hydration failure in dev mode that caused rendered content to disappear when visual editing is enabled.

  • Regression test added in packages/core/tests/unit/astro/vite-config.test.ts
  • Changeset included for emdash
  • Verification: pnpm typecheck, pnpm lint:json, pnpm format --check, focused vitest suite all pass

Closes #2916.

A candidate change the reporter confirmed against their own site via the preview build:

npm i https://pkg.pr.new/emdash@bot/fix-2916

Opened automatically by emdashbot as a draft. A maintainer must review before merge.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: emdashbot + Kimi K2.7 Code

Screenshots / test output

…itor hydration

EmDash-Run: 7361befc-9ace-4078-82fe-22c6d12f5f63
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 226f3aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/release-service Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 5, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://bot-fix-2916.try.emdashcms.com, https://bot-fix-2916-emdash-playground.emdash-cms.workers.dev (commit 226f3aa)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://96226b33.try.emdashcms.com, https://96226b33-emdash-playground.emdash-cms.workers.dev 226f3aa 2026-09-06T06:53:59.045Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://463e6ca4.try.emdashcms.com, https://463e6ca4-emdash-playground.emdash-cms.workers.dev 5e946be 2026-09-04T22:43:13.522Z Visit the dashboard ↗

@pkg-pr-new

pkg-pr-new Bot commented Sep 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2921

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2921

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2921

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2921

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2921

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2921

emdash

npm i https://pkg.pr.new/emdash@2921

create-emdash

npm i https://pkg.pr.new/create-emdash@2921

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2921

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2921

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2921

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2921

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2921

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@2921

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2921

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2921

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2921

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2921

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2921

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2921

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2921

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2921

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2921

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2921

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2921

commit: 226f3aa

@ascorbic
ascorbic marked this pull request as ready for review September 6, 2026 06:20
Comment on lines +578 to +583
// The inline Portable Text editor loads the code-block extension, which
// pulls in lowlight. lowlight default-imports highlight.js/lib/core, a
// CommonJS file. Pre-bundling both here ensures Vite wraps the deep CJS
// import with an ESM interop stub instead of serving it raw to the
// browser, which would make hydration fail with
// "does not provide an export named 'default'".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't need all these comments

}
});

describe("createViteConfig inline Portable Text hydration deps", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a shallow test. Include an e2e test proving that the PT editor shows up in the visual editor

…ine PT editor hydration

EmDash-Run: 9eaa4754-5b05-4f1f-96ed-e2349350c3f2
@ascorbic
ascorbic merged commit 67f676d into main Sep 6, 2026
53 checks passed
@ascorbic
ascorbic deleted the bot/fix-2916 branch September 6, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline Portable Text editor disappears in dev when Highlight.js fails to hydrate

1 participant