Skip to content

fix: resolve #1053 type errors for strict consumers - #1076

Merged
ascorbic merged 4 commits into
mainfrom
fix/1053-compile-subpaths
May 17, 2026
Merged

ascorbic merged 4 commits into
mainfrom
fix/1053-compile-subpaths

Conversation

@ascorbic

@ascorbic ascorbic commented May 17, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Closes #1053. Built on #1074 (TS6 upgrade, merged) — supersedes #1075, which is closed in favour of this single coherent change.

#1053 reported two type errors when consuming [email protected] under a strict TypeScript project. Re-triaged:

  • byline.ts:204 (kysely Transaction variance) — TypeScript 5.x behaviour; does not reproduce on TS 6 and was already resolved by chore: upgrade to TypeScript 6 + pin tsgo beta + fix dual-load config #1074. No code change.
  • wordpress-plugin.ts ('error' is of type 'unknown') — real: the analyze-endpoint error body from response.json() is unknown under @cloudflare/workers-types and was read without narrowing. Fixed with assertion-free narrowing (clean under both the consumer's Workers config and emdash's own typecheck; runtime unchanged).

Root cause of the class: the reporter's premise was right, their repro wrong. Bare import "emdash" resolves to compiled dist/*.d.mts (skipLibCheck covers it — verified clean). The errors only surfaced because several subpaths shipped raw source (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas, emdash/auth/providers/*): skipLibCheck does not skip .ts, so a strict consumer's tsc type-checked EmDash's source and its transitive graph. And because that raw source imported Database from src while emdash/locals provided the compiled dist identity, Kysely<Database> had two nominally-distinct identities → TS2345 wherever emdash met route-local types.

Structural fix: those subpaths are now compiled to dist (.mjs + .d.mts). Consumers only ever see declarations, so there is a single Database identity and skipLibCheck applies. Import specifiers and runtime behaviour are unchanged (verified by an end-to-end demo build exercising route injection).

  • tsdown: route entrypoints are fed via inputOptions.input (a literal object) rather than entry globs — Astro's [param] dynamic-route directories are glob character-classes, so any glob-based entry silently drops routes nested under a bracketed segment. entryFileNames and resolveRoute share one routeArtifactName() (single source of truth) so rolldown's reserved [name]/[hash] output placeholders cannot mangle dynamic-route artifacts. ./ui and .astro exports remain source by necessity — the consumer's Astro build must process them.
  • The earlier exploratory fixture-based consumer-typecheck harness is replaced by a fast static guard (scripts/typecheck-public-source.mjs, wired into the CI typecheck job): it fails if any subpath export ships raw .ts/.tsx again. Once raw source isn't shipped there is no raw-source graph to type-check, so a static export-shape check is the whole guarantee.

Verified green: pnpm build, pnpm typecheck, demos + templates typecheck, demo build with route injection, lint at the existing baseline (PR adds 0), formatting.

Known follow-up (tracked, not in scope here)

packages/core/locals.d.ts imports EmDashHandlers from ./dist/types.d.mts, a path tsdown never emits (it is ./dist/astro/types.d.mts), so Astro.locals.emdash is any for all consumers today. The one-line path fix un-masks a latent Database/AuthTables invariance cascade (e.g. @emdash-cms/auth-atproto), so it is a separate, deliberate follow-up.

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 (PR adds 0 diagnostics; repo baseline unchanged)
  • pnpm test passes (or targeted tests for my change) — verified via pnpm build + full typecheck + an end-to-end demo build exercising route injection; the static guard is the regression test
  • pnpm format has been run
  • I have added/updated tests for my changes — scripts/typecheck-public-source.mjs guards against reshipping raw source
  • User-visible strings in the admin UI are wrapped for translation (if applicable) — N/A
  • I have added a changeset — two emdash patch changesets (wordpress-plugin narrowing; compile source-exported subpaths)
  • New features link to an approved Discussion — N/A (not a feature)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7

Closes #1053.

Two parts:

1. wordpress-plugin.ts: the analyze-endpoint error body from
   response.json() is unknown under @cloudflare/workers-types; narrow
   it before reading .message (was the reported TS18046). The other
   reported error (byline.ts kysely Transaction variance) was TS5.x
   behaviour, resolved by the TS6 upgrade in #1074.

2. Stop shipping raw .ts for the source-exported subpaths
   (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas,
   emdash/auth/providers/*). They are compiled to dist (.mjs +
   .d.mts), so a strict consumer's tsc only ever sees declarations
   (skipLibCheck covers them), eliminating the dual-package Database
   identity wall that is #1053's root cause. ./ui and .astro stay
   source (the consumer's Astro build must process them).

   - tsdown: route entrypoints fed via inputOptions.input (literal
     object, not entry globs -- [param] dirs are glob char-classes).
     entryFileNames + resolveRoute share one routeArtifactName() so
     rolldown's reserved [name]/[hash] placeholders cannot mangle
     dynamic-route artifacts.
   - A fast static guard (scripts/typecheck-public-source.mjs, wired
     into CI) fails if any subpath export ships raw .ts/.tsx again.

Verified: pnpm build, pnpm typecheck, demos+templates typecheck,
demo build (route injection e2e), lint baseline unchanged.
Copilot AI review requested due to automatic review settings May 17, 2026 09:26
@changeset-bot

changeset-bot Bot commented May 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 229b5dd

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

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-perf-coordinator 229b5dd May 17 2026, 11:53 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-i18n 229b5dd May 17 2026, 11:53 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 229b5dd May 17 2026, 11:54 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 229b5dd May 17 2026, 11:54 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 17, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 229b5dd May 17 2026, 11:55 AM

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

This PR addresses strict TypeScript consumer failures by narrowing the WordPress plugin analyze error body and moving several exported EmDash subpaths from raw source to compiled artifacts/declarations.

Changes:

  • Adds a public export guard to prevent most raw .ts/.tsx subpath exports from returning.
  • Updates tsdown/package exports/route resolution to emit and resolve compiled route/API/auth-provider artifacts.
  • Narrows response.json() error handling in the WordPress plugin import source.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/typecheck-public-source.mjs Adds CI guard against raw TypeScript source in public exports.
packages/core/tsdown.config.ts Adds route entry discovery, artifact naming, compiled public subpath entries, and broader externals.
packages/core/src/import/sources/wordpress-plugin.ts Narrows unknown JSON error body before reading message.
packages/core/src/astro/integration/routes.ts Resolves injected routes through compiled/sanitized route artifacts.
packages/core/src/astro/integration/route-naming.ts Adds shared route artifact sanitization helper.
packages/core/package.json Repoints route/API/auth-provider exports to compiled dist files.
.github/workflows/ci.yml Runs the new public-source guard in CI.
.changeset/wordpress-plugin-error-narrowing.md Adds patch changeset for WordPress plugin narrowing.
.changeset/compile-source-exported-subpaths.md Adds patch changeset for compiled subpath exports.
Comments suppressed due to low confidence (1)

packages/core/src/astro/integration/routes.ts:37

  • This fallback no longer resolves a usable source route when emdash/routes/* cannot be resolved. In source/dev or unbuilt test runs the files under src/astro/routes still have their original .ts names (including bracketed dynamic segments), but this now falls back to sanitized .mjs paths under src/astro/routes, which do not exist. That breaks the documented "dist not yet built" path and source-imported tests/development.
		// Fallback for development (e.g. dist not yet built).
		return isAstro
			? resolve(__dirname, "../routes", route)
			: resolve(__dirname, "../routes", `${specifier}.mjs`);

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

Comment on lines 30 to +32
try {
// Try to resolve as package export
return require.resolve(`emdash/routes/${route}`);
return require.resolve(`emdash/routes/${specifier}`);
Comment on lines +43 to +45
// `.ts`/`.tsx` source, but NOT `.d.ts` declarations (those are the desired
// shipping form -- `skipLibCheck` covers them).
const RAW_SOURCE = /(?<!\.d)\.tsx?$/;
Comment on lines +48 to +51
"./routes/*": {
"types": "./dist/astro/routes/*.d.mts",
"default": "./dist/astro/routes/*.mjs"
},
Comment on lines +13 to +18
* Mirror each entry's path under src/ into dist/, preserving the original
* filename verbatim. tsdown/rolldown's default name template rewrites `[` and
* `]` to `_`, which would mangle dynamic-route entrypoints
* (`[collection]`, `[...path]`) and decouple `emdash/routes/*` resolution from
* the real filenames. Mirroring keeps dist a 1:1 image of src so route
* injection resolves entrypoints by their actual paths.
…dle them

Compiling the route/admin entries made tsdown try to bundle deps it
could not resolve at build time -- 'emdash' (the package importing
itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI
escalates tsdown's bundling advisory to a fatal error.

- Externalize 'emdash' (self): compiled routes import it; resolved at
  the consumer's runtime where the package is installed.
- Externalize @aws-sdk/* (optional S3 deps, runtime-only).
- Keep the *-admin.tsx providers as source (bridge the admin React +
  @cloudflare/kumo runtime, like .astro/./ui); revert their exports.
- inlineOnly: false -- nothing is unintentionally bundled (all deps
  external, only our own src is); silences the CI-escalated advisory.

Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).
ascorbic added a commit that referenced this pull request May 17, 2026
locals.d.ts imported EmDashHandlers from ./dist/types.d.mts, a path
tsdown never emits (it is ./dist/astro/types.d.mts). The augmentation
silently resolved to nothing, so Astro.locals.emdash was `any` for
every consumer. Point it at the real artifact.

This un-masks one real, previously-hidden mismatch: auth-atproto's
callback.ts passed Kysely<Database> to createKyselyAdapter (expects
Kysely<AuthTables>). Fixed with the canonical cast already used in
core's cleanup.ts (Database uses Generated<> wrappers that confuse
structural checks; the adapter casts internally; safe at runtime).

Stacked on the compile-subpaths change (#1076): with routes compiled,
fixing locals only surfaces this single bounded mismatch rather than
the dual-package wall.

Verified: pnpm typecheck, demos+templates typecheck, lint baseline
unchanged, public-source guard.
@pkg-pr-new

pkg-pr-new Bot commented May 17, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 229b5dd

resolveRoute resolves emdash/routes/* to the compiled dist artifact
with routeArtifactName applied ([ ] -> _), so the media catch-all
route's entrypoint is api/media/file/_...key_ not [...key].ts. The
catch-all pattern assertion (the actual guarantee) is unchanged.
ascorbic added a commit that referenced this pull request May 17, 2026
locals.d.ts imported EmDashHandlers from ./dist/types.d.mts, a path
tsdown never emits (it is ./dist/astro/types.d.mts). The augmentation
silently resolved to nothing, so Astro.locals.emdash was `any` for
every consumer. Point it at the real artifact.

This un-masks one real, previously-hidden mismatch: auth-atproto's
callback.ts passed Kysely<Database> to createKyselyAdapter (expects
Kysely<AuthTables>). Fixed with the canonical cast already used in
core's cleanup.ts (Database uses Generated<> wrappers that confuse
structural checks; the adapter casts internally; safe at runtime).

Stacked on the compile-subpaths change (#1076): with routes compiled,
fixing locals only surfaces this single bounded mismatch rather than
the dual-package wall.

Verified: pnpm typecheck, demos+templates typecheck, lint baseline
unchanged, public-source guard.
@ascorbic
ascorbic merged commit 6e62b90 into main May 17, 2026
38 of 39 checks passed
@ascorbic
ascorbic deleted the fix/1053-compile-subpaths branch May 17, 2026 12:02
ascorbic added a commit that referenced this pull request May 17, 2026
* fix: resolve #1053 type errors for strict consumers

Closes #1053.

Two parts:

1. wordpress-plugin.ts: the analyze-endpoint error body from
   response.json() is unknown under @cloudflare/workers-types; narrow
   it before reading .message (was the reported TS18046). The other
   reported error (byline.ts kysely Transaction variance) was TS5.x
   behaviour, resolved by the TS6 upgrade in #1074.

2. Stop shipping raw .ts for the source-exported subpaths
   (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas,
   emdash/auth/providers/*). They are compiled to dist (.mjs +
   .d.mts), so a strict consumer's tsc only ever sees declarations
   (skipLibCheck covers them), eliminating the dual-package Database
   identity wall that is #1053's root cause. ./ui and .astro stay
   source (the consumer's Astro build must process them).

   - tsdown: route entrypoints fed via inputOptions.input (literal
     object, not entry globs -- [param] dirs are glob char-classes).
     entryFileNames + resolveRoute share one routeArtifactName() so
     rolldown's reserved [name]/[hash] placeholders cannot mangle
     dynamic-route artifacts.
   - A fast static guard (scripts/typecheck-public-source.mjs, wired
     into CI) fails if any subpath export ships raw .ts/.tsx again.

Verified: pnpm build, pnpm typecheck, demos+templates typecheck,
demo build (route injection e2e), lint baseline unchanged.

* style: format

* fix(build): externalize self/optional deps so route entries don't bundle them

Compiling the route/admin entries made tsdown try to bundle deps it
could not resolve at build time -- 'emdash' (the package importing
itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI
escalates tsdown's bundling advisory to a fatal error.

- Externalize 'emdash' (self): compiled routes import it; resolved at
  the consumer's runtime where the package is installed.
- Externalize @aws-sdk/* (optional S3 deps, runtime-only).
- Keep the *-admin.tsx providers as source (bridge the admin React +
  @cloudflare/kumo runtime, like .astro/./ui); revert their exports.
- inlineOnly: false -- nothing is unintentionally bundled (all deps
  external, only our own src is); silences the CI-escalated advisory.

Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).

* test: route-injection entrypoint now resolves to compiled artifact

resolveRoute resolves emdash/routes/* to the compiled dist artifact
with routeArtifactName applied ([ ] -> _), so the media catch-all
route's entrypoint is api/media/file/_...key_ not [...key].ts. The
catch-all pattern assertion (the actual guarantee) is unchanged.

* fix(types): correct shipped locals.d.ts EmDashHandlers path

locals.d.ts imported EmDashHandlers from ./dist/types.d.mts, a path
tsdown never emits (it is ./dist/astro/types.d.mts). The augmentation
silently resolved to nothing, so Astro.locals.emdash was `any` for
every consumer. Point it at the real artifact.

This un-masks one real, previously-hidden mismatch: auth-atproto's
callback.ts passed Kysely<Database> to createKyselyAdapter (expects
Kysely<AuthTables>). Fixed with the canonical cast already used in
core's cleanup.ts (Database uses Generated<> wrappers that confuse
structural checks; the adapter casts internally; safe at runtime).

Stacked on the compile-subpaths change (#1076): with routes compiled,
fixing locals only surfaces this single bounded mismatch rather than
the dual-package wall.

Verified: pnpm typecheck, demos+templates typecheck, lint baseline
unchanged, public-source guard.

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
ascorbic added a commit that referenced this pull request May 18, 2026
* fix: resolve #1053 type errors for strict consumers

Closes #1053.

Two parts:

1. wordpress-plugin.ts: the analyze-endpoint error body from
   response.json() is unknown under @cloudflare/workers-types; narrow
   it before reading .message (was the reported TS18046). The other
   reported error (byline.ts kysely Transaction variance) was TS5.x
   behaviour, resolved by the TS6 upgrade in #1074.

2. Stop shipping raw .ts for the source-exported subpaths
   (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas,
   emdash/auth/providers/*). They are compiled to dist (.mjs +
   .d.mts), so a strict consumer's tsc only ever sees declarations
   (skipLibCheck covers them), eliminating the dual-package Database
   identity wall that is #1053's root cause. ./ui and .astro stay
   source (the consumer's Astro build must process them).

   - tsdown: route entrypoints fed via inputOptions.input (literal
     object, not entry globs -- [param] dirs are glob char-classes).
     entryFileNames + resolveRoute share one routeArtifactName() so
     rolldown's reserved [name]/[hash] placeholders cannot mangle
     dynamic-route artifacts.
   - A fast static guard (scripts/typecheck-public-source.mjs, wired
     into CI) fails if any subpath export ships raw .ts/.tsx again.

Verified: pnpm build, pnpm typecheck, demos+templates typecheck,
demo build (route injection e2e), lint baseline unchanged.

* style: format

* fix(build): externalize self/optional deps so route entries don't bundle them

Compiling the route/admin entries made tsdown try to bundle deps it
could not resolve at build time -- 'emdash' (the package importing
itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI
escalates tsdown's bundling advisory to a fatal error.

- Externalize 'emdash' (self): compiled routes import it; resolved at
  the consumer's runtime where the package is installed.
- Externalize @aws-sdk/* (optional S3 deps, runtime-only).
- Keep the *-admin.tsx providers as source (bridge the admin React +
  @cloudflare/kumo runtime, like .astro/./ui); revert their exports.
- inlineOnly: false -- nothing is unintentionally bundled (all deps
  external, only our own src is); silences the CI-escalated advisory.

Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).

* test: route-injection entrypoint now resolves to compiled artifact

resolveRoute resolves emdash/routes/* to the compiled dist artifact
with routeArtifactName applied ([ ] -> _), so the media catch-all
route's entrypoint is api/media/file/_...key_ not [...key].ts. The
catch-all pattern assertion (the actual guarantee) is unchanged.

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
ascorbic added a commit that referenced this pull request May 18, 2026
* chore: harden pnpm supply-chain config

Pin pnpm (packageManager: [email protected]) so the build-script/trust schema
is deterministic, and add supply-chain hardening to pnpm-workspace.yaml:

- minimumReleaseAge 1440 (24h publish cooldown); @rolldown/* and
  @emnapi/* excluded (vite8/rolldown-rc exact-pins these per-arch
  binaries; their release cadence structurally conflicts with the
  cooldown and they are not an attack surface worth the friction)
- strictDepBuilds + explicit allowBuilds: build scripts run only for
  @parcel/watcher, sharp, better-sqlite3, esbuild, workerd;
  core-js-pure denied (donation postinstall, not needed)
- dangerouslyAllowAllBuilds false
- blockExoticSubdeps true, with an @astrojs/telemetry -> 3.3.0 override
  (infra/cache-demo's pkg.pr.new Astro cache-support preview pulls
  telemetry via URL; the override keeps the guard on)
- trustPolicy no-downgrade with a reviewed, version-pinned
  trustPolicyExclude ([email protected], [email protected], [email protected],
  @portabletext/[email protected], [email protected] -- all benign
  publish-method changes / old pre-provenance pins, not takeovers)
- verifyStoreIntegrity, strictStorePkgContentCheck, verifyDepsBeforeRun
  error

Move enable-pre-post-scripts from .npmrc to pnpm-workspace.yaml
(enablePrePostScripts: true; canonical location, also silences the
npm "unknown config" warning). Remove .npmrc entirely -- provenance
is implied by OIDC trusted publishing.

Lockfile regenerated under the hardened config with pnpm 11.1.2.

* chore: address Copilot review on supply-chain hardening

- Remove stale root pnpm.onlyBuiltDependencies (dead under pinned
  pnpm 11; allowBuilds in pnpm-workspace.yaml is the single source)
- Narrow cooldown excludes: @rolldown/* -> @rolldown/binding-*, and
  @emnapi/* -> @emnapi/core/@emnapi/runtime, so the cooldown stays
  active for JS like @rolldown/pluginutils / @emnapi/wasi-threads
- Drop the dangling CONTRIBUTING.md pointer (no such policy doc)
- Override @ungap/structured-clone to ^1.3.1 (1.3.0 deprecated,
  CWE-502)
- Regenerate the lockfile from a clean store so the astro pkg.pr.new
  tarball regains its SRI integrity (the earlier warm-store regen
  dropped it; @astrojs/cloudflare and @lunariajs/core never had SRI,
  pre-PR included -- pnpm doesn't record it for those URLs)

Re-resolved clean under pnpm 11.1.2 with the narrowed excludes.

* fix: resolve #1053 type errors for strict consumers (#1076)

* fix: resolve #1053 type errors for strict consumers

Closes #1053.

Two parts:

1. wordpress-plugin.ts: the analyze-endpoint error body from
   response.json() is unknown under @cloudflare/workers-types; narrow
   it before reading .message (was the reported TS18046). The other
   reported error (byline.ts kysely Transaction variance) was TS5.x
   behaviour, resolved by the TS6 upgrade in #1074.

2. Stop shipping raw .ts for the source-exported subpaths
   (emdash/routes/*, emdash/api/route-utils, emdash/api/schemas,
   emdash/auth/providers/*). They are compiled to dist (.mjs +
   .d.mts), so a strict consumer's tsc only ever sees declarations
   (skipLibCheck covers them), eliminating the dual-package Database
   identity wall that is #1053's root cause. ./ui and .astro stay
   source (the consumer's Astro build must process them).

   - tsdown: route entrypoints fed via inputOptions.input (literal
     object, not entry globs -- [param] dirs are glob char-classes).
     entryFileNames + resolveRoute share one routeArtifactName() so
     rolldown's reserved [name]/[hash] placeholders cannot mangle
     dynamic-route artifacts.
   - A fast static guard (scripts/typecheck-public-source.mjs, wired
     into CI) fails if any subpath export ships raw .ts/.tsx again.

Verified: pnpm build, pnpm typecheck, demos+templates typecheck,
demo build (route injection e2e), lint baseline unchanged.

* style: format

* fix(build): externalize self/optional deps so route entries don't bundle them

Compiling the route/admin entries made tsdown try to bundle deps it
could not resolve at build time -- 'emdash' (the package importing
itself) and '@cloudflare/kumo' (admin-only, not an emdash dep). CI
escalates tsdown's bundling advisory to a fatal error.

- Externalize 'emdash' (self): compiled routes import it; resolved at
  the consumer's runtime where the package is installed.
- Externalize @aws-sdk/* (optional S3 deps, runtime-only).
- Keep the *-admin.tsx providers as source (bridge the admin React +
  @cloudflare/kumo runtime, like .astro/./ui); revert their exports.
- inlineOnly: false -- nothing is unintentionally bundled (all deps
  external, only our own src is); silences the CI-escalated advisory.

Guard's allowlist generalized to RUNTIME_COUPLED (Astro + admin React).

* test: route-injection entrypoint now resolves to compiled artifact

resolveRoute resolves emdash/routes/* to the compiled dist artifact
with routeArtifactName applied ([ ] -> _), so the media catch-all
route's entrypoint is api/media/file/_...key_ not [...key].ts. The
catch-all pattern assertion (the actual guarantee) is unchanged.

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
@emdashbot emdashbot Bot mentioned this pull request May 18, 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.

Type errors in emdash 0.12.0 under strict TypeScript

2 participants