Skip to content

fix(build): match dts-bundle module name to the published package name - #2

Merged
raiseandfall merged 1 commit into
masterfrom
fix/dts-bundle-scoped-module-name
Oct 15, 2026
Merged

raiseandfall merged 1 commit into
masterfrom
fix/dts-bundle-scoped-module-name

Conversation

@raiseandfall

Copy link
Copy Markdown
Member

Summary

Fixes the dts-bundle invocation in build so the bundled caching.d.ts declares the ambient module under the package's real, scoped name (@learningmachine/caching) instead of the old unscoped caching.

Background

dts-bundle --name caching has been unchanged since this 2021 commit renamed the package from caching to @learningmachine/caching — the --name flag was never updated to match. The bug sat dormant because the only previously-published artifact (manually published to npmjs.org in 2021) wasn't built with this script.

Today's first-ever semantic-release run on this repo published a fresh 1.0.0 to Cloudsmith, built from current master — which hit this bug for the first time. Consumers (lm-frontend) importing from @learningmachine/caching got:

TS2306: File '.../node_modules/@learningmachine/caching/dist/caching.d.ts' is not a module.

because dist/caching.d.ts declared declare module 'caching' { ... } — a module name that doesn't match what's actually being imported.

Fix

  • --name caching → --name @learningmachine/caching, so the bundled ambient module declarations match the real import specifier.
  • Added --out caching.d.ts explicitly: dts-bundle derives the output path from --name when --out isn't given, which would've nested the file under a @learningmachine/ directory and broken the build script's cp build-temp/caching.d.ts dist/ step.

Testing

  • npm run build locally: confirmed dist/caching.d.ts now declares @learningmachine/caching and its submodules correctly; dist/index.js / dist/index-cjs.js are byte-identical to before (only the type-declaration generation changed).
  • Copied the rebuilt dist/ into a local lm-frontend checkout's node_modules/@learningmachine/caching and ran the exact failing CI command, npm run build:issuing — completed successfully with no TS2306 or any other caching-related errors (previously failed with 5 errors across 5 files).

Next steps after merge

Merging will trigger this repo's semantic-release step and publish a new version to Cloudsmith. lm-frontend's lockfile will need to be updated to pick up that new version once published.

dts-bundle was invoked with --name caching, a leftover from before the
package was renamed to the scoped @learningmachine/caching. The bundled
dist/caching.d.ts declared 'caching' (and 'caching/cache', etc.) instead
of '@learningmachine/caching', so consumers importing from the real
package name got 'TS2306: File ... is not a module' — TypeScript had no
declarations for the module they were actually importing.

Pass --out caching.d.ts explicitly so the output path stays the same
(dts-bundle derives it from --name otherwise, which would nest the file
under a '@learningmachine/' directory and break the build script's cp
step).
@raiseandfall
raiseandfall merged commit 0ef740e into master Oct 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant