Skip to content

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

@sudo-barun

Description

@sudo-barun

πŸ” 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions