-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
browserify v2 adds source maps #1
Comments
I've posted a problem about |
I have no idea why that happens. |
Hi. Thanks for your work. Browserify is soo cool and with source maps it's going to be even better. Unfortunately I can't get it working for me with regards to coffee script and source maps. My setup is as follows. I have a bunch of coffee scripts to be run on frontend in AFAIK browserify doesn't support external source maps, so I wrote a simple transform function to embed them (make them inline): convert = require "convert-source-map"
js = '' # Bundled code will be here
scripts = do require "browserify"
scripts
.add require.resolve "../../lib/scripts/index"
.transform (file) ->
code = ''
write = (chunk) -> code += chunk
end = ->
code = code.replace convert.mapFileCommentRegex, (match) ->
sourcemap = convert.fromMapFileComment match, path.dirname file
return sourcemap.toComment()
@queue code
@queue null
return through write, end
.bundle debug: true, (error, code) ->
if error then throw error
js = code Given example coffee script console.log "Hey ho!" what I get in (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// Generated by CoffeeScript 1.7.1
(function() {
console.log("Hey ho!");
}).call(this);
},{}]},{},[1])
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcyI6WyIvaG9tZS90YWRldXN6L1Byb2plY3RzL2RyZWRkL25vZGVfbW9kdWxlcy9icm93c2VyaWZ5L25vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCIvaG9tZS90YWRldXN6L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TG1OdlptWmxaU0pkTENKdVlXMWxjeUk2VzEwc0ltMWhjSEJwYm1keklqb2lPMEZCZVVKQk8wRkJRVUVzUlVGQlFTeFBRVUZQTEVOQlFVTXNSMEZCVWl4RFFVRlpMRk5CUVZvc1EwRkJRU3hEUVVGQk8wRkJRVUVpZlE9PVxuIl19 Decoded and pretty printed body portion of sourceMappingURL is: {
"version": 3,
"file": "generated.js",
"sources": [
"/home/tadeusz/Projects/dredd/node_modules/browserify/node_modules/browser-pack/_prelude.js",
"/home/tadeusz/Projects/dredd/lib/scripts/index.js"
],
"names": [],
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
"sourcesContent": [
"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error(\"Cannot find module '\"+o+\"'\")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
"// Generated by CoffeeScript 1.7.1\n(function() {\n console.log(\"Hey ho!\");\n\n}).call(this);\n\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiLi4vLi4iLCJzb3VyY2VzIjpbInNyYy9zY3JpcHRzL2luZGV4LmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBeUJBO0FBQUEsRUFBQSxPQUFPLENBQUMsR0FBUixDQUFZLFNBQVosQ0FBQSxDQUFBO0FBQUEifQ==\n"
]
} So I get mapping for the compiled JS file, which contains mapping to the coffee. But I was hoping to get a mapping to the original coffee source. Is that possible? |
Please keep these issues (i.e. not comments) in the browserify repo. However @lzrski have a look at coffeeify or caching coffeeify. |
I did as you suggested. Works great. Thanks. |
Please leave comments regarding browserify v2 adds source maps post here.
The text was updated successfully, but these errors were encountered: