Fork me on GitHub
#shadow-cljs
<
2020-06-02
>
superstructor05:06:40

Has anyone come across this kind of issue when trying to require an npm package ? The file is valid JS, but I guess it could be using some features that Google Closure doesn't support ?

Build failure:
Failed to inspect file
  ...\node_modules\prettier\index.js

it was required from
  ...\codemirror.cljs

Errors encountered while trying to parse file
  ...\node_modules\prettier\index.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}

RuntimeException: Exception parsing ".../node_modules/prettier/index.js"
        com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:155)

David Pham05:06:26

Did you install prettier?

David Pham05:06:03

Maybe reinstall it?

David Pham05:06:27

Or maybe it is not valid JavaScript.

thheller07:06:18

@superstructor please always post the full errors. I can reproduce this and I get a closure compiler error. seems to be something in the file it doesn't like. not sure what.

IllegalArgumentException: Must call rewindTo before calling getSourcePosition for an earlier line (1298797 < 1300077)
	com.google.common.base.Preconditions.checkArgument (Preconditions.java:300)
	com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourcePosition (LineNumberScanner.java:46)
	com.google.javascript.jscomp.parsing.parser.LineNumberScanner.getSourceRange (LineNumberScanner.java:58)
	com.google.javascript.jscomp.parsing.parser.Scanner.getTokenRange (Scanner.java:100)

superstructor10:06:39

Thanks for following it up @thheller :thumbsup: 🙂 and apologies for cutting the error output short.

thheller10:06:27

no biggy. I know that those kind of errors mean internal closure compiler problems, just easier to guess which one with the full trace 🙂

thheller10:06:37

are you including this in a browser build? the prettier package is pretty node focused so I wouldn't have much faith in it working in the browser

superstructor11:06:38

Yeah I was trying it in a browser build but I ended up trying js-beautify for now which appears to work OK. Not a critical feature.

Eliraz12:06:35

hello, doe's anyone here has an experience with devcards? I've finally made devcards "work" but I get no components rendered on the screen, all I see is the `devcards` title and clojurescript logo.. how do I tell devcards to render those cards I have?

thheller12:06:10

@eliraz.kedmi if you setup a reproducible example I can take a look and see if its a setup issue. otherwise no clue about devcards.

Eliraz12:06:51

@thheller how can I do that?

Eliraz12:06:17

is there an online env for clojurescript?

thheller12:06:25

create a github repo with instructions on how to produce the problem

Eliraz12:06:37

sure I'll do that

Eliraz12:06:43

Thank you!

Felipe Marques21:06:16

I'm trying to add some custom reader tags to my cljs project. It works as expected by when recompilation is triggered by editing some file, I get the following error:

#copy :inclusion.home/inclusion-card-title
----------------^---------------------------------------------------------------
my_app/core.cljs [line 26, col 10] No reader function for tag copy.
Does any one have faced this problem.

Felipe Marques21:06:33

I added the require to my main-ns to gurantee that the tag is registered

Felipe Marques21:06:50

I register the tag like this

(cljs.reader/register-tag-parser! 'copy (fn [kw] (copy kw)))

thheller21:06:20

shadow-cljs does not support custom reader tags in source files and never will, unless someone can give me a really convincing reason. so far noone has.

thheller21:06:25

there is literally no reason to ever use it in source code. absolutely fine and useful for data.

thheller21:06:55

just call (copy :inclusion.home/inclusion-card-title) directly instead of #copy :inclusion.home/inclusion-card-title.

thheller21:06:19

cljs.reader is for reader tags in data parsed by cljs.reader is is not for source code.

thheller21:06:17

eg. (cljs.reader/read-string "#copy :foo") is totally fine and you have total control over that

Felipe Marques22:06:58

humm, I understand. It was a more stylistic choice than regarding any functionality. I'll use the function directly.

thheller22:06:19

FWIW custom reader tags in code are an absolute nightmare for tooling

👀 4
4
thheller22:06:06

since its impossible to tell what you are doing in the read fn and it occurs during read time ...

thheller22:06:39

macros or regular functions already let you do everything you can possibly want to do, just in a more well defined manner