Skip to content

fix: only publish src directory when something references it - #506

Merged
dsherret merged 1 commit into
denoland:mainfrom
dsherret:fix-declaration-map-src
Jul 26, 2026
Merged

fix: only publish src directory when something references it#506
dsherret merged 1 commit into
denoland:mainfrom
dsherret:fix-declaration-map-src

Conversation

@dsherret

Copy link
Copy Markdown
Collaborator

Closes #400
Closes #413

Problem

.npmignore decided whether to exclude /src/ based on JS source maps only — declaration maps were never considered. Since declarationMap defaulted to true whenever declaration was enabled and skipSourceOutput was false, the default build published .d.ts.map files pointing at ../src/foo.ts while .npmignore contained /src/:

$ npm i ./npm && cat node_modules/pkg/types/index.d.ts.map
sources: ["../src/index.ts"]

$ ls node_modules/pkg/src
(missing)

Editors follow those maps, find nothing, and "go to definition" lands nowhere — the report in #400. inlineSources does not help: it embeds sourcesContent in the JS source map only, never in a .d.ts.map.

This started when declarationMap became default-on in b5f0a23 (0.41.0); #400 was filed six weeks later.

The .js module specifiers both issues point at are not the problem — ./dom.js in a .d.ts resolves to dom.d.ts, and npm/src type checks clean under node16, nodenext, and bundler.

Fix

  • declarationMap now defaults to false, and is ignored (with a warning) when declaration is disabled or skipSourceOutput is on, since the maps have nothing to point at.
  • When declaration maps are emitted, /src/ is published so they resolve.
  • Test files under /src/ are now excluded individually. They were never listed, so anyone using sourceMap: true (which already published /src/) was shipping their test sources and test shims.

Verification

Building a package with declarationMap: true and installing it:

index.d.ts.map -> ../src/index.ts: EXISTS
dom.d.ts.map   -> ../src/dom.ts:   EXISTS

and with the default config, no .d.ts.map files are emitted and /src/ stays ignored.

deno test -A passes. Integration coverage added for both the new default and the declarationMap: true path.

The declaration maps point at `/src/`, but that directory was added to
the `.npmignore` unless JS source maps were enabled, so every package
built with `declarationMap` shipped maps that resolve to nothing and
"go to definition" landed nowhere.

Default `declarationMap` to `false` and publish `/src/` when it's turned
on. The test files in that directory are now excluded individually,
which they never were when JS source maps published it.

Closes denoland#400
Closes denoland#413
@dsherret
dsherret merged commit 9a1daa1 into denoland:main Jul 26, 2026
5 checks passed
@dsherret
dsherret deleted the fix-declaration-map-src branch July 26, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant