Skip to content

fix(core): exclude unused @tiptap collab deps from optimizeDeps#780

Open
mvanhorn wants to merge 5 commits into
emdash-cms:mainfrom
mvanhorn:fix/771-tiptap-collaboration-optimizedeps
Open

fix(core): exclude unused @tiptap collab deps from optimizeDeps#780
mvanhorn wants to merge 5 commits into
emdash-cms:mainfrom
mvanhorn:fix/771-tiptap-collaboration-optimizedeps

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

What does this PR do?

A fresh npm create emdash@latest followed by yarn dev fails during dependency optimization on @tiptap/extension-collaboration and @tiptap/y-tiptap (#771):

[ERROR] Could not resolve "@tiptap/extension-collaboration"

Neither package is imported by any source file in this repo (verified by grep across packages/admin/src, packages/core/src, etc.), and neither is declared in packages/admin/package.json or in the catalog inside pnpm-workspace.yaml. They show up in the pnpm store as transitive installs only.

What's happening: Vite's esbuild dependency scanner follows a non-static import() somewhere inside @tiptap/react or @tiptap/starter-kit that references these two collaboration packages, and the scan fails because they're not installed. The dev server never finishes booting on a clean checkout.

This PR appends both packages to the optimizeDeps.exclude array in both the Cloudflare and non-Cloudflare branches of the Astro integration's vite-config.ts, so esbuild skips resolving them entirely. The repo continues to work fine with the 17 @tiptap/* packages it actually uses.

Closes #771

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 — N/A locally; the change is a string-array literal addition with no type changes.
  • pnpm lint passes (pnpm --silent lint:json reported zero diagnostics)
  • pnpm test passes (or targeted tests for my change) — N/A; no test exercises optimizeDeps shape directly. End-to-end verification is npm create emdash@latest && yarn dev succeeds.
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable) — see above
  • User-visible strings in the admin UI are wrapped for translation — N/A (no admin UI strings)
  • I have added a changeset (.changeset/rude-seas-guess.md, emdash patch)
  • New features link to an approved Discussion — N/A (bug fix)

AI-generated code disclosure

  • This PR includes AI-generated code

Developed with Claude Code orchestrating Codex CLI (gpt-5.5 high). The change is a 2-element addition to two existing optimizeDeps.exclude arrays plus a one-line comment above each.

Screenshots / test output

$ pnpm --silent lint:json
0 diagnostics

To verify end-to-end on a maintainer's machine:

  1. npm create emdash@latest (or pnpm create emdash@latest)
  2. cd <project> && yarn dev
  3. Before this PR: dev server fails with Could not resolve "@tiptap/extension-collaboration".
  4. After this PR: dev server starts cleanly.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 26, 2026

🦋 Changeset detected

Latest commit: 91b0b0d

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

This PR includes changesets to release 14 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/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 26, 2026

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 91b0b0d

@mvanhorn mvanhorn marked this pull request as draft April 26, 2026 22:43
@github-actions github-actions Bot added size/M and removed size/S labels Apr 26, 2026
@mvanhorn mvanhorn marked this pull request as ready for review April 26, 2026 22:56
Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Thanks! Just one small note

Comment on lines +400 to +403
"virtual:emdash",
"@tiptap/extension-collaboration",
"@tiptap/y-tiptap",
]
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.

Instead of repeating the array, could you define it as a constant used in both places?

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been inactive for 14 days. It will be closed automatically in 7 days if there is no further activity.

If you're still working on this, please push an update or leave a comment.

@github-actions github-actions Bot added the stale label May 15, 2026
mvanhorn added a commit to mvanhorn/emdash that referenced this pull request May 15, 2026
…mdash-cms#780)

Per @ascorbic's review on emdash-cms#780: extract the repeated @tiptap/* array
into a single constant and reuse it in both the SSR optimizeDeps block
and the top-level optimizeDeps exclude (both cloudflare and non-cloudflare
branches). Removes 3 duplicated explanatory comments; the one on the
constant covers it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Done in 83264e4. Extracted UNUSED_TIPTAP_DEPS next to LOCALE_MESSAGES_RE at module scope and reused it in all three exclude sites (SSR optimizeDeps, top-level cloudflare branch, top-level non-cloudflare branch). The three duplicated comments are gone too; the one on the constant covers the rationale.

Thanks for the review.

@github-actions github-actions Bot removed the stale label May 15, 2026
@github-actions github-actions Bot added stale review/needs-rereview Author pushed changes since the last review and removed stale labels May 29, 2026
mvanhorn and others added 5 commits May 30, 2026 01:07
Vite's esbuild scanner follows a non-static import() inside
@tiptap/react or @tiptap/starter-kit that references
@tiptap/extension-collaboration and @tiptap/y-tiptap. Neither package
is imported by source code in this repo and neither is declared in
packages/admin/package.json or the pnpm-workspace catalog, so a fresh
install fails dependency optimization with "Could not resolve
@tiptap/y-tiptap" before the dev server is reachable.

Append both packages to optimizeDeps.exclude in both the Cloudflare and
non-Cloudflare branches of the Astro integration's vite-config.ts so
esbuild skips resolving them. The repo continues to work correctly with
the @tiptap/* packages it actually uses.

Fixes emdash-cms#771
…xclusion

Calls createViteConfig with both Cloudflare and Node mock adapters and
asserts that the resulting optimizeDeps.exclude (and ssr.optimizeDeps
.exclude on the Cloudflare path) carries @tiptap/extension-collaboration
and @tiptap/y-tiptap. Verified to fail without the fix and pass with
it.

Also picks up oxfmt's reformatting of the inline exclude array on the
SSR branch (one-liner instead of multi-line list) — purely cosmetic.

Refs emdash-cms#771
…mdash-cms#780)

Per @ascorbic's review on emdash-cms#780: extract the repeated @tiptap/* array
into a single constant and reuse it in both the SSR optimizeDeps block
and the top-level optimizeDeps exclude (both cloudflare and non-cloudflare
branches). Removes 3 duplicated explanatory comments; the one on the
constant covers it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
createViteConfig now resolves projectRoot via fileURLToPath(root); the
optimizeDeps regression test's mock astroConfig was missing root after
rebasing onto current main. Add a file URL so both branches construct.
@mvanhorn mvanhorn force-pushed the fix/771-tiptap-collaboration-optimizedeps branch from 83264e4 to 91b0b0d Compare May 30, 2026 06:11
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Rebased onto current main (the branch had drifted ~200 commits) and pushed in 91b0b0d.

Two notes:

  • The previous Tests failure was unrelated to this change — the CI Postgres step couldn't run migrations (role "root" does not exist, _emdash_migrations does not exist). Re-running on current main should clear it.
  • The rebase surfaced that createViteConfig now resolves projectRoot via fileURLToPath(astroConfig.root), so the regression test's mock needed a root URL. Added that; the optimizeDeps exclude assertions still pass locally.

The actual fix (excluding @tiptap/extension-collaboration and @tiptap/y-tiptap from optimizeDeps) is unchanged. #771 is still open.

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

Labels

area/core cla: signed review/needs-rereview Author pushed changes since the last review size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ERROR] Could not resolve "@tiptap/y-tiptap"

2 participants