Javascript - Source Map (Map File)

1 - About

A source map provides a mapping between the original and the build source code (combined/minified)

This is an important element used in a debug session in order to be able to stop at breakpoint.

The location coordinates are by line and column number in the source map.

With source maps, it is possible to single step through or set breakpoints in the original source.

Source maps can be generated with two kinds of inlining:

  • Inlined source maps: the generated JavaScript file contains the source map as a data URI at the end (instead of referencing the source map through a file URI).
  • Inlined source: the source map contains the original source (instead of referencing the source through a path).
Source maps works for styling as well. See CSS - Source Map

3 - Library and IDE

3.1 - VsCode

If no source map exists for the original source or if the source map is broken and cannot successfully map between the source and the generated JavaScript, then breakpoints show up as unverified (gray hollow circles).

See VsCode - Javascript

3.2 - Webpack

The devtool option controls if and how source maps are generated for devtool.

module.exports = {
    mode: 'development',
    entry: './js/index.js',
    devtool: 'source-map',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'

where the devtool value may be:

  • source-map - a full source map is emitted
  • inline-source-map extract source maps (for instance created from typescript) and include them in the final bundle
  • cheap-eval-source-map

Running webpack through:

  • The webpack cli, the source map comes into the output directory

webpack -d

where -d is shorthand for –debug –devtool source-map –output-pathinfo

  • The webpack-dev-server. The map are emitted in memory and then then you don't see them in explorer. You can see that the source map file is emitted with the dev server

Hash: db8af9ffcce7bc166a1d
Version: webpack 3.6.0
Time: 2678ms
          Asset     Size  Chunks                    Chunk Names
      bundle.js  1.07 MB       0  [emitted]  [big]  main  1.09 MB       0  [emitted]         main


3.3 - Typescript

The sourceMap option of the compiler controls the generation of a source map.

  "compilerOptions": {
    "sourceMap": true,

4 - Management

4.1 - Devtool Enable / Disable

Web Browser - Developer Tool (devtool)

  • Chrome: Open the settings and check/uncheck the “Enable source maps” option.

5 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap