microsoft / microsoft/TypeScript

Provide option to not include `sourceMappingURL` in the generated `.js` file when `sourceMap` is `true`

Open
#59,896 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔍 Search Terms
  • sourceMappingURL
  • sourceMap
✅ Viability Checklist
⭐ Suggestion

There should be a compilerOption to disable inclusion of sourceMappingURL in the generated .js file when sourceMap is true.

📃 Motivating Example

When sourceMap is true in tsconfig.json, TypeScript compiler generates .map file together with .js file and also include sourceMappingURL in .js file.

The inclusion of sourceMappingURL in .js file is one way of linking generated code with sourcemap.
Another way is to use SourceMap header.

Right now, to make use of SourceMap header without including sourceMappingURL in .js file, I have to:

  1. set sourceMap to true
  2. run npx tsc
  3. set sourceMap to false
  4. run npx tsc once again.

There should provide a compilerOption to disable inclusion of sourceMappingURL in the generated .js file.

💻 Use Cases
  1. What do you want to use this for?
    I want to use this to use SourceMap header without getting warning in browser. The benefit of using SourceMap header is that the linking of generated file to map file can be controlled by the server without regenerating .js file.

  2. What shortcomings exist with current approaches?
    sourceMappingURL is included in .js file.

  3. What workarounds are you using in the meantime?

    1. set sourceMap to true
    2. run npx tsc
    3. set sourceMap to false
    4. run npx tsc once again.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or compiler entry points are named in the issue. Start by tracing how the sourceMap compiler option controls .map emission and the sourceMappingURL comment. Done means a documented compiler option can suppress that comment while still emitting source maps, with coverage for both enabled and disabled behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.