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

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: