In node.js express app and nodeunit tests I widely use coffeescript without saving resulting javascript files on disk to avoid project clogging by javascript translations.
When I got any error in coffeeScript file I see in console: the filename where error was occured and line number (for example 37): /pathTo_File/fileName.coffee:37. But I dont have 37th line in my coffee file!!! I have two times less lines there.
I guess that I got error on 37th row in my output javascript file, but I don't have it on disk. Coffeescript files only.
So how I can get line number with error in coffeescript file?
I understand that I can translate my coffee script file manually (using console) to js and see there line number and guess on what line I got that error on my coffee file. But maybe there is something faster.
My IDE is WebStorm and os is osX.
CoffeeScript 1.6.1 and above include support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code in the debugger. To generate source maps alongside your JavaScript files, pass the --map or -m flag to the compiler.
http://coffeescript.org/#source-maps
Related
Recently I faced a very nasty problem with source mapping using grunt-contrib-concat. Grunt-contrib-concat concatenates several .js files into one and uses source-map module for source mapping.
So breakpoints in my code paused incorrectly both in Chrome and in VS Code. (You know what is it, if you faced the same problem).
My environment: Windows 10, VS Code with Debugger for Chrome extension, Chrome browser, Node.js project with grunt-contrib-concat dependency.
It is very unefficient to debug your client-side code without correct breakpoints.
I have spent several hours to clear the problem, and finally I have found the solution. Problem was in concatenate minified .js files. After these minified files line numbers in source map become wrong.
So the solution is to exclude minified files and use normal instead.
As per the documentation of ammo.js, it says:
The most straightforward thing is if you want to write your code in C++, and run that on the web. If so, then compile your code into LLVM, link it with bullet, and compile that to JavaScript using emscripten.(The easiest way to link it is to add your .bc file to the llvm-link command in make.py.)
So how can I compile the following code written in C++ into LLVM bitcode, link it and run it on web? BulletHelloWorld example
How can I link it in make.py? Is it necessary to always use the ammo.idl file even if I want to compile a specific program and not want to expose the entire bullet library to JavaScript?
Link to make.py
So lets start with the basics. Incase you donot know about make and cmake, study it before proceeding.
First you need to build the Bullet Library from source to use it on the web. From what I can see, you need to pass in flags to build it independent of python. Study these flags and see what is required by you.
The Bullet Library is using cmake to generate the build files - so first get a makefile out of cmake and then you can “emcc make” the generated makefile.
The output of this step ie a .bc file, is to be “linked” to the output of the next step.
Now the example.cpp that you want to compile depends on some headers of the Bullet Library. So while compiling your main.cpp file you will need to pass the em++ binary the path to these headers. This once compiled should generate your main.bc
Now you need to call em++ again, but with the main.bc along with the .bc from the previous step as parameters and also provide the required output file ie js/html. In one sense we are now linking all the “.bc” files to generate js/html.
Lookout for some missing symbol “warnings” as that could mean your code wont run.
Btw all this is available on the official emscripten website, so incase of confusion you should refer it.
I am currently trying to get into NodeJS together with the SailsJS framework.
And I want to use coffeescript on the serverside aswell, but after converting all files in config/*.js to config/*.coffee properly with js2coffee, I get the following error when trying to start up the app:
config/400.coffee
SyntaxError: Unexpected token ILLEGAL
pointing to the first character in the file, which is a hashtag for a coffee comment. So it seems the app does not recognize the file as coffeescript, but searching for standard js instead.
I tried installing the package coffee-script and requireing it in
app.js
require('coffee-script');
require('sails').lift(require('optimist').argv);
but it doesn't help.
If I delete 400.coffee, the error appears in the next file 403.coffee etc.
What am I doing wrong? Isn't coffeescript allowed in the config files or am I missing something?
Coffeescript 1.7.0, released Jan 28th, 2014, changed the require('coffee-script') behavior to only load the compiler itself. Now, do load the automatic compiler for .coffee files, you must call require('coffee-script/register') before loading any coffeescript files.
Keep in mind that using this will mean that every .coffee file will be recompiled every time you start node, which could increase startup times. That may or may not be important to you though.
I'm using UglifyJS2 to compress an output file from Browserify. Browserify has generated its own source map which it tacks the bottom of the file like so:
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjo...
I've got an error my JS somewhere in one of the files I've require'd, but Chrome is telling me the error occurred somewhere in the browserify output file rather than pointing me all the way back to require'd file.
The in-source-map option doesn't say anything about base64-encodings, so I haven't set it to anything.
i think sourcemap with uglified js has not support yet.
our team deploy minified source and debug it by Chalres's Map Local or Fiddler's autoresponder with not minified source with sourcemap.
I'm using NetBeans 6.5 and I have some javascript files that it claims are binary files and won't display annotations. svn propedit shows that the svn:mime-type is text/javascript and to display the annotations on the command line I have to run "svn annotate --force file.js".
from http://subversion.tigris.org/svn_1.4_releasenotes.html:
svn blame --force Displays the output
of blame, even if the file is binary.
It looks like this is not a NetBeans-specific problem, but something related to how svn handles Your .js files. It would be good to add a proper tag to this question.
from http://subversion.tigris.org/faq.html#binary-files:
Subversion just looks at the first
1024 bytes of the file; if any of the
bytes are zero, or if more than 15%
are not ASCII printing characters,
then Subversion calls the file binary.
(...) Subversion treats the following
files as text: (...) Files with a
svn:mime-type starting "text/"
If Your javascript file contains binary data, You might consider moving it to the end of the file.
There is a chance that the property is set to " text/javascript" or something that looks like text/javascript to human, but not to the svn.
There is a chance that the file used to be binary, but it's not anymore, however You have updated Your repository while not having write access to .svn/ directory (and svn still 'thinks' the file is binary).
There is a chance You have changed the property to the right one, but have not commited it yet.
Finally, the most powerfull solution to svn problems I have ever encountered was to copy the file, delete it the from svn, commit, add the file back (from the copy) and commit. Beware: You loose change history by doing so.
I wish You good luck on finding out what has caused this problem!