Repository navigation
fix(plugin-gateway): drop the @discordjs/structures dev snapshot dependency - #127
Conversation
…ndency Adapt the parts of @discordjs/structures the package used into its own sources: the Structure base (merged into Structure), BitField, PermissionsBitField, and the Partialize type, keeping upstream's Apache-2.0 copyright notice in each file. The four flags bitfields it shipped now derive from NumberFlagsBitField. kData, kPatch, and kClone keep their Symbol.for keys, so they stay the very same symbols as upstream's. Without the snapshot, the strictest remaining dependency requires Node.js 20, so engines.node goes from >=24.17.0 to >=20.0.0. The built export list is unchanged. Refs #121 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB
◈ PR Lens
Architecture 7 components touched across 5 lanes. Play the interactive walkthrough Inside the changed components — 2 viewsComponent view — Data structures In-tree Structure base class and entity models replacing @discordjs/structures Component view — Bitfields and permissions In-tree BitField base, PermissionsBitField, and flag utilities Data flow
Follow each request, response and payload The other flows — 1 sequence
View
Tip The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change 🪧 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 replacing @discordjs/structures with an in-package reimplementation.
Structurebase:DataTemplate, constructor,kPatch,kClone,optimizeData, andtoJSONare now defined directly onStructureinstead of delegating toBaseStructure.prototype[...].call(...).kData/kPatch/kClonekeep the sameSymbol.for("djs.structures.*")keys, verified by a new test.BitField/PermissionsBitField: copied from upstream instead of re-exported;NumberFlagsBitField(unchanged, pre-existing in this package) continues to convert 32-bit numeric enum flags tobigintviaresolve/toJSON.flags.ts:Activity/Attachment/Channel/MessageFlagsBitFieldnow extendNumberFlagsBitFielddirectly instead of the upstream re-exports, with identicalresolve/toJSONbehavior.types.ts: internalPartializetype, replacing the upstream import.package.json/lockfile: dependency removed,engines.nodewidened from>=24.17.0to>=20.0.0, matching every other package in the monorepo.- README/tests/changeset: attribution note updated, a symbol-identity test added, changeset added.
I traced Structure's constructor/[kPatch]/[kClone]/toJSON and the BitField/PermissionsBitField/flags class hierarchy against the described upstream behavior and didn't find a behavioral divergence. Each adapted file carries a /*! attribution header naming the source, copyright holders, license, and what changed, which is sufficient given the repo itself is Apache-2.0 licensed (same license, so the existing root LICENSE file already satisfies redistribution). engines.node: >=20.0.0 matches plugin-cache, plugin-api, plugin-logger, plugin-i18next, plugin-sharder, and plugin-subcommands-advanced. Remaining @discordjs/structures mentions in Mixin.ts/Channel.ts are design-convention references, not stale import claims, so they're still accurate.
Claude Sonnet | 𝕏

🔗 Linked issue
Part of #121 (item 6: production dependency on a
@discordjs/structuresdev snapshot).🧭 Context
@wolfstar/plugin-gatewaypinned@discordjs/[email protected]. That snapshot, and its@discordjs/formattersdependency, declareengines.node >= 24.17.0, which the package had to pass on to every consumer. Dev tags can also disappear or change. The package only used a small part of it: theStructurebase,BitField/PermissionsBitField, four flags bitfields, and thePartializetype.📚 Description
The parts that were used are now copied into the package (about 330 lines), and the dependency is removed. The source is the upstream TypeScript at the snapshot's own commit (
dbb749062), checked against the snapshot'sdist.kData,kPatchandkClonekeep theirSymbol.for("djs.structures.*")keys, so they are the same symbols@discordjs/structuresuses.Mixin'senrichToJSONhook still works through the samedjs.structures.mixin.toJSONkey. A new test checks the keys.mainfirst and diffed the export lists. The builtindex.d.tsdeclares the same 296 exports andindex.jsexposes the same 153 runtime exports, and neither references@discordjs/structuresany more.@discordjs/core,@discordjs/ws,@wolfstar/plugin-cacheand the peer@wolfstar/http-frameworkall require>=20. The source uses nothing newer than Node 20; the newest API isArray#toSorted. Soengines.nodegoes from>=24.17.0to>=20.0.0, like the other packages in this repo./*! … */block naming the source, both copyright holders and the license, and saying what was changed (section 4(b))./*!survives bundling; I checked it is present indist.Worth knowing when reviewing:
Structureno longer extends an upstream class; it declares those members itself. Its unused second type parameter is renamed_Omittedso the unused-parameter check passes. Callers pass it by position, so nothing breaks.BitField.resolvenow only recognises this package'sBitFieldinstances. A bitfield built with the real@discordjs/structureswould no longer resolve. Nothing in this repo does that.Key changes
src/structures/Structure.tsDataTemplate, constructor,kPatch,kClone,optimizeData,toJSON) merged in, replacing theBaseStructure.prototype[...].callworkaroundsrc/util/BitField.ts,src/util/PermissionsBitField.tssrc/util/flags.tsActivity/Attachment/Channel/MessageFlagsBitFieldnow extendNumberFlagsBitFieldwith the same behavior (resolvereturns abigint,toJSONa number)src/util/types.tsPartialize(not re-exported)package.json/pnpm-lock.yamlengines.nodeset to>=20.0.0patchType of Change
Pre-flight Checklist
main)pnpm changesetAlso checked:
pnpm lint,pnpm typecheck, and the builds of plugin-cache and plugin-gateway (attw and publint clean).🤖 Generated with Claude Code
https://claude.ai/code/session_01RBWEHLtNzWNykJMPqeqqbB
Generated by Claude Code