shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
cjsauer 2020-11-27T15:08:02.269600Z

I’m having an issue getting shadow to ingest .js files. The use the import/export syntax as required, but they make use of a class with static fields, which for some reason is giving me a syntax error of “expecting a (“ after the field name. Is it possible that I need to tweak the closure compiler's input language setting? Commenting out all static fields allows compilation to succeed...

cjsauer 2020-11-27T15:08:34.270300Z

I did try setting the :language-in compiler option to no avail.

thheller 2020-11-27T15:09:32.270600Z

aren't static fields just a proposal for now?

thheller 2020-11-27T15:09:47.270800Z

tweaking input language is not a thing since it is already at the highest level by default

➕ 1
thheller 2020-11-27T15:10:38.271Z

I don't have a clue whether they are supported or not. if you get a compiler error maybe not.

thheller 2020-11-27T15:11:41.271200Z

if its not in any officially released JS versions then chances are good that its not supported. they often don't implement experimental features.

thheller 2020-11-27T15:14:17.271400Z

https://github.com/google/closure-compiler/issues/3477

cjsauer 2020-11-27T15:18:04.272Z

Oh I didn’t even realize that! Thank you.

cjsauer 2020-11-27T15:19:07.272900Z

I wonder, could I transpile this with Babel prior to feeding closure maybe?

jmckitrick 2020-11-27T15:33:10.273500Z

For this error: ‘Cannot infer target type in expression’ is that Closure, shadow, or something else generating that message?

jmckitrick 2020-11-27T15:33:20.273800Z

How can it be fixed?

jmckitrick 2020-11-27T15:36:48.274300Z

Thanks, I’ll try that.

thheller 2020-11-27T15:46:26.274400Z

dunno. I'd just go for class Foo {} and Foo.field = 1; or whatever

cjsauer 2020-11-27T15:54:29.275700Z

I didn’t write this code unfortunately. It’s generated. I’ll see if I can transform it prior to closure somehow. Thanks for the help.

bendlas 2020-11-27T18:45:26.282300Z

Hello, I just ran into some weirdness while porting a project from figwheel-main to shadow-cljs. Both only discovered because serving dev-http from classpath: :dev-http {9000 "classpath:www"}:

bendlas 2020-11-27T18:46:00.282600Z

• shadow finds public/index.html from a dependency, instead of in resources/public/index.html. I suspect this is because of the hardcoded special-casing of folders named *resources, because it behaves correctly, when public/index.html is in different :paths directory

bendlas 2020-11-27T18:46:41.283300Z

• when serving from classpath, the fallback to index.html necessary for client-routing, doesn't work as described in https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http.

bendlas 2020-11-27T18:46:57.283700Z

I now realize that probably both could be worked around by serving from multiple file roots. Shall I create tickets?

2020-11-27T18:59:03.285900Z

I am having a pot of trouble shimming https://github.com/cljsjs/packages/tree/master/rrule so I can use https://github.com/reup-distribution/cljs-rrule. I have created a a shim like the below in src/cljs/cljsjs:

(ns cljsjs.rrule
  (:require ["rrule" :as rrule]))

(js/goog.exportSymbol "RRule" rrule)

2020-11-27T19:00:58.286600Z

But when I call cljs-rrule.core/rrule I get #object[TypeError TypeError: Cannot read property 'call' of undefined]

thheller 2020-11-27T19:10:46.287100Z

@bendlas this likely has nothing to do with shadow-cljs but instead the ordering of the classpath by deps.edn

thheller 2020-11-27T19:11:14.287600Z

shadow-cljs doesn't filter any folders when it comes to :dev-http. it just uses the classpath as constructed by clojure

thheller 2020-11-27T19:11:38.288100Z

I don't know if that has been fixed but it didn't put :paths first for a while so the ordering was more or less random

👍 1
thheller 2020-11-27T19:11:59.288400Z

well not random but different from shadow-cljs.edn and project.clj

thheller 2020-11-27T19:12:53.289Z

@mac sorry I don't know that package. check what rrule actually is in the REPL or so.

2020-11-27T20:50:59.289500Z

@thheller (type r/rrule) => nil

2020-11-27T21:46:41.290800Z

@thhellerI figured it out 🙂 I think the structure of the js package might have changed since the cljs lib was made.

Lyderic Dutillieux 2020-11-27T23:02:44.295700Z

Hey guys, I'm thinking of reducing my modules footprint. I was wondering if it would be possible to get cljs.core and other core libs from a CDN ? I'm aware that I would lose tree-shaking capabilities, but since core libs are really stable, clojurescript is getting more and more popular and my project grows, using a CDN and client cache may be a good fit. Have anyone tried to setup this ?

lilactown 2020-11-27T23:30:52.296500Z

I don't think anyone has tried this. you not only lose tree shaking, but also the advanced optimizations that the Closure compiler does for you such as variable renaming

👍 1