ClojureScript

Source map "sources" is not created correctly on windows

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Windows 7
  • Patch:
    Code

Description

To reproduce on windows 7:

  • clone clojurescript
  • run cljsc test.clj '{:source-map "test.js.map"}' > test.js
    The generated source map "sources" field contains a path to core.js.

Expected: "sources" field should contain path to core.cljs, not core.js.

Problem (closure.clj):
compiled-cljs is a map from a string to JavaScriptFile record like so:

{"c:\\src\\hacking\\out\\cljs
core.js" #cljs.closure.JavaScriptFile [...]

On windows:
for a file: (.getPath (io/file path)) => "c:\src\hacking\out\cljs\core.js"
for a url: (.getPath ^URL url) => "/c:/src/hacking/out/cljs/core.js"

To check if resulting source map should be merged with the source map of a compiled file, the code does a lookup in compiled-cljs by url path. This does not match on windows because of / vs \.

Fix:
Convert to file by (.getPath (io/file path)) then the core.clj is picked up from compiled-cljs.

I have tested on windows 7 and linux.

  1. fix-windows-sourcemap-path
    13/Oct/13 2:25 AM
    1 kB
    Jacob Mortensen
  2. fix-win-path.patch
    24/Oct/13 10:42 PM
    1 kB
    Jacob Mortensen

Activity

Hide
David Nolen added a comment -

This patch no longer applies to master can we get a new one that does? Thanks!

Show
David Nolen added a comment - This patch no longer applies to master can we get a new one that does? Thanks!
Jacob Mortensen made changes -
Field Original Value New Value
Attachment fix-win-path.patch [ 12393 ]
Hide
Jacob Mortensen added a comment -

I have attached an updated patch (fix-win-path.patch).

I did run into an error when I added :source-map to options (related to source maps), but the compiler did output a source map file that looks ok on windows.
I will take a look at the error I am seeing.

Show
Jacob Mortensen added a comment - I have attached an updated patch (fix-win-path.patch). I did run into an error when I added :source-map to options (related to source maps), but the compiler did output a source map file that looks ok on windows. I will take a look at the error I am seeing.
Hide
Jacob Mortensen added a comment -

The error I had has been fixed and applied: http://dev.clojure.org/jira/browse/CLJS-637.

Show
Jacob Mortensen added a comment - The error I had has been fixed and applied: http://dev.clojure.org/jira/browse/CLJS-637.
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: