-
Notifications
You must be signed in to change notification settings - Fork 2k
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Source maps: --join support? #2779
Comments
The main problem here is that |
+1 (yes, I'm affected by this one as well) |
I believe @jwalton has plans to address this sometime in the medium-near future. I'll defer to him on the wisest implementation. |
Well, it's certainly something I've been thinking about, but I'm not sure I know how to solve it. What should happen, from a source-map standards perspective, is that "sources" should be a list of .coffee files, and then some of these mappings should be of the five-field variety as we go from file to file. I like @mintplant 's suggestion of recoding line offsets where each file begins. What I'm thinking is we pass in a list of (lineOffset, filename) pairs to coffee-script.coffee#compile(). I think we'd also change SourceMap.addMapping() to accept an extra "filename" parameter. So, as we build the source map, we figure out which file we're in based on the current line number from the joined code, subtract the lineOffset for that file, and use the resulting line number as the source line when we call addMapping(). |
+1. @jwalton: it sounds like the way that |
I have an example of a single CommonJS module from many CoffeeScripts files debuggable in the browser and WebStorm using rebased map files. I can't reliably make Chrome stop at breakpoints. https://github.com/projmate/coffee-backbone-sourcemap The logic is here https://github.com/projmate/projmate-filters/blob/develop/src/lib/commonJsify.coffee |
+1 |
This is something I will hopefully have a chance to look at soonish. Someone on my team just pulled in snockets and started using it to join together coffee files, so I suspect we need it now, too. :) |
@jwalton I've taken over dev of snockets pthrasher/snockets and I've added srcmap support. I rewired a lot of how the internals work, but it will compile coffee, gen src maps, uglify all the other js and coffee srcs, and then concatenate the source maps and the js. I'm still working out some kinks, and it's not yet up on NPM (just on github) but it's a solid start. The goal is to get this working 100%. Though, the project desperately needs more (read: thorough and complete) tests, and some optimizations. Definitely take a look and let me know what you think. I have a working example of using it with grunt for one of my own projects if you'd like me to post that grunt task. |
@pthrasher Definitely sounds interesting! @undashes (one of my co-workers) is probably interested in this, too. |
@jwalton Cool, I've got a target date for snockets 2.0 of the end of the month. Keep an eye out, and if you would like any functionality added, let me know. |
Just adding my 👍 to this feature request — it would be super helpful to be able to |
Adding a 👍 to the "Affects me" stack. |
👍 also affected |
+1 |
+1 and @jwalton any new news? |
+1 |
When I added source map support to autoprefixer, which can also concatenate CSS, I solved the source map problem of joining files this way:
(Actually, I developed the Climap module to help with the above.) The key was to join the AST:s, not the source strings. I hope any of this helps. |
also affected |
I've had to deal with this too. My solution was to use Cake to watch the 5 files being joined, concatenate the files into a single .coffee file when any one changed, then compile the concatenated files via the coffee command, with the map flag. It works quite well. |
I've just looked into how other libraries accomplish this, sass for example adds an offset when you |
This would require the coffee --join to create a coffee file of the Thus far, after several requests, they've felt it not necessary. Use -- Owen On Mon, Dec 9, 2013 at 3:48 PM, Johan Lindskogen
|
Why does |
I "solved" that by using require.js. I'm not the biggest fan of it, because I'm used to something more straight forward from java, I guess, but it's the best way to solve something like requirements-management in JavaScript/CoffeeScript that I could find. I fear, that this will always be a pain in the JavaScript-World until they put something idiomatic into the language itself... In the end I don't have a combined file, but several single files that load each other by means of require.js. So I don't have tons of script-tags (only a single one) in the html-code and the SourceMaps work too. Greetings |
@lydell |
He's not asking what this does, he's asking why coffee is doing it. And indeed, this should be in your build tool, not in the compiler. |
The thing is, if I don't use |
Don't naively concatenate your files together to share scope. That is so 1996. Today, we use ES6 modules or CommonJS requires and compile them to a single file if that's what we need. I recommend commonjs-everywhere. |
All these issues can now be closed, yay!! |
related discussion: jashkenas/coffeescript#2779 the deprecated patch: jashkenas/coffeescript#3477
Currently the map is generated but mentions compiled .js file as "sources". AFAIK it should go for a set of original filenames.
The text was updated successfully, but these errors were encountered: