fix: ensure implementations resolve correctly in minified builds#12
Merged
Conversation
Provides codebase architecture, conventions, toolchain, check commands, and resolution semantics so AI agents can work effectively in this repo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies singleton registry containing multiple singleton plugin implementations — identity, containment, singleton consistency across individual and registry resolution, registration order, and child container sharing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- tsconfig.json now covers src + __tests__ (IDE + lint) - tsconfig.build.json scoped to src only (rslib uses this) - rslib.config.ts points at tsconfig.build.json to keep tests out of dist - Move registry test into __tests__/registry/ with separate abstractions, implementations, and test files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d class names When a bundler (rspack/webpack) minifies class names, multiple singleton implementations of the same abstraction all resolve to the first one registered. The cache key in Container.resolveRegistration uses class.name which becomes identical after minification. Bug documented in __tests__/registry/bugs/SINGLETON_CACHE_KEY_COLLISION.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bundles the plugin registry fixture with rspack in production mode (minification enabled), executes the bundle, and asserts the output. Confirms all singleton plugins resolve to the first registered implementation when class names are mangled. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move bug doc to bugs/ at project root - Move simulated and rspack minification tests to __tests__/singletonCacheKeyCollision/ - Remove bug-related tests from registry test file Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Details the proposed fix using a unique registration ID instead of class.name for singleton cache keys. Includes before/after resolution flows, child container behavior, and edge cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the numeric ID approach with using the Registration object reference itself as the Map key. No new fields or counters needed — object identity is guaranteed unique even after bundler minification. This matches the approach used by inversify and tsyringe. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the string-based cache key (abstraction token + class.name) with the Registration object reference itself as the Map key. Fixes singleton cache collisions when bundlers minify class names. Also adds test plan doc for additional hardening tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds coverage analysis (89.88% stmts, 81.7% branches) identifying untested registerFactory paths and Abstraction.createComposite(). Proposes withFactory.test.ts and withAbstractionCreateComposite.test.ts to close the gaps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tsconfig.json references "node" in types array but @types/node was only available as a transitive dep locally. CI installs with --frozen-lockfile and doesn't have it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The rspack minification test imports from @rspack/core which was only available as a transitive dep from rslib. CI doesn't hoist it consistently, causing type errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pavel910
approved these changes
May 18, 2026
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.
Summary
Container.resolveRegistrationusesclass.name, which becomes identical after minification. Documented inbugs/SINGLETON_CACHE_KEY_COLLISION.mdwith root cause analysis and proposed fix directions..name) and a real rspack production-mode bundle test that confirms the collision in a realistic environment.tsconfig.jsonnow coverssrc+__tests__(IDE and lint),tsconfig.build.jsonscoped tosrconly (rslib uses this to keep tests out ofdist).AGENTS.mdwith architecture, resolution semantics, conventions, and toolchain reference.CLAUDE.mdpoints to it.Known failing tests (intentional)
4 tests fail — these document the singleton cache key collision bug and are expected to fail until the fix lands:
simulated.test.tsclass.nameis identicalrspackMinified.test.ts(x3)Test plan
pnpm lint— tsc, oxlint, oxfmt all passpnpm build— rslib producesdist/index.js+ declarations, no test files in distpnpm test— 54 passing, 4 known failures (singleton cache key collision bug)src/and__tests__/fromtsconfig.json🤖 Generated with Claude Code