Repository navigation
fix(plugin-gateway,plugin-cache,plugin-sharder): add a no-op ./register subpath export - #123
Conversation
…ter` subpath export The Stars CLI build imports `<name>/register` for every `@wolfstar/plugin-*` dependency of a project, so these three packages crashed their consumers at startup with `ERR_PACKAGE_PATH_NOT_EXPORTED`. None of them registers an `@wolfstar/http-framework` `Plugin` hook: plugin-cache and plugin-sharder never touch the framework's `Client`, and a gateway hook would run for every `Client` of the process, while `postInitialization` runs from the base constructor before `GatewayClient` sets up its gateway and cache. A workspace test now fails when a `@wolfstar/plugin-*` package lacks the subpath. Refs #121 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB
◈ PR Lens
Architecture 4 components touched across 5 lanes. Play the interactive walkthrough Data flow No data-flow sequence changed in this PR. View
Tip Click the link under each diagram to open it on a canvas you can zoom, pan and step through 🪧 More tips
Thanks for using PR Lens! It's built by Coldtea, free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full diff: a no-op ./register subpath export added to plugin-cache, plugin-gateway, and plugin-sharder, plus a workspace test guarding it.
- New
src/register.tsper package:export {};behind anoxlint-disable-next-line unicorn/require-module-specifierscomment, with a comment explaining why noPluginhook applies to that package. package.json#exports["./register"]: standardimport/types/defaulttrio pointing at./dist/esm/register.{js,d.ts};sideEffectscorrectly stays a barefalsesince these entrypoints have no real side effect (unlikeplugin-api/plugin-logger, whoseregister.tsdoes import./indexand declaressideEffectsas an array).tsdown.config.ts:entry/attwEntrypointsextended to build and type-check the new subpath.tests/register-entrypoints.test.ts: asserts every@wolfstar/plugin-*package declares the./registerexport and ships the backing file.- Changeset:
patchfor all three affected packages.
I verified rather than took the PR description's checks at face value:
oxlint -c .oxlintrc.jsonandoxlint src --fixon all three newregister.tsfiles: 0 errors, and--fixdoes not strip theexport {};— confirms the disable comment correctly defuses theunicorn/require-module-specifiers→unicorn/no-empty-fileauto-fix trap this repo has hit before.vitest run tests/register-entrypoints.test.ts: 8/8 pass.pnpm --filter @wolfstar/plugin-cache build: clean,attwandpublintboth pass on./register.- Read
GatewayClient.ts's constructor to confirm theregister.tscomment's claim is accurate:super(options)(which runs the baseClient'spreGenericsInitialization/preInitialization/postInitializationhooks) does execute beforethis.cache/this.gatewayare assigned, so a hook genuinely couldn't see them yet.
No functional issues. The no-op design is well-reasoned and matches the actual code.
Claude Sonnet | 𝕏

🔗 Linked issue
Part of #121 (item 1, the blocking one). Supersedes #122, which was closed.
🧭 Context
The Stars CLI build (
stars:plugin-registrationsin@wolfstar/vite-server) addsimport "<name>/register"to the entry for every dependency whose name matches/^@wolfstar\/plugin-[^/]+$/. It never checks the package'sexports.plugin-gateway,plugin-cacheandplugin-sharderonly export".", so a project that depends on any of them builds fine and then crashes at startup withERR_PACKAGE_PATH_NOT_EXPORTED. The issue only names gateway and cache, butplugin-sharderhas the same gap.📚 Description
Should
registeruse aPluginhook to do something? I checked, and for these three packages the answer is no. The entrypoint is intentionally a no-op (export {}):plugin-cacheandplugin-sharderdon't depend on@wolfstar/http-framework, and they never touch itsClient. The cache is passed explicitly throughGatewayClient'scacheoption, and the sharder manager runs outside the bot process. They have no hook to register.plugin-gateway: a hook runs for everyClientin the process (the sharder manager, plain HTTP clients), not only forGatewayClient. Stars injects the import for every project that depends on the package, so any side effect would reach users who never opted in. The lifecycle also doesn't fit.ClientrunspreGenericsInitialization,preInitializationandpostInitializationfrom the base constructor, beforeGatewayClient's constructor has createdgatewayandcache. ApostListenauto-connect would also double-connect withGatewayClient#start(), which already runsload → listen → connect. Everything a hook could set up,GatewayClient's own constructor already does, so a hook adds nothing.The same reasoning is written as a comment in each
src/register.ts. ThesideEffects: falseflag stays: the module is empty, so a bundler can drop the import without changing behavior.The durable fix is to make the Stars transform check
exports["./register"]before it injects the import. That code lives in@wolfstar/cli/@wolfstar/vite-server, not in this repo.Key changes
plugin-cache,plugin-gateway,plugin-shardersrc/register.ts(no-op),exports["./register"],tsdownentry+attwEntrypointstests/register-entrypoints.test.tsfails when any@wolfstar/plugin-*package lacks./register(it currently checks all 7).changeset/register-entrypoints.mdpatchfor the three packagesType of Change
Pre-flight Checklist
pnpm test: 41 files, 443 tests)pnpm changesetChecks I ran:
pnpm buildfor each of the three packages passes, with attw and publint clean on./register.node -e "await import('@wolfstar/plugin-<name>/register')"resolves for all three.pnpm lintandpnpm typecheckpass.🤖 Generated with Claude Code
https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB
Generated by Claude Code