Fork me on GitHub
#shadow-cljs
<
2018-08-17
>
richiardiandrea00:08:02

what does this mean in practical terms? I cannot use set! on goog-define?

Closure compilation failed with 4 errors
--- registry/aws_test.cljs:16
@define variable registry.PROVIDER assignment must be global

thheller05:08:20

goog.define are compile time constants, so no you cannot set! them

richiardiandrea16:08:13

yes, however sometimes you want to use it in your tests

richiardiandrea16:08:28

I have seen the pattern used in the wild as well

thheller16:08:03

then set them via :closure-defines in the test build?

thheller16:08:49

they are constants with special treatment by the compiler so closure will really not like you messing with them

richiardiandrea17:08:05

uhm ok, yeah but I'd have to split my conf for each and every value of it then...I found that vanilla cljs allows this, I frankly don't know why, maybe older GCC...in any case for now it is ok

richiardiandrea17:08:45

maybe I should just use a :^dynamic var containing a goog-define for this...still deciding

thheller17:08:30

well then you lose all the benefit of a goog-define in the first place. I don't know what you are trying to do in the first place but registry.PROVIDER looks like it is actually a runtime configuration option and not a compile time constant.

richiardiandrea17:08:39

at the beginning it was, I still need to make it so by using the shadow's conditional reader features but it is not a prio so I will convert it to ^:dynamic for this iteration

chgraham02:08:48

[edit] Ok, at https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#what-is-the-hints-feature I finally noticed that I can enter, at the REPL: (devtools.core/install! [:formatters :hints]) Also, to make the documentation better, it should be explained exactly where the following configuration is written: :external-config { :devtools/config { :features-to-install [:formatters :hints] :fn-symbol “F” :print-config-overrides true}} I assume it’s written in cljs-build configuration. I’m using shadow-cjls, not cljs-build. -------------------------------------------------------------------------------- I’m using Cursive and running this command from an IntelliJ terminal: lein with-profile +dev-cljs run -m shadow.cljs.devtools.cli watch :app …so when my web page loads, I see: Installing CLJS DevTools 0.9.10 and enabling features :formatters (with :hints and :async greyed out - the latter two weren’t loaded). How can configure project.clj or shadow-cljs.edn - or employ some other tactic - so that I can activate the :hints functionality of CLJS DevTools, i.e., DevTools? (PS, here is relevant portion of project.clj :profiles {:dev-cljs {:dependencies [[binaryage/devtools “0.9.10"] [thheller/shadow-cljs “2.5.1”]]}} and here is shadow-cljs.edn {:source-paths [“src”] :nrepl {:port 3333} :lein {:profile “+dev-cljs”} :builds {:app {:target :browser :output-dir “public/js” :asset-path “/js” :modules {:main {:entries [giggin.core]}} :devtools {:after-load giggin.core/main :http-root “public” :http-port 3000}}}}

thheller05:08:52

:app {... :compiler-options {:devtools/config {:features-to-install ...}}} I believe

thheller05:08:33

:external-config as described in the docs is :compiler-options in shadow-cljs.edn

endenwer05:08:35

Hey guys, does anyone know how to enable css live reloading for electron?

thheller06:08:49

@endenwer how does electron deal with CSS? how are the files included?

endenwer06:08:34

I am trying to make it work with this example https://github.com/ahonn/shadow-electron-starter.

endenwer06:08:58

Config

;; shadow-cljs configuration
{:source-paths ["src"]

 :dependencies [[reagent "0.8.0-alpha2"]
                [cider/cider-nrepl "0.18.0-SNAPSHOT"]]

 :builds {:main {:target :node-script
                 :output-to "resources/main.js"
                 :main app.main.core/main}

          :renderer {:target :browser
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:init-fn app.renderer.core/start!}}
                     :devtools {:after-load app.renderer.core/start!
                                :watch-dir "resources/public"}}}}

endenwer06:08:37

There is a library for that https://github.com/Quramy/electron-connect but as I know it reloads everything not just css

thheller06:08:18

hmm it has trouble with the file:// urls electron returns for document.location.href

chrisetheridge09:08:08

so i’m trying to run karma, to test my outputted js files

chrisetheridge09:08:31

those dependencies that are not found are in the “dependencies” key in package.json , and i’ve npm install’d

thheller09:08:51

I guess this code fails

thheller09:08:53

if (util && util.inspect && util.inspect.custom) {
  module.exports.prototype[util.inspect.custom] = function () {
    var obj = util.inspect({ length: this.length });
    return this.constructor.name + ' ' + obj;
  };
}

chrisetheridge09:08:22

any reason why that would fail?

chrisetheridge09:08:29

even after an explicit npm install it still does not work

thheller09:08:40

there is nothing for you to install

thheller09:08:27

compilation would fail if it were missing any packages. the code is just weird

chrisetheridge10:08:10

which code? mine? i.e is this something i can fix?

thheller10:08:33

no the JS code in node_modules/readable_stream

thheller10:08:50

you probably can't fix it no

chrisetheridge10:08:58

poo. well i’m using that to resolve stream

chrisetheridge10:08:04

:resolve {"object.assign" {:target :npm :require "object-assign"}
                              "stream"        {:target :npm :require "readable-stream"}}

chrisetheridge10:08:07

so could maybe try remove that?

thheller10:08:25

uhm yeah don't do that

chrisetheridge10:08:54

if i dont:

[:ci] Compiling ...
symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
{:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object-assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object.assign/index.js"]}
ExceptionInfo: symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource "node_modules/object-assign/index.js"], conflict with [:shadow.build.npm/resource "node_modules/object.assign/index.js"]
	clojure.core/ex-info (core.clj:4739)
	clojure.core/ex-info (core.clj:4739)

thheller10:08:08

sorry I meant don't do the stream override

chrisetheridge10:08:14

okay let me try that

thheller10:08:14

object.assign is fine

thheller10:08:33

shadow-cljs has a few built-in node overrides for browser builds

thheller10:08:42

and you just interfered with one of them 😉

chrisetheridge10:08:16

The required JS dependency "readable-stream/writable.js" is not available, it was required by "node_modules/stream-browserify/index.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install readable-stream/writable.js

chrisetheridge10:08:40

trying the readable-stream/writable.js. but i’ve installed readable and stream

chrisetheridge10:08:52

yeah that repo doesn’t exist (writable.js)

thheller10:08:56

you probably installed too many packages

thheller10:08:03

or rather the wrong ones

chrisetheridge10:08:05

ill clean node modules

thheller10:08:08

all of those should be ... wait ... do you have shadow-cljs and a dependency in your package.json?

thheller10:08:40

I made that optional a while ago and this has caused sooo much trouble

thheller10:08:46

it definitely was not worth removing it

thheller10:08:06

remove util and buffer definitely

thheller10:08:29

them rm -rf node_modules

thheller10:08:00

npm install should definitely install the node_modules/readable-stream then

chrisetheridge10:08:32

trying that now

thheller10:08:57

npm can be a PITA sometimes

chrisetheridge10:08:19

➜  Monolith git:(shadow-cljs) ✗ shadow compile ci --debug
shadow-cljs - config: /Users/chrisetheridge/code/Cognician/Monolith/shadow-cljs.edn  cli version: 2.5.1  node: v10.8.0
shadow-cljs - starting 2.5.1 with launcher 2.1.0 ...
[:ci] Compiling ...
The required JS dependency "readable-stream/readable.js" is not available, it was required by "node_modules/stream-browserify/index.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install readable-stream/readable.js

See: 

➜  Monolith git:(shadow-cljs) ✗

thheller10:08:12

does node_modules/readable-stream exist? if so check its package.json please

chrisetheridge10:08:32

no it doesn’t

thheller10:08:09

hmm? are you running npm in the wrong directory or something?

chrisetheridge10:08:20

nah definitely in the right dire

thheller10:08:25

try deleting node_modules and package-lock.json again

chrisetheridge10:08:35

lol doing that now as a try

thheller10:08:44

I don't understand why it wouldn't install the package?

chrisetheridge10:08:10

ah that worked!

chrisetheridge10:08:15

package-lock was out of sync i guess

chrisetheridge10:08:44

does that happen often?

thheller10:08:17

yeah .. npm sucks ...

urbanslug10:08:20

is there a way to reduce how much memory shadow-cljs is using?

urbanslug10:08:38

Have an 8G laptop and having trouble

thheller10:08:08

you can set :jvm-opts ["-Xmx1G"] in shadow-cljs.edn

👍 4
thheller10:08:19

that would limit it to 1gb

thheller10:08:32

can try -Xmx512m

thheller10:08:06

maybe 256m but at that point you'll run into problems I think

chrisetheridge10:08:21

[:ci] Compiling ...
The required JS dependency "react-dom/test-utils" is not available, it was required by "node_modules/enzyme-adapter-react-15/build/ReactFifteenAdapter.js".

Searched in:/Users/chrisetheridge/code/Cognician/Monolith/node_modules

You probably need to run:
  npm install react-dom/test-utils
i’m guessing i need to add a :resolve key for this?

thheller10:08:13

is react-dom not installed?

thheller10:08:23

and no you don't need :resolve for this

thheller10:08:44

whenever you see a message like this

thheller10:08:01

check /Users/chrisetheridge/code/Cognician/Monolith/node_modules + react-dom/test-utils

thheller10:08:25

/Users/chrisetheridge/code/Cognician/Monolith/node_modules/react-dom/test-utils.js

thheller10:08:04

the error message isn't ideal. it should list the full paths it tried to find

chrisetheridge10:08:49

ah okay. let me check that

chrisetheridge10:08:52

i’ve installed react-dom

thheller10:08:02

it was in your deps so it should be there

thheller10:08:29

but you pinned the version to exactly 15.0.0

thheller10:08:36

thats probably not ideal

thheller10:08:43

it may just not exist in that version

chrisetheridge10:08:59

yeah that’s most probably the reason. going to see if i can bump it

chrisetheridge10:08:11

oh i can use 16

thheller10:08:58

probably don't have to bump to the latest react. just something more recent from the 15.x branch

thheller10:08:10

15.0.0 is probably just bad

chrisetheridge10:08:44

yeah that worked 🙂 thank you

chrisetheridge10:08:48

is it possible to use a runner ns with karma?

chrisetheridge10:08:53

if i use a runner ns, i get init is not defined

chrisetheridge10:08:07

➜  Monolith git:(shadow-cljs) ✗ karma start --single-run
17 08 2018 12:38:56.254:INFO [karma]: Karma v2.0.5 server started at 
17 08 2018 12:38:56.259:INFO [launcher]: Launching browser ChromeHeadless with unlimited concurrency
17 08 2018 12:38:56.267:INFO [launcher]: Starting browser ChromeHeadless
17 08 2018 12:38:56.619:INFO [HeadlessChrome 0.0.0 (Mac OS X 10.13.6)]: Connected on socket B0WRKA9GuQOl0l4wAAAA with id 88087934
HeadlessChrome 0.0.0 (Mac OS X 10.13.6) ERROR
  {
    "message": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n    at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n    at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at ",
    "str": "Uncaught TypeError: Cannot read property 'init' of undefined\nat : Cannot read property 'init' of undefined\n    at eval (eval at <anonymous> (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7), <anonymous>:1:19)\n    at ContextKarma.start (/Users/chrisetheridge/code/Cognician/Monolith/node_modules/karma-cljs-test/adapter.js:6:7)\n    at ContextKarma.loaded ()\n    at "
  }

thheller10:08:05

are you using a custom :runner-ns?

chrisetheridge10:08:42

can you not use a custom one?

thheller10:08:48

then you must adjust your karma config accordingly

thheller10:08:59

it tries to call client: {args: ["shadow.test.karma.init"]

chrisetheridge10:08:01

ah of course. it hooks into shadows one

chrisetheridge10:08:07

doh thanks dude

chrisetheridge11:08:50

[0:0]~cljs.user=> (require '["enzyme-adapter-react-16" :as Adapter])
[:result {:type :repl/error, :ex #error {
 :cause "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
 :data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "symbol module$node_modules$object_assign$index already provided by [:shadow.build.npm/resource \"node_modules/object.assign/index.js\"], conflict with [:shadow.build.npm/resource \"node_modules/object-assign/index.js\"]"
   :data {:provide module$node_modules$object_assign$index, :conflict [:shadow.build.npm/resource "node_modules/object.assign/index.js"], :resource-id [:shadow.build.npm/resource "node_modules/object-assign/index.js"]}
   :at [clojure.core$ex_info invokeStatic "core.clj" 4739]}]
i get this when trying to require that npm dep? regardless of :as or :refer

chrisetheridge11:08:28

in a shadow-cljs browser-repl

chrisetheridge11:08:52

nvm. hit this before. i was on the wrong build

chrisetheridge11:08:03

hmm i still cannot require this module properly

chrisetheridge11:08:09

["enzyme-adapter-react-16" :default Adapter]

thheller11:08:14

browser repl doesn't have the :resolve setting

chrisetheridge11:08:21

regardless of :default :refer or :as, i get undefined each time

thheller11:08:46

read the error message. none of that matters

chrisetheridge11:08:24

i get no error message. printing the required object gives me undefined

thheller11:08:23

hmm? you just posted an error above?

chrisetheridge11:08:42

that was in the browser repl. i wanted to debug the require from there. but dropped that cause of the resolution errors

endenwer11:08:38

Fix for loading files with absolute paths in electron. With this live reloading will work.

thheller11:08:53

@endenwer I can fix the live reload, its just getting confused because of the file: url since I didn't expect that it just assumes http semantics currently.

thheller11:08:00

no need to hack into electron to make this work

endenwer11:08:19

This is from https://github.com/electron/electron/issues/2242. I din't find another way to fix live reloading

thheller11:08:46

@endenwer I can fix it .. just not right now.

endenwer11:08:29

You mean in shadow-cljs?

thheller14:08:08

@henrik try running shadow-cljs stop and then shadow-cljs server. it probably fails on startup.

thheller14:08:39

may be related to the new launcher though. I'm currently reworking that again to fix a few things

thheller14:08:56

you can just downgrade to 2.4.33

henrik14:08:07

I see. Are you storing logs somewhere that I can send you?

thheller14:08:19

there should be one in .shadow-cljs/*.log

henrik14:08:33

Downgrading works fine

henrik14:08:02

henrik@Mimir-2 ~/D/P/P/i/a/.shadow-cljs> cat server.stderr.log
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Error: Unable to access jarfile null
Aug 17, 2018 6:28:11 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.8.Final
Aug 17, 2018 6:28:11 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.8.Final
shadow-cljs - HTTP server for :client available at 

thheller14:08:43

those are not normal errors though

henrik14:08:03

OK, I rm-rf’d .shadow-cljs, reinstalled 2.5.1, and did a shadow-cljs start.

henrik14:08:28

server.stderr.log has a single Error: Unable to access jarfile null in it

davidst15:08:46

what's the recommended way to serve non-js dependencies from npm (e.g., the css file for katex)? I am hoping there is something better than webjars or symlinks into the node_modules directory

thheller15:08:29

don't serve them at all. bundle them into one file.

thheller15:08:35

I currently use node-sass for that

ClashTheBunny16:08:07

I'm off to lunch right now, but I'll be back in a couple hours.

Logan Powell20:08:02

Is it possible to increase --max-old-space-size (the max heap size) via the package.json (reference: https://stackoverflow.com/a/34358130) I'm running out of memory doing some very large batch processing with fs

Logan Powell20:08:38

I.e., can shadow listen for the start command in package.json?

thheller20:08:26

@loganpowell where are you running out of memory?

Logan Powell20:08:53

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node_module_register
 2: v8::internal::FatalProcessOutOfMemory
 3: v8::internal::FatalProcessOutOfMemory
 4: v8::internal::Factory::NewFillerObject
 5: v8::internal::wasm::WasmOpcodes::TrapReasonMessage
 6: 000002033BF843C1

thheller20:08:10

no which build?

Logan Powell20:08:51

cli version: 2.4.25

Logan Powell20:08:57

you mean shadow or Node?

thheller20:08:00

node-repl or what?

Logan Powell20:08:11

yes, node-repl

Logan Powell20:08:25

but it's due to the load I'm putting on Node

thheller20:08:54

you can run (shadow/node-repl {:node-args ["--whatever"]})

thheller20:08:07

that option is however not available from the CLI currently so only from clj-repl

Logan Powell20:08:33

Like this?

(shadow.cljs.devtools.api/node-repl {:node-args ["--max-old-space-size=8192"]})
To quit, type: :cljs/quit
=> [:selected :node-repl]

Logan Powell20:08:41

so that's the equivalent of:

"start": "node --max-old-space-size=4076"

Logan Powell20:08:57

sorry with the 8192 in there instead

Logan Powell20:08:23

sweet! Thank you!