Skip to content

Published package omits src/ but dist/**/*.js.map references it, breaking source-map consumers #2233

@marc-wilson

Description

@marc-wilson

Describe the bug

The published @modelcontextprotocol/sdk npm tarball ships dist/**/*.js.map source maps whose sources field references ../../../../src/**/*.ts, but the src/ directory is not included in the published package. Any bundler that resolves source maps (e.g. webpack's source-map-loader) fails to read the referenced TypeScript files and emits a warning for every SDK file it touches.

Verified on @modelcontextprotocol/sdk@1.29.0.

To Reproduce

Steps to reproduce the behavior:

  1. Install @modelcontextprotocol/sdk@1.29.0 in a project bundled with webpack and source-map-loader enabled (the default for @nx/webpack Node apps with sourceMap: true).
  2. Import something from @modelcontextprotocol/sdk — e.g. anything that pulls in dist/cjs/experimental/tasks/helpers.js.
  3. Run the build.

Inspecting the shipped map confirms the dangling reference:

// dist/cjs/experimental/tasks/helpers.js.map
{"version":3,"file":"helpers.js","sources":["../../../../src/experimental/tasks/helpers.ts"], ...}

The tarball contents:

package.json   // no "files" field
LICENSE
README.md
dist/          // shipped
src/           // NOT shipped

Every dist/**/*.js.map in the package has the same broken sources path, so any imported file can trigger this — the experimental tasks helpers happened to surface it for us.

Expected behavior

The shipped source maps resolve cleanly. Either the referenced src/ files are included in the tarball, or the sources are inlined into the maps (sourcesContent / --inlineSources), or the maps are not shipped at all.

Logs

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/helpers.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/helpers.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/helpers.ts'

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/interfaces.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/interfaces.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/interfaces.ts'

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/mcp-server.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/mcp-server.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/mcp-server.ts'

Additional context

Possible fixes (any one resolves it):

  1. Add "src" to the files array in package.json so the referenced TypeScript sources ship alongside the maps.
  2. Build with --inlineSources (or post-process the maps to populate sourcesContent) so consumers don't need src/ on disk — typically the cleanest option for a published library.
  3. Strip the //# sourceMappingURL= comments and omit .js.map files if maps aren't intended for downstream consumption.

Happy to open a PR for whichever direction maintainers prefer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions