Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Error in build API when building with source maps on #132

Closed
plexus opened this issue Apr 18, 2017 · 8 comments
Closed

Error in build API when building with source maps on #132

plexus opened this issue Apr 18, 2017 · 8 comments
Labels

Comments

@plexus
Copy link
Contributor

plexus commented Apr 18, 2017

Given two files (see gist: https://gist.github.com/plexus/484c003eaae3c2bd4e7753c64a6ab91e)

  • package.json
  • src/birch/core.cljs

First do npm install, then start lumo with lumo -c src, and try using the build API:

$ lumo -c src
cljs.user=> (require '[lumo.build.api :as b])
cljs.user=> (b/build "src" {:target :nodejs
       #_=>                 :optimizations :advanced
       #_=>                 :output-to "birch-compiled.js"
       #_=>                 :main 'birch.core})

This works fine, but with source maps enabled:

cljs.user=> (b/build "src" {:target :nodejs
       #_=>                 :optimizations :advanced
       #_=>                 :output-to "birch-compiled.js"
       #_=>                 :source-map "birch-compiled.js.map"
       #_=>                 :output-dir "out"
       #_=>                 :main 'birch.core})

You get this:

#error {:message "failed compiling file:out/cljs/core.cljs", :data {:file "out/cljs/core.cljs"}, :cause #error {:message "failed compiling file:out/cljs/nodejs.cljs", :data {:file "out/cljs/nodejs.cljs"}, :cause #error {:message "Could not parse ns form cljs.nodejs", :data {:tag :cljs/analysis-error}, :cause #error {:message "failed compiling file:/home/arne/LambdaIsland/Episodes/command_line_tools_with_lumo/src/birch/core.cljs", :data {:file "/home/arne/LambdaIsland/Episodes/command_line_tools_with_lumo/src/birch/core.cljs"}, :cause #error {:message "Could not analyze dep cljs.nodejs", :data {:tag :cljs/analysis-error}, :cause #error {:message "Could not analyze dep clojure.string", :data {:tag :cljs/analysis-error}, :cause #error {:message "Could not parse ns form birch.core", :data {:tag :cljs/analysis-error}, :cause #object[Error Error: java.lang.RuntimeException: java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (ReferenceError) : window is not defined]}}}}}}}

It's not always this exact message, but it seems to always be something that's not defined.

e.g.

#error {:message "failed compiling file:out/cljs/core.cljs", :data {:file "out/cljs/core.cljs"}, :cause #error {:message "failed compiling file:out/cljs/nodejs.cljs", :data {:file "out/cljs/nodejs.cljs"}, :cause 
#error {:message "Could not parse ns form cljs.nodejs", :data {:tag :cljs/analysis-error}, :cause #error {:message "failed compiling file:/home/arne/LambdaIsland/Episodes/command_line_tools_with_lumo/src/birch/co
re.cljs", :data {:file "/home/arne/LambdaIsland/Episodes/command_line_tools_with_lumo/src/birch/core.cljs"}, :cause #error {:message "Could not analyze dep cljs.nodejs", :data {:tag :cljs/analysis-error}, :cause 
#error {:message "Could not analyze dep clojure.string", :data {:tag :cljs/analysis-error}, :cause #error {:message "Could not parse ns form birch.core", :data {:tag :cljs/analysis-error}, :cause #object[Error Er
ror: java.lang.RuntimeException: java.lang.RuntimeException: com.google.gwt.core.client.JavaScriptException: (TypeError) : p.getLineCount is not a function]}}}}}}}
@arichiardi
Copy link
Collaborator

arichiardi commented Aug 23, 2017

Any hint on how to contribute a solution to this? It seems like a namespace is missing completely, but not sure I am reading the error correctly.

@anmonteiro
Copy link
Owner

A namespace is not missing, it's this file here that doesn't exist:

(json/read-str (slurp (io/resource "cljs/core.aot.js.map")))

@mfikes
Copy link
Collaborator

mfikes commented Aug 24, 2017

This might be related: With recent work to add Closure Compiler support in Planck, I was encountering p.getLineCount is not a function whenever I would try to have it compose source maps for me. Looking at the code in jscomp.js you can see what appears to be a GWT compilation issue where a getter is emitted, and subsequently a property is accessed (properly).

(c,p.getLineCount()!=null?p.lineCount:-1

This is dealing with source map JSON, so no getter will exist, but the property will. I made a local revision to change that one instance of a getter to p.lineCount, and found another error of some sort waiting behind that one. At that point, I concluded that people must not be using this JavaScript port in order to compose source maps. Instead of tracking down a fix to contribute upstream, I reversed gears and did the composition myself using the facilities that exist in ClojureScript proper, here planck-repl/planck@54da01b#diff-9cd6c94b68150c0325eb5ef1bb598492R23 making use of decode-reverse, merge-source-maps, and invert-reverse-map.

@arichiardi
Copy link
Collaborator

Yep it probably is related! Thanks Mike :)

I so so wish we would not need to duplicate efforts between plank and lumo... but thanks to both for your projects, amazing stuff going on.

By the way, I contributed a lumo compiler patch to serverless-cljs-plugin (wip/lumo branch), that is where I discovered the issue.

@arichiardi
Copy link
Collaborator

arichiardi commented Aug 24, 2017

This might also be related: google/closure-compiler-js#25 (comment)

Does it mean we just need to bump the compiler version?

@mfikes
Copy link
Collaborator

mfikes commented Aug 24, 2017

@arichiardi If you npm install google-closure-compiler-js and look for p.getLineCount in node_modules/google-closure-compiler-js/jscomp.js, you'll see that the problem exists with the latest builds.

@anmonteiro
Copy link
Owner

Please read my comment above. This is not related to closure at all. Lumo is just not bundling the core.aot.js.map file.

While that Closure issue is valid, please refrain from adding noise to this issue. Happy to discuss that in a new ticket.

@arichiardi
Copy link
Collaborator

Uhm, I see it in the fileset out of write-core-analysis-caches:

│   ├── core.aot.js.map
│   ├── core.cljc
│   ├── core.cljs
│   ├── core.cljs.cache.aot._COLON_cljs.analyzer_SLASH_constants.json
│   ├── core.cljs.cache.aot._COLON_defs.json
│   ├── core.cljs.cache.aot._COLON_doc.json
│   ├── core.cljs.cache.aot._COLON_excludes.json
│   ├── core.cljs.cache.aot._COLON_externs.json

but it is true, at the REPL (io/resource "cljs/core.aot.js.map") returns nil.

@anmonteiro anmonteiro added the bug label Aug 28, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Aug 28, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Aug 29, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Aug 29, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Aug 29, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Aug 29, 2017
arichiardi added a commit to arichiardi/lumo that referenced this issue Sep 5, 2017
anmonteiro added a commit that referenced this issue Sep 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants