Skip to content

Source maps: <script type="text/coffeescript"> support? #2780

Closed

Description

@ashtuchkin

Am I missing it or there's no support for source maps when compiling coffee in browser?

Activity

  1. vendethiel commented on Mar 5, 2013

    @vendethiel
    Collaborator

    Do browsers even support that?

  2. kelp404 commented on Mar 5, 2013

    @kelp404

    👍

  3. ashtuchkin commented on Mar 5, 2013

    @ashtuchkin
    Author

    @Nami-Doc That's a good question. The current v3 specification allows it by using a data uri as sourceMappingUrl and additional parameter "sourcesContent". I'm not sure about the browser support though.

  4. ashtuchkin commented on Mar 5, 2013

    @ashtuchkin
    Author

    Just checked - it works in Chrome 25.

  5. kelp404 commented on Mar 5, 2013

    @kelp404

    include coffee-script.js
    https://github.com/jashkenas/coffee-script/blob/master/extras/coffee-script.js

    <script type="text/javascript" src="https://raw.github.com/jashkenas/coffee-script/master/extras/coffee-script.js"></script>
    <script type="text/coffeescript">
        console.log 'coffee'
    </script>
  6. vendethiel commented on Mar 5, 2013

    @vendethiel
    Collaborator

    in the long run?

    indeed. I suppose it may be useful for testing purposes ;).

  7. ashtuchkin commented on Mar 6, 2013

    @ashtuchkin
    Author

    @kelp404 Yes, I'm aware of how to use it, thank you. The question is about supporting source maps right in the browser.
    @mintplant I use it for development & testing of my product extensively. The benefit is that you can do frontend-only development with a basic static files server (I mock server requests anyway).

  8. kelp404 commented on Mar 6, 2013

    @kelp404

    @ashtuchkin Sorry, I got a mistake.

  9. hden commented on Mar 11, 2013

    @hden
    Contributor

    @ashtuchkin How did you checked comparability? Canary seems to ignore the sourcesContent option.

  10. ashtuchkin commented on Mar 11, 2013

    @ashtuchkin
    Author

    I created manually the source map, encoded original text to js string, created property sourcesContent in the source map, then base64-encoded source map and added as a sourceMapUrl to the .js file. Then viewed it in Chrome Dev Tools. Chrome 25 for Linux.

  11. hden commented on Mar 13, 2013

    @hden
    Contributor

    Got it working in Canary, too. I think this is possible if we could...

    • port JSON.stringify() since it's not supported in IE6
    • port a permissive base64 encoder that supports utf-8, because...
      • utf-8 strings are expected in source codes
      • and btoa() is not supported in IE

    I'm afraid both of them adds significant LOC to existing code base.

    In other hand, If we compile to js with horrible inline source mapping, none of these limits will apply, any thought?
    See what's been done by browserify for detail.

  12. ashtuchkin commented on Mar 14, 2013

    @ashtuchkin
    Author

    Source mapping is only supported in latest Chromes & Firefox, why should we support it in IE6?

    Sent from my iPhone

    On 12.03.2013, at 20:38, Hao-kang Den [email protected] wrote:

    Got it working in Canary, too. I think this is possible if we could...

    port JSON.stringify() since it's not supported in IE6
    port a permissive base64 encoder that supports utf-8, because...
    utf-8 strings are expected in source codes
    and btoa() is not supported in IE
    I'm afraid both of them adds significant LOC to existing code base.

    In other hand, If we compile to js with horrible inline source mapping like what's been done by browserify, none of these limits will apply, any thought?

    —
    Reply to this email directly or view it on GitHub.

  13. hden commented on Mar 14, 2013

    @hden
    Contributor

    Because extras/coffee-script.js need to run in all the browser that is currently supported.
    Or do you suggest a user agent string or a global object check to exclude source mapping in whatever browser that does not support it?

  14. ashtuchkin commented on Mar 14, 2013

    @ashtuchkin
    Author

    I would suggest first making it optional (needs to be enabled in config hash), and then check for availability of both JSON and btoa. Imho we need not rely on user agent.

    This is a small feature and I agree that we should minimize impact on both cycles and file size.

    Sent from my iPhone

    On 13.03.2013, at 20:27, Hao-kang Den [email protected] wrote:

    Because extras/coffee-script.js need to run in all the browser that is currently supported.
    Or do you suggest a user agent string or a global object check to exclude source mapping in whatever browser that does not support it?

    —
    Reply to this email directly or view it on GitHub.

  15. hden commented on Mar 14, 2013

    @hden
    Contributor

    It seems that encoded data aren't interpreted in eval'd codest

    I wan wrong see the reply from @ashtuchkin below

  16. ashtuchkin commented on Mar 16, 2013

    @ashtuchkin
    Author

    I've managed to make it work by adding sourceURL statement in addition to sourceMappingURL. Please, see https://github.com/ashtuchkin/coffee-browser-sourcemaps

  17. hden commented on Mar 16, 2013

    @hden
    Contributor

    Awsome! @ashtuchkin Are you going to make a PR? I've have a working branch based on your idea.

  18. jashkenas commented on Mar 17, 2013

    @jashkenas
    Owner

    @hden. Want to finalize and submit your branch as a PR, if it's working?

  19. ashtuchkin commented on Mar 17, 2013

    @ashtuchkin
    Author

    @hden no, feel free to submit your PR, I'll be happy to review it if needed.

  20. jashkenas commented on Mar 18, 2013

    @jashkenas
    Owner

    It's on master now, thanks to @hden.

  21. braco commented on Mar 18, 2013

    @braco

    I'm not clear on this pull, is this supposed to just work with

    <script type="text/coffeescript" src="...">
    

    ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions