HenrikJoreteg / moonboots

A set of conventions and tools for bundle and serving clientside apps with node.js
158 stars 20 forks source link

Source maps lose line number context when used libraries #36

Closed lukekarrys closed 10 years ago

lukekarrys commented 10 years ago

Because libraries are concatenated and prepended to the js source, they make the line numbers of the bundle no longer mapped to the source maps.

Thanks to @whobubble for bringing up this issue.

matiasdecarli commented 10 years ago

To workarround this, I've change the order of the prepend. Now its: the application + external libraries. If you want, I can make a pull request of this.

whobubble commented 10 years ago

There is a workaround using the browserify-shim transform. A bit verbose but working example:

package.json

  ...
  "dependencies": {
    "browserify-shim": "~3.3.1"
  },
  "browser": {
    "charFunk": "./clientapp/libraries/charFunk-1.1.1.min.js"
  },
  "browserify-shim": {
    "charFunk": "charFunk"
  }
}

add the transform into the browserify config for moonboots and activate source maps:

    ...
    browserify: {
        debug: true,
        transforms:["browserify-shim"]
    },
    ...
wraithgar commented 10 years ago

Looks like a documentation update is what's needed, to point people to browserify-shim if they want to maintain line numbers, and a warning that libraries will shift line numbers.

wraithgar commented 10 years ago

Readme updated.