<< Back to previous view

[CLJS-637] Exception when compiler output is redirected Created: 25/Oct/13  Updated: 26/Oct/13  Resolved: 26/Oct/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Jacob Mortensen Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

windows 7

Attachments: Text File source-map-exception.patch    
Patch: Code


To reproduce on windows 7:
> cljsc ./file.cljs '{:optimizations :advanced :source-map "file.map.js"}' > file.js

results in the following stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: No implementation
of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: c
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
at clojure.java.io$fn_8496$G8491_8501.invoke(io.clj:35)
at clojure.java.io$file.invoke(io.clj:413)
at cljs.closure$add_source_map_link.invoke(closure.clj:940)
at cljs.closure$build.invoke(closure.clj:986)
at cljs.closure$build.invoke(closure.clj:945)
at user$eval2565.invoke(cljsc.clj:21)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:294)
at clojure.main$script_opt.invoke(main.clj:356)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at clojure.lang.Var.invoke(Var.java:423)
at clojure.lang.AFn.applyToHelper(AFn.java:167)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)

Source map file is generated but no file.js is generated.

Expected: When no output-to is specified then resulting js file has a sourceMappingURL that corresponding to where source map file is placed.

add-source-map-link function in closure.clj is called with output-to :print when no output-to is specified. The code then tries to open a the file :print.

In this case point sourceMappingURL to where resulting mapping file is placed:

cljsc ./file.cljs '{:optimizations :advanced :source-map "../file.map.js"}' > file.js

should result in
//@ sourceMappingURL=../file.map.js

Attached patch fixes this. It also changes //@ to //# (new format).

Weakness in solution: Only works for redirect to current dir. If the redirect is not to current directory ( [...] > ./out/file.js) then sourceMappingURL is not correct - but the compiler does not throw an exception.

I have only tested on windows.

Comment by Sean Grove [ 25/Oct/13 7:44 PM ]

Tested on osx, repro'd the issue. After applying the patch, issue is resolved. All tests still pass locally with patch applied. Haven't tried out the patch with an actual project though, just a single file.

Comment by David Nolen [ 26/Oct/13 5:06 PM ]

fixed, https://github.com/clojure/clojurescript/commit/d53e2cff0db4cb28ffdcc7554c9a9c3cfe656daa

Generated at Wed Jan 17 14:40:45 CST 2018 using JIRA 4.4#649-r158309.