V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
shellex
V2EX  ›  问与答

coffeescript的报错信息反馈问题

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

    @infinte 这是啥?

    @chloerei 唔。。。

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

    大部分问题这么解决都挺快
    island205
        12
    island205  
       Apr 24, 2013
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3837 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 05:18 · PVG 13:18 · LAX 22:18 · JFK 01:18
    ♥ Do have faith in what you're doing.