CommonJS identity control
@stackline/dynamic-dedupe
Reuse one exports object across copied and linked CommonJS trees, with a small upstream-compatible API and loader restoration designed for current Node tooling.
npm install @stackline/dynamic-dedupe
v1.0.0Node 12-24TypeScript 3.9+Zero runtime dependencies
Executable identity model
Dedupe workbench
Exports will be shared
Source, basename, and the final two parent directories match.
Three functions
The historical API, tightened.
Configuration happens at process startup. Loader changes remain explicit and reversible.
| Function | Behavior | Compatibility |
|---|---|---|
activate(ext?, depth?) | Wrap the current CommonJS loader and record matching exports. | Preserved |
deactivate(ext?) | Disable the hook and restore its predecessor when safe. | Hardened |
reset() | Forget recorded identities without clearing require.cache. | Preserved |
Loader order
Compose with existing tools.
Register a TypeScript or instrumentation hook first, then activate deduplication. The captured loader still performs compilation.
require('typescript-loader/register')
const dedupe = require('@stackline/dynamic-dedupe')
dedupe.activate('.ts', 2)
const service = require('./linked/service.ts')
Read the complete compatibility contract
Release evidence
Tested where loader hooks fail.
The verification suite exercises identity boundaries and interactions, not only happy-path exports.
- 7
- Node major lines from 12 through 24
- 3
- operating systems in CI
- 0
- runtime dependencies
- 2
- TypeScript generations checked
- SHA-256
- length-framed module identity
- Alias
- legacy package-name smoke install
Drop-in adoption
Keep existing requires.
An npm alias changes the package without changing require('dynamic-dedupe').
npm install dynamic-dedupe@npm:@stackline/dynamic-dedupe
Project resources