fix: support built plugin entrypoints#533
Conversation
🦋 Changeset detectedLatest commit: 02a255c The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
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/.tsxand.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
left a comment
There was a problem hiding this comment.
Sandboxed plugins should be using TS entrypoints and then bundling them with the CLI
|
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 I’m going to close this PR and follow up in the plugin package metadata instead, starting with |
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, ordist/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 sharedgetBuildOutputBaseName()helper for source and built entrypoints, uses it for main/backend/admin bundle outputs, and adds unit coverage for.ts,.tsx,.mjs,.js, and.cjsentries.Scope note: this branch is based directly on
origin/mainand includes a second commit with the current type-aware lint baseline fixes that were already present in #184, solely so this PR passes independently againstmain. 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
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runpnpm locale:extracthas been run (if applicable; no admin UI strings changed)AI-generated code disclosure
Screenshots / test output
Not visual.
Validation run locally:
pnpm --silent lint:quick→ passedpnpm --silent lint:json | jq '.diagnostics | length'→0pnpm format→ passedpnpm typecheck→ passedpnpm --filter emdash test -- tests/unit/cli/bundle-utils.test.ts→ passed (135files /2353tests; this command runs the core package vitest suite under the current config)