Skip to content

fix: support built plugin entrypoints#533

Closed
masonjames wants to merge 3 commits into
emdash-cms:mainfrom
masonjames:fix/built-plugin-entrypoints
Closed

fix: support built plugin entrypoints#533
masonjames wants to merge 3 commits into
emdash-cms:mainfrom
masonjames:fix/built-plugin-entrypoints

Conversation

@masonjames

@masonjames masonjames commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes plugin bundling when a plugin manifest points at built JavaScript entrypoints such as dist/index.mjs, dist/sandbox-entry.js, or dist/worker.cjs.

The bundle command previously derived tsdown output names by stripping only .ts / .tsx, so built JS entrypoints kept their extension in the base name and the CLI could miss the generated output. This adds a shared getBuildOutputBaseName() helper for source and built entrypoints, uses it for main/backend/admin bundle outputs, and adds unit coverage for .ts, .tsx, .mjs, .js, and .cjs entries.

Scope note: this branch is based directly on origin/main and includes a second commit with the current type-aware lint baseline fixes that were already present in #184, solely so this PR passes independently against main. It does not include the PortableText plugin-block changes from #184. If maintainers prefer to merge baseline cleanup elsewhere first, this draft can be rebased to drop that support commit.

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 and pnpm locale:extract has been run (if applicable; no admin UI strings changed)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: N/A — bug fix, not a feature

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

Not visual.

Validation run locally:

  • pnpm --silent lint:quick → passed
  • pnpm --silent lint:json | jq '.diagnostics | length'0
  • pnpm format → passed
  • pnpm typecheck → passed
  • pnpm --filter emdash test -- tests/unit/cli/bundle-utils.test.ts → passed (135 files / 2353 tests; this command runs the core package vitest suite under the current config)

@changeset-bot

changeset-bot Bot commented Apr 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 02a255c

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

This PR includes changesets to release 9 packages
Name Type
emdash Patch
@emdash-cms/cloudflare 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/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

pkg-pr-new Bot commented Apr 13, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 02a255c

@masonjames masonjames marked this pull request as ready for review April 13, 2026 15:56
Copilot AI review requested due to automatic review settings April 13, 2026 15:56

Copilot AI 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.

Pull request overview

Fixes the plugin bundling workflow in @emdash-cms/core when a plugin manifest/export points to built JavaScript entrypoints (e.g. dist/index.mjs, dist/worker.cjs) by deriving the correct tsdown output base name for both source and built entries, and adds unit coverage for the new behavior. The branch also includes a small set of type-aware lint baseline adjustments so it can pass cleanly against main.

Changes:

  • Add getBuildOutputBaseName() to normalize entry base names across .ts/.tsx and .mjs/.js/.cjs, and use it for main/backend/admin bundle output discovery.
  • Add unit tests covering base-name derivation for source and built entry extensions.
  • Apply type/lint cleanup changes across a few files (safer JSON parsing / type guards / non-null assertion removals).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/cli/commands/bundle-utils.ts Adds getBuildOutputBaseName() helper (shared entry base-name logic).
packages/core/src/cli/commands/bundle.ts Uses getBuildOutputBaseName() for main/backend/admin output discovery (fixes built-entry bundling).
packages/core/tests/unit/cli/bundle-utils.test.ts Adds unit coverage for the new base-name helper across .ts/.tsx/.mjs/.js/.cjs.
.changeset/fix-plugin-bundle-built-entries.md Patch changeset documenting the bundling fix.
packages/core/tsdown.config.ts Makes package version parsing type-safe for lint/type baseline.
packages/core/src/storage/s3.ts Refactors S3Client config construction (lint/type baseline adjustment).
packages/core/src/query.ts Removes unnecessary non-null assertions (type narrowing cleanup).
packages/core/src/emdash-runtime.ts Adds safe string-array JSON parsing helper for taxonomy collections field.
packages/core/src/astro/routes/api/content/[collection]/index.ts Introduces a reusable isRecord guard to avoid unsafe casts.
packages/core/src/astro/integration/vite-config.ts Removes an unnecessary non-null assertion in a dev-only branch.
packages/core/src/api/handlers/redirects.ts Removes a non-null assertion in loop hop formatting (baseline cleanup).
packages/admin/vitest.config.ts Removes an unnecessary cast in vitest config plugin list.
lunaria.config.ts Makes Lunaria locales typing explicit and enforces non-empty target locales at runtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ascorbic ascorbic left a comment

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.

Sandboxed plugins should be using TS entrypoints and then bundling them with the CLI

@masonjames

Copy link
Copy Markdown
Contributor Author

Thanks for the clarification — and sorry for taking this in the wrong direction in core.

I understand the intended path now: sandboxed marketplace packages should expose TS entrypoints and rely on emdash plugin bundle / publish --build to produce the runtime artifact, rather than changing core runtime entrypoint resolution here.

I’m going to close this PR and follow up in the plugin package metadata instead, starting with emdash-smtp-marketplace so its main / types / exports / files match the TS-entrypoint convention used by the other sandboxed marketplace packages. Thanks again for the guidance.

@masonjames masonjames closed this Apr 13, 2026
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.

3 participants