Repository navigation
Let stricter TypeScript apps and plain Node import pi-optchat/core and pi-optchat/durable - #260
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the package build and subpath export changes.
No open issues 🎉
What changed in this PR
This PR ships built JavaScript and declarations for pi-optchat/core and pi-optchat/durable, supporting stricter TypeScript consumers and plain Node imports while leaving the Pi extension entry point unchanged.
Changes:
- Adds a build and prepack step, redirects subpath exports to
dist/, and includes build output in the package. - Adds a strict Workers consumer fixture and CI checks against the packed package.
- Documents the build prerequisite for the linked Durable Object example.
| File | Description |
|---|---|
tsconfig.json |
Excludes the separately checked Workers fixture. |
tsconfig.build.json |
Emits JavaScript and declarations with rewritten import extensions. |
test/consumer-workers/worker.ts |
Exercises core and durable APIs with Workers storage types. |
test/consumer-workers/tsconfig.json |
Configures stricter, Workers-only consumer typechecking. |
test/consumer-workers/package.json |
Defines a private ESM consumer fixture. |
package.json |
Updates exports, adds build hooks, and packages dist/. |
package-lock.json |
Locks the added Workers types dependency. |
docs/durable.md |
Documents building before using the linked example. |
.gitignore |
Ignores generated dist/ output. |
.github/workflows/check.yml |
Checks packed-package types and plain Node imports. |
Review effort: Balanced
…mportingTsExtensions
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A Cloudflare Workers app with stricter settings than ours (
noUncheckedIndexedAccess,exactOptionalPropertyTypes, Workers types instead of Node's) couldn't typecheck once it importedpi-optchat/coreorpi-optchat/durable. Both pointed at our raw.tssource, so the app's compiler checked our files under the app's own settings;skipLibCheckonly skips.d.ts. Such an app got dozens of errors in our code (66 in the test app below). Plain Node couldn't load them either, since it won't strip types from files innode_modules.Fix
The package now ships
coreanddurablebuilt:tsconfig.build.jsonemits.jsand.d.tstodist/(rewriteRelativeImportExtensionsturns our.tsimports into.js), andprepackrunsnpm run build, sonpm packand the Publish workflow'snpm publishalways include it. Source stays insrc/, and our own tsconfig is unchanged: no stricter flags, no guard edits..andpi.extensionsstay on./src/index.ts: Pi loads and compiles its extensions itself, so that path works today and is left alone.Entry points changed
pi-optchat/core: nowdist/core/index.jswith typesdist/core/index.d.ts(wassrc/core/index.ts).pi-optchat/durable: nowdist/durable/index.jswith typesdist/durable/index.d.ts(wassrc/durable/index.ts).pi-optchat(the Pi extension): unchanged.Test
test/consumer-workersis a tiny Workers app (strict,noUncheckedIndexedAccess,exactOptionalPropertyTypes,skipLibCheck, only@cloudflare/workers-types) that opens a memory onSqliteStoreand buildsoptchat()andoptchatImport(). CI installs it from the tarballnpm packproduces, typechecks it, and imports both entry points in plain Node, so a missingdist/infilesfails too. The branch's first commit adds only this check, and it failed against the old exports.examples/durable-objectstill links the repo withfile:../.., so runnpm run buildfirst (noted in docs/durable.md); itstscandwrangler deploy --dry-runpass.