shellex
V2EX  ›  问与答

coffeescript的报错信息反馈问题

  •  
  •   shellex · Aug 27, 2012 · 5626 views
    This topic created in 5185 days ago, the information mentioned may be changed or developed.
    把coffeescript编译成javascript后,如果运行期有报错,报的是javascript文件的行号,翻查和阅读起来有点麻烦,诸位用coffeescript也是人肉检查的么?
    12 replies  •  1970-01-01 08:00:00 +08:00
    chloerei
    chloerei
    Aug 27, 2012
    1
    Rails 框架开发模式编译出来的 js 会在每个方法前面加上原 coffee 的行号,没仔细研究是 Rails 打的补丁还是编译工具自带的。
    shellex
    shellex
    OP
    Aug 28, 2012
    2
    @chloerei 哎?每个方法前加入coffee行号么。。。貌似没看到这个选项,node.js装的coffee
    nouh
    nouh
    Aug 28, 2012
    3
    用vim-coffeescript插件,然后加上这个配置
    vnoremap <leader>c <esc>:'<,'>:CoffeeCompile<CR>
    nnoremap <leader>c :CoffeeCompile<CR>
    command -nargs=1 C CoffeeCompile | :<args>
    infinte
    infinte
    Aug 28, 2012
    5
    这个不就是万众期待的 source map 咩?
    chloerei
    chloerei
    Aug 28, 2012
    6
    @shellex 我不能重现了……可能我是梦中看到的
    chloerei
    chloerei
    Aug 28, 2012
    7
    @shellex 原来是 scss 才有,我搞错了。
    island205
    island205
    Sep 1, 2012
    8
    @chloerei 对的,但是作为JavaScript开发者的话,通过生成的js代码判断是cs哪里出问题应该不难。
    shellex
    shellex
    OP
    Sep 2, 2012
    9
    @nouh 不不,这不是我想要的。我是生成出javascript在浏览器执行的,异常也是浏览器给的,我只是觉得跑去看js再看coffee很麻烦

    @infinte 这是啥?

    @chloerei 唔。。。

    @island205 确实不难,只是麻烦....
    infinte
    infinte
    Sep 2, 2012
    10
    @shellex
    soutce map:在 JS 和 coffeescript 源码之间建立映射关系
    大致就是 windows 编程里的 pdb……
    zhangxiao
    zhangxiao
    Oct 1, 2012
    11
    错误信息里的行号是解释成js之后的行号,所以看下是哪个文件,然后
    coffee -p /path/to/the/coffee-file | cat -n | less

    大部分问题这么解决都挺快
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1043 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:03 · PVG 03:03 · LAX 11:03 · JFK 14:03
    ♥ Do have faith in what you're doing.