question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source maps don't always map back to the original sources.

See original GitHub issue

Description

Source maps don’t always map back to the original sources.

Expected/Actual behavior

Example repo: https://github.com/lydell/brunch-sources-content-bug

public/concat.css.map is correct:

{
  "version": 3,
  "sources": [
    "app/concat1.css",
    "app/concat2.css"
  ],
  "names": [],
  "mappings": "AAAA;AACA;AACA;AACA;ACHA;AACA;AACA;AACA",
  "file": "public/concat.css",
  "sourcesContent": [
    "a {\n  color: black;\n}\n",
    "b {\n  font-weight: bold;\n}\n"
  ]
}

public/concat.js.map is correct:

{
  "version": 3,
  "sources": [
    "app/concat1.js",
    "app/concat2.js"
  ],
  "names": [],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AACA;AADA;AAAA;CCAA;AAAA;AACA;AADA;AAAA",
  "file": "public/concat.js",
  "sourcesContent": [
    "console.log('concat1')\n",
    "console.log('concat2')\n"
  ]
}

public/require.js.map is wrong. It misses the “app/_hello.js” source, and the included source content is the contents of public/require.js, not of app/main.js.

{
  "version": 3,
  "sources": [
    "app/main.js"
  ],
  "names": [],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AACA;AACA;AAFA;AAAA",
  "file": "public/require.js",
  "sourcesContent": [
    "var hello = require('./_hello')\nconsole.log(hello)\n"
  ]
}

public/sass.css.map is wrong. It misses the “app/_include.scss” source, and the included source content is the contents of public/sass.css, not of app/main.scss.

{
  "version": 3,
  "sources": [
    "app/main.scss"
  ],
  "names": [],
  "mappings": "AAAA;AACA;AACA;AACA;AACA;AACA;AACA",
  "file": "public/sass.css",
  "sourcesContent": [
    "b {\n  font-weight: bold; }\n\na {\n  color: black; }\n\n"
  ]
}

Environment

  1. Brunch: 2.10.2
  2. Node: 6.9.1
  3. NPM: 3.10.8
  4. Operating system: Ubuntu 16.04

package.json contents

{
  "private": true,
  "devDependencies": {
    "brunch": "^2.10.2",
    "css-brunch": "^2.6.1",
    "javascript-brunch": "^2.0.0",
    "sass-brunch": "^2.9.0"
  }
}

brunch config contents

module.exports = {
  files: {
    stylesheets: {
      joinTo: {
        'concat.css': /\.css$/,
        'sass.css': /\.scss$/,
      }
    },
    javascripts: {
      joinTo: {
        'concat.js': /concat\d\.js$/,
        'require.js': 'app/main.js'
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
sehcheesecommented, May 1, 2017

Any fixes coming down the pipes for this? Is the temporary fix to use 2.9.1?

3reactions
shvaikaleshcommented, Apr 13, 2017

Yep, it is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4 Reasons Why Your Source Maps are Broken - Sentry Blog
This likely means that your source map doesn't contain or link to your original source files. Without your original source files, you're still ......
Read more >
How to use sourcemaps to restore the original file?
Open up the source map in a text editor, and you'll see that it's mostly just a simple JSON object. The “sources” field...
Read more >
508270 - Source maps cache not refreshed - chromium
When it's not "broken," the source map tabs close and come back up after reload. I suspect disabling the cache for sourcemaps somehow...
Read more >
Should I Use Source Maps in Production? | CSS-Tricks
A “source map” is a special file that connects a minified/uglified version of an asset (CSS or JavaScript) to the original authored version....
Read more >
Source maps in Node.js. Supporting the many flavors of…
The Source Map V3 specification. Source maps provide a method for translating from generated source back to the original, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found