Skip to content

Integrate internal_helpers for Astro and update dependencies#1580

Open
Adammatthiesen wants to merge 5 commits into
mainfrom
integration-kit-pt2
Open

Integrate internal_helpers for Astro and update dependencies#1580
Adammatthiesen wants to merge 5 commits into
mainfrom
integration-kit-pt2

Conversation

@Adammatthiesen

@Adammatthiesen Adammatthiesen commented Jul 12, 2026

Copy link
Copy Markdown
Member

This pull request introduces a new shared helper for Astro integrations and migrates all packages to use it, simplifying and unifying how virtual imports are added across the codebase. It removes the old per-package helper implementations and updates dependencies accordingly. These changes improve maintainability and consistency for all packages that provide or consume virtual imports.

Migration to shared Astro integration helpers

  • Introduced a new addVirtualImports helper in the @withstudiocms/internal_helpers package to standardize the way virtual imports are added in Astro integrations. (.changeset/eager-mirrors-write.md, .changeset/eager-mirrors-write.mdR1-R5)
  • Migrated all packages (@studiocms/blog, @studiocms/devapps, @studiocms/html, @studiocms/markdoc, @studiocms/markdown-remark, @studiocms/mdx, @studiocms/md, @studiocms/wysiwyg, @studiocms/component-registry) to use the new shared helper, removing the old virtualImportsPlugin implementations. (.changeset/eight-meals-invent.md, [1]; .changeset/seven-socks-wink.md, [2]

Code and configuration updates

  • Updated all relevant package.json files to add @withstudiocms/internal_helpers as a dependency where needed. [1] [2] [3] [4]
  • Refactored integration and test setup files (e.g., index.ts, vitest.config.ts) in affected packages to use addVirtualImports and remove legacy code. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

Other minor changes

  • Minor cleanup in package.json exports for @studiocms/html and @studiocms/markdoc. [1] [2]

These changes collectively make the codebase more maintainable, reduce duplication, and ensure a consistent integration pattern for virtual imports across all StudioCMS packages.

@coderabbitai ignore

Summary by CodeRabbit

  • New Features

    • Added shared virtual import support for Astro and Vite integrations.
    • Added context-aware virtual module handling for server and client builds.
  • Refactor

    • Migrated StudioCMS integrations to shared virtual import utilities.
    • Removed reliance on Astro integration kit helpers.
    • Simplified integration and handler configuration wiring.
  • Bug Fixes

    • Corrected virtual module package exports to expose type declarations without unintended JavaScript entrypoints.
  • Tests

    • Added coverage for virtual import resolution, loading, and context matching.

…tion

feat(markdoc, markdown-remark, md, mdx, wysiwyg, component-registry): migrate to use internal_helpers for virtual imports

fix(studiocms): replace deprecated Astro integration kit helpers

chore: update package dependencies to include internal_helpers

test(internal_helpers): add tests for virtualImportsPlugin functionality
@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4b94f81

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

This PR includes changesets to release 11 packages
Name Type
@withstudiocms/internal_helpers Minor
@withstudiocms/component-registry Minor
@studiocms/markdown-remark Minor
@studiocms/devapps Minor
@studiocms/markdoc Minor
@studiocms/wysiwyg Major
@studiocms/blog Major
@studiocms/html Minor
@studiocms/mdx Minor
@studiocms/md Minor
studiocms Minor

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

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Shared Astro helper migration

Layer / File(s) Summary
Shared virtual import implementation
packages/@withstudiocms/internal_helpers/...
Adds the shared Vite virtual import plugin, Astro wrapper, public exports, Vite peer dependency, and tests for ID resolution, loading, and context filtering.
Package integration migration
packages/@studiocms/{blog,devapps,html,markdoc,md,mdx,wysiwyg}/..., packages/@withstudiocms/component-registry/..., packages/@studiocms/markdown-remark/...
Replaces package-local virtual import plugins with addVirtualImports, updates workspace dependencies, and removes JavaScript defaults from virtual type exports.
Test integration migration
packages/@studiocms/{blog,html,markdoc,md,mdx,wysiwyg}/vitest.config.ts
Uses the shared helper for test-only virtual modules while preserving fixture exports and identity renderers.
StudioCMS handler refactor
packages/studiocms/src/handlers/...
Replaces defineUtility wrappers with directly typed Astro handlers and updates plugin, route, changelog, database, and configuration virtual module generation.
Remaining integration and workspace cleanup
packages/studiocms/src/..., packages/studiocms/package.json, packages/studiocms/tsconfig.json, playground/..., pnpm-workspace.yaml, .changeset/*
Migrates remaining helper imports, replaces Vite helper checks, removes astro-integration-kit metadata, simplifies playground integration setup, and adds release changesets.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the shared helper migration and dependency update.
Linked Issues check ✅ Passed The PR replaces Astro Integration Kit usage with internal_helpers and shared virtual-import helpers, matching issue #1564.
Out of Scope Changes check ✅ Passed No clearly unrelated code changes are evident; the edits support the Astro Integration Kit replacement.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch integration-kit-pt2

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.

@github-actions

github-actions Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Allure Test Report for this PR:

Allure Report | History

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

@pkg-pr-new

pkg-pr-new Bot commented Jul 12, 2026

Copy link
Copy Markdown
create-studiocms

npm i https://pkg.pr.new/create-studiocms@1580

effectify

npm i https://pkg.pr.new/effectify@1580

studiocms

npm i https://pkg.pr.new/studiocms@1580

@studiocms/auth0

npm i https://pkg.pr.new/@studiocms/auth0@1580

@studiocms/blog

npm i https://pkg.pr.new/@studiocms/blog@1580

@studiocms/cloudinary-image-service

npm i https://pkg.pr.new/@studiocms/cloudinary-image-service@1580

@studiocms/devapps

npm i https://pkg.pr.new/@studiocms/devapps@1580

@studiocms/discord

npm i https://pkg.pr.new/@studiocms/discord@1580

@studiocms/github

npm i https://pkg.pr.new/@studiocms/github@1580

@studiocms/google

npm i https://pkg.pr.new/@studiocms/google@1580

@studiocms/html

npm i https://pkg.pr.new/@studiocms/html@1580

@studiocms/markdoc

npm i https://pkg.pr.new/@studiocms/markdoc@1580

@studiocms/markdown-remark

npm i https://pkg.pr.new/@studiocms/markdown-remark@1580

@studiocms/md

npm i https://pkg.pr.new/@studiocms/md@1580

@studiocms/mdx

npm i https://pkg.pr.new/@studiocms/mdx@1580

@studiocms/s3-storage

npm i https://pkg.pr.new/@studiocms/s3-storage@1580

@studiocms/upgrade

npm i https://pkg.pr.new/@studiocms/upgrade@1580

@studiocms/wysiwyg

npm i https://pkg.pr.new/@studiocms/wysiwyg@1580

@withstudiocms/api-spec

npm i https://pkg.pr.new/@withstudiocms/api-spec@1580

@withstudiocms/auth-kit

npm i https://pkg.pr.new/@withstudiocms/auth-kit@1580

@withstudiocms/cli-kit

npm i https://pkg.pr.new/@withstudiocms/cli-kit@1580

@withstudiocms/component-registry

npm i https://pkg.pr.new/@withstudiocms/component-registry@1580

@withstudiocms/config-utils

npm i https://pkg.pr.new/@withstudiocms/config-utils@1580

@withstudiocms/effect

npm i https://pkg.pr.new/@withstudiocms/effect@1580

@withstudiocms/internal_helpers

npm i https://pkg.pr.new/@withstudiocms/internal_helpers@1580

@withstudiocms/kysely

npm i https://pkg.pr.new/@withstudiocms/kysely@1580

@withstudiocms/sdk

npm i https://pkg.pr.new/@withstudiocms/sdk@1580

@withstudiocms/template-lang

npm i https://pkg.pr.new/@withstudiocms/template-lang@1580

commit: 4b94f81

@Adammatthiesen Adammatthiesen changed the title [WIP] Integrate internal_helpers for Astro and update dependencies Integrate internal_helpers for Astro and update dependencies Jul 12, 2026
@Adammatthiesen Adammatthiesen marked this pull request as ready for review July 12, 2026 23:23
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner July 12, 2026 23:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (4)
.changeset/seven-socks-wink.md (1)

1-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Expand changeset description with rationale/impact.

The description is a single line. Based on learnings, changesets should describe the change, rationale, and potential impact so maintainers understand versioning decisions during initial development. Consider noting that this removes the deprecated astro-integration-kit dependency in favor of internal helpers, with no expected user-facing behavior change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.changeset/seven-socks-wink.md around lines 1 - 6, Expand the changeset
description to state that the deprecated astro-integration-kit dependency is
being replaced with internal helpers, include the rationale for the replacement,
and note that no user-facing behavior change is expected.

Source: Learnings

packages/@withstudiocms/internal_helpers/src/vite/virtualImportsPlugin.ts (1)

29-58: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

No test coverage for the ambiguous-ssr fallback branch.

matchesContext's "backward compatibility" branch (context defined, options.ssr undefined) is untested — packages/@withstudiocms/internal_helpers/test/virtualImportsPlugin.test.ts only exercises unscoped imports and explicit ssr: true/false cases. Given the correctness/security concern raised above, this branch should have explicit test coverage to lock in intended behavior once resolved.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/`@withstudiocms/internal_helpers/src/vite/virtualImportsPlugin.ts
around lines 29 - 58, In virtualImportsPlugin tests, add explicit coverage for
matchesContext when an import defines a context but the plugin hook receives
options with ssr undefined. Assert the intended backward-compatible fallback
behavior for both matching and non-matching contexts, using the existing
virtualImportsPlugin test patterns and symbols.
packages/@withstudiocms/internal_helpers/test/virtualImportsPlugin.test.ts (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

@ts-nocheck makes the subsequent type assertion inert.

The file disables all type checking, so the as Exclude<ReturnType<typeof virtualImportsPlugin>, undefined> casts (Lines 18, 48, 87) provide no actual type safety — they're purely documentation at that point. As per coding guidelines, **/*.{test.ts,test.tsx,spec.ts,spec.tsx} files should "Write unit tests with proper TypeScript types, mock external dependencies, and cover plugin integration and auth flows." Consider removing @ts-nocheck and narrowing plugin with a proper type guard/non-null assertion instead, so type errors in the test itself are still caught.

Also applies to: 16-18

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/`@withstudiocms/internal_helpers/test/virtualImportsPlugin.test.ts
at line 1, Remove the file-level `@ts-nocheck` directive in virtualImportsPlugin
tests so TypeScript validates the test code and its ReturnType-based assertions.
Update the plugin handling around the casts at the affected test cases to narrow
the possibly undefined result with an appropriate type guard or non-null
assertion, while preserving the existing test behavior.

Source: Coding guidelines

packages/@studiocms/md/vitest.config.ts (1)

1-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate test-integration scaffold across packages.

This entire test-integration block (including the studiocms:component-registry/runtime mock) is duplicated verbatim in packages/@studiocms/mdx/vitest.config.ts. Consider extracting it into the shared vitest.shared.js helper referenced at line 5, reducing duplicate maintenance when this mock needs to change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/`@studiocms/md/vitest.config.ts around lines 1 - 20, Extract the
duplicated testIntegration AstroIntegration scaffold, including the
studiocms:component-registry/runtime mock, into the shared vitest helper used by
configShared. Update both package Vitest configurations to reuse that shared
symbol and remove their local test-integration definitions, preserving the
existing test behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.changeset/seven-socks-wink.md:
- Around line 1-6: Expand the changeset description to state that the deprecated
astro-integration-kit dependency is being replaced with internal helpers,
include the rationale for the replacement, and note that no user-facing behavior
change is expected.

In `@packages/`@studiocms/md/vitest.config.ts:
- Around line 1-20: Extract the duplicated testIntegration AstroIntegration
scaffold, including the studiocms:component-registry/runtime mock, into the
shared vitest helper used by configShared. Update both package Vitest
configurations to reuse that shared symbol and remove their local
test-integration definitions, preserving the existing test behavior.

In `@packages/`@withstudiocms/internal_helpers/src/vite/virtualImportsPlugin.ts:
- Around line 29-58: In virtualImportsPlugin tests, add explicit coverage for
matchesContext when an import defines a context but the plugin hook receives
options with ssr undefined. Assert the intended backward-compatible fallback
behavior for both matching and non-matching contexts, using the existing
virtualImportsPlugin test patterns and symbols.

In `@packages/`@withstudiocms/internal_helpers/test/virtualImportsPlugin.test.ts:
- Line 1: Remove the file-level `@ts-nocheck` directive in virtualImportsPlugin
tests so TypeScript validates the test code and its ReturnType-based assertions.
Update the plugin handling around the casts at the affected test cases to narrow
the possibly undefined result with an appropriate type guard or non-null
assertion, while preserving the existing test behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b96ab2d-e598-4b89-800e-e874cf6b1b72

📥 Commits

Reviewing files that changed from the base of the PR and between 55b6083 and 4b94f81.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (47)
  • .changeset/eager-mirrors-write.md
  • .changeset/eight-meals-invent.md
  • .changeset/seven-socks-wink.md
  • packages/@studiocms/blog/package.json
  • packages/@studiocms/blog/src/index.ts
  • packages/@studiocms/blog/vitest.config.ts
  • packages/@studiocms/devapps/package.json
  • packages/@studiocms/devapps/src/index.ts
  • packages/@studiocms/html/package.json
  • packages/@studiocms/html/vitest.config.ts
  • packages/@studiocms/markdoc/package.json
  • packages/@studiocms/markdoc/src/index.ts
  • packages/@studiocms/markdoc/vitest.config.ts
  • packages/@studiocms/markdown-remark/src/integration/index.ts
  • packages/@studiocms/markdown-remark/src/integration/integration-utils.ts
  • packages/@studiocms/md/package.json
  • packages/@studiocms/md/src/index.ts
  • packages/@studiocms/md/vitest.config.ts
  • packages/@studiocms/mdx/package.json
  • packages/@studiocms/mdx/src/index.ts
  • packages/@studiocms/mdx/vitest.config.ts
  • packages/@studiocms/wysiwyg/package.json
  • packages/@studiocms/wysiwyg/vitest.config.ts
  • packages/@withstudiocms/component-registry/package.json
  • packages/@withstudiocms/component-registry/src/registry/handler.ts
  • packages/@withstudiocms/internal_helpers/package.json
  • packages/@withstudiocms/internal_helpers/src/astro-integration/addVirtualImports.ts
  • packages/@withstudiocms/internal_helpers/src/astro-integration/index.ts
  • packages/@withstudiocms/internal_helpers/src/vite/index.ts
  • packages/@withstudiocms/internal_helpers/src/vite/virtualImportsPlugin.ts
  • packages/@withstudiocms/internal_helpers/test/virtualImportsPlugin.test.ts
  • packages/studiocms/package.json
  • packages/studiocms/src/handlers/astroConfigCheck.ts
  • packages/studiocms/src/handlers/changelog.ts
  • packages/studiocms/src/handlers/pluginHandler.ts
  • packages/studiocms/src/handlers/routeHandler.ts
  • packages/studiocms/src/handlers/setupDbStudio.ts
  • packages/studiocms/src/index.ts
  • packages/studiocms/src/integrations/dynamic-sitemap/index.ts
  • packages/studiocms/src/integrations/node-namespace.ts
  • packages/studiocms/src/plugins/analytics/index.ts
  • packages/studiocms/test/virtuals/utils.test.ts
  • packages/studiocms/tsconfig.json
  • packages/studiocms/vitest.config.ts
  • playground/astro.config.mts
  • playground/package.json
  • pnpm-workspace.yaml
💤 Files with no reviewable changes (4)
  • packages/studiocms/test/virtuals/utils.test.ts
  • pnpm-workspace.yaml
  • packages/@studiocms/markdown-remark/src/integration/integration-utils.ts
  • packages/studiocms/tsconfig.json

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.

Chore: Replace Astro Integration Kit

1 participant