-
Notifications
You must be signed in to change notification settings - Fork 900
fix(core): exclude unused @tiptap collab deps from optimizeDeps #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mvanhorn
wants to merge
5
commits into
emdash-cms:main
Choose a base branch
from
mvanhorn:fix/771-tiptap-collaboration-optimizedeps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−2
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4bef531
fix(core): exclude unused @tiptap collab deps from optimizeDeps
mvanhorn 488a27a
style: format
emdashbot[bot] 1348109
test(astro): regression test for #771 optimizeDeps tiptap exclusion
mvanhorn d440213
Merge branch 'main' into fix/771-tiptap-collaboration-optimizedeps
ascorbic f691973
Merge branch 'main' into fix/771-tiptap-collaboration-optimizedeps
ascorbic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "emdash": patch | ||
| --- | ||
|
|
||
| fix: exclude unused @tiptap collaboration deps from optimizeDeps so fresh installs do not fail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/core/tests/unit/astro/vite-config-optimizedeps.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import type { AstroConfig } from "astro"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import type { EmDashConfig } from "../../../src/astro/integration/runtime.js"; | ||
| import { createViteConfig } from "../../../src/astro/integration/vite-config.js"; | ||
|
|
||
| /** | ||
| * Regression for #771: a fresh `npm create emdash@latest && yarn dev` failed | ||
| * dependency optimization on `@tiptap/extension-collaboration` and | ||
| * `@tiptap/y-tiptap`. Neither package is imported in source code or declared | ||
| * as a dependency, but Vite's esbuild dep scanner follows non-static | ||
| * `import()` calls inside `@tiptap/react` / `@tiptap/starter-kit` and tries | ||
| * to resolve them. The fix: list both packages in `optimizeDeps.exclude` so | ||
| * the scanner skips them. | ||
| * | ||
| * Both branches of the integration's vite config (Cloudflare and non- | ||
| * Cloudflare) need the exclusion. The test pins both branches so a future | ||
| * refactor can't quietly drop the entries from one path. | ||
| */ | ||
| describe("vite-config optimizeDeps exclude (#771)", () => { | ||
| function makeOptions(adapter: "cloudflare" | "node") { | ||
| const astroConfig: Partial<AstroConfig> = { | ||
| adapter: | ||
| adapter === "cloudflare" | ||
| ? { name: "@astrojs/cloudflare", hooks: {} } | ||
| : { name: "@astrojs/node", hooks: {} }, | ||
| }; | ||
| const emdashConfig: Partial<EmDashConfig> = {}; | ||
| return { | ||
| astroConfig: astroConfig as AstroConfig, | ||
| emdashConfig: emdashConfig as EmDashConfig, | ||
| plugins: [] as PluginDescriptor[], | ||
| }; | ||
| } | ||
|
|
||
| it("excludes @tiptap/extension-collaboration and @tiptap/y-tiptap on the Node path", () => { | ||
| const config = createViteConfig( | ||
| makeOptions("node") as Parameters<typeof createViteConfig>[0], | ||
| "dev", | ||
| ); | ||
| const exclude = config.optimizeDeps?.exclude ?? []; | ||
| expect(exclude).toContain("@tiptap/extension-collaboration"); | ||
| expect(exclude).toContain("@tiptap/y-tiptap"); | ||
| // Sanity-check existing entries are still present so we did not | ||
| // regress the original optimizeDeps shape. | ||
| expect(exclude).toContain("virtual:emdash"); | ||
| }); | ||
|
|
||
| it("excludes @tiptap/extension-collaboration and @tiptap/y-tiptap on the Cloudflare ssr path", () => { | ||
| const config = createViteConfig( | ||
| makeOptions("cloudflare") as Parameters<typeof createViteConfig>[0], | ||
| "dev", | ||
| ); | ||
| // On Cloudflare the exclusion shows up in two places: the | ||
| // adapter-specific ssr.optimizeDeps block, and the top-level | ||
| // optimizeDeps.exclude ternary. Both must carry the entries so a | ||
| // future refactor that drops one path is still caught. | ||
| const ssr = config.ssr as { optimizeDeps?: { exclude?: string[] } } | undefined; | ||
| const ssrExclude = ssr?.optimizeDeps?.exclude ?? []; | ||
| expect(ssrExclude).toContain("@tiptap/extension-collaboration"); | ||
| expect(ssrExclude).toContain("@tiptap/y-tiptap"); | ||
| expect(ssrExclude).toContain("virtual:emdash"); | ||
|
|
||
| const topLevelExclude = config.optimizeDeps?.exclude ?? []; | ||
| expect(topLevelExclude).toContain("@tiptap/extension-collaboration"); | ||
| expect(topLevelExclude).toContain("@tiptap/y-tiptap"); | ||
| }); | ||
| }); | ||
|
|
||
| // Re-declare here to avoid pulling the runtime module's broader type surface | ||
| // into a test file. The shape only needs to be assignable; the test does not | ||
| // inspect the plugins list. | ||
| type PluginDescriptor = { | ||
| name?: string; | ||
| package?: string; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?