Fork me on GitHub
#shadow-cljs
<
2020-08-06
>
royalaid02:08:00

Hey @thheller running into some weirdness with when trying to import a javascript file that itself has an import and CLJS is throwing back at me saying that Requested module does not have an export "initSchema".

royalaid02:08:04

The code in question in src/models/index.js

royalaid02:08:13

import { initSchema } from '@aws-amplify/datastore';

royalaid02:08:22

and then in another file

royalaid02:08:48

["/models/index" :refer [Post]]

royalaid02:08:33

and yet strangely

royalaid02:08:31

(ns ex
  (:require ["@aws-amplify/datastore" :refer [DataStore initSchema] :as foo]
            #_["/models/index" :refer [Post]]
            [cljs.core.async.interop :refer [<p!]]))
works just fine and initSchema is a fn if I log it

royalaid02:08:00

Final point is that if I swap to import * as foo from '@aws-amplify/datastore'; everything works and I can use foo but unfortunately this is generated code and would rather not have to update the require after each time I re-generate the file

Mikko Harju04:08:35

Is it a known issue that when evaling stuff with nRepl, I've started to get

[2020-08-06 07:06:52.100 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 6, :from 21}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
pretty frequently, and the only solution that I've found is to shut down shadow-cljs and start it again. I haven't figured out the actual circumstances this happens but I'll try to see if I see some similarities. I'm using Vim/Fireplace if that is something that might have to do with this.

robert-stuttaford07:08:32

@thheller how do i interpret the size difference between what the build report says, and the filesize on disk? for example, a common module, the report says "JS: 1.92 MB", but on disk, the same module is '9912095' bytes, or 10mb. is it perhaps that the report is about :release and my on-disk code is the non-:release version? edit: on reflection, this is a silly question, of course it's about the :release version πŸ˜…

thheller08:08:14

@royalaid npm packages are imported in a separate step and converted to commonjs. closure does some strict checking for ESM files but since everything is CJS it only supports imports * as .... a bit annoying but pure ESM doesn't work unless everything is ESM and npm packages rarely are.

πŸ‘ 3
thheller08:08:53

@robert-stuttaford yeah, its always release

thheller08:08:23

@mikko which version do you use? I thought I fixed that issue a couple versions ago?

Mikko Harju09:08:00

shadow-cljs - server version: 2.10.19 running at 

Mikko Harju09:08:17

I think this relates to running code in a completely new NS, or then something else has failed in prior reload and then evaluating new code causes this. But these are just pure guesses.

thheller09:08:29

very strange. would help a lot if you can narrow it down a create some reproducible steps to trigger it.

Mikko Harju09:08:21

Definitely. Will try!

Mikko Harju05:08:53

I think this has to do with clara.rules somehow. I'm not sure why, but it seems that whenever I get into a state where it fails to satisfy our constraints we get to an error state where I evaluate a form, and then it prints that error. We've had had issues with clara.rules previously too on CLJS that it might do something funky, might be related to compilation failing or something..

Mikko Harju05:08:30

For instance, now I just hit a situation where it failed to succeed with a perfectly valid set of facts and rules, that error appeared, restarted the compilation and now it works with no changes πŸ™‚

thheller08:08:13

strange. no clue how that may be happening. thought I fixed all the cases but I guess not?

Mikko Harju08:08:15

What was the relevant part you changed? If I could spot something… (or not)?

thheller09:08:45

but there were a couple other commits since then that may potentially affect this

Mikko Harju09:08:25

Can it be that the connection tries to declare cljs.user again and that itself causes an exception causing the cljs,user to not be available anymore?

Mikko Harju09:08:56

For example, (ns cljs.user (:require some.namespace.that.fails))

thheller09:08:47

do you have an actual cljs.user? the error message suggests you don't?

Mikko Harju09:08:50

Hey, that's it? If I just put (throw (js/Error. "Lets fail")) to a NS and then load it => I get that error!

thheller09:08:21

a JS runtime error cannot possibly cause a CLJS compiler error?

Mikko Harju09:08:32

First.

[2020-08-07 12:45:14.376 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex - {:input {:code "(load-file \"filippos/core/models/data_types.cljs\")", :ns cljs.user, :repl true}}
ExceptionInfo Failed to process REPL command {:eof? false, :ns cljs.user, :form (load-file "filippos/core/models/data_types.cljs"), :source "(load-file \"filippos/core/models/data_types.cljs\")", :tag :shadow.cljs.repl/process-ex}

Mikko Harju09:08:39

(that data_types ns has the throw)

Mikko Harju09:08:59

Then next eval form:

[2020-08-07 12:45:47.721 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 8, :from 40}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}

Mikko Harju09:08:22

And I load it with Require! in fireplace after I planted that throw

thheller09:08:25

is there more to the first error? it should be printing a stacktrace?

thheller09:08:20

thats not the first

thheller09:08:28

> [2020-08-07 12:45:14.376 - WARNING] :shadow.cljs.devtools.server.worker.impl/cljs-compile-ex

thheller09:08:10

thats all? there should be more?

thheller09:08:44

see thats the issue

Mikko Harju09:08:57

Yeah, and that is on the classpath.

thheller09:08:25

yes but load-file expects a file-path so src/main/filippos/core/models/data_types.cljs or an absolute path

thheller09:08:15

or do you just have the file in the project root?

thheller09:08:59

I mean this error should clearly not cause everything else to fail but it is a legit error caused by sending invalid data

Mikko Harju09:08:27

wait, I'll add repro steps

Mikko Harju10:08:53

Argh. I thought I had it but now it's resisting me and is working πŸ˜„

Mikko Harju10:08:49

1. compile 2. introduce error in code & save 3. wait for compilation 3. refresh browser 4. eval anything in that NS => fails subsequently, even after fixing the error and refreshing

thheller10:08:44

sorry that isn't precise enough. like I said a JS (throw ...) cannot possibly cause an error on the compiler side

thheller10:08:25

unless you mean "error in code" as an compilation error

Mikko Harju10:08:29

OK – so basically it boils down to having unhandled exceptions lurking around in the core and that causes failures?

thheller10:08:42

it is completely expected that you CANNOT eval anything in an NS that fails to load

thheller10:08:49

that will NEVER work

thheller10:08:03

but the issue I'm interested in here is the "no output by id"

thheller10:08:13

which is a compile side error

thheller10:08:44

but you need to separate the two worlds when diagnosing this

thheller10:08:20

on the server-side CLJS compilation running in CLJ

thheller10:08:26

one is JS side

thheller10:08:24

"no output by id" cannot possibly the caused by a JS side runtime exception

thheller10:08:05

it may cause the JS side to fail but not the reverse

thheller10:08:23

so we need to track down what you did to trigger that error, not the other errors that may cause.

Ody14:08:39

With the minimal setup as described here: https://github.com/minimal-xyz/minimal-shadow-cljs-browser. Is it supposed to deploy, ie. copy assets like index.html when it detects changes?

Ody15:08:58

Cool, what magic incantation makes it do so? May be this https://shadow-cljs.github.io/docs/UsersGuide.html#_css_reloading

thheller15:08:20

there is no support for doing anything with html at all

Ody15:08:58

Thanks. I am new to cljs, at the stage of examining the tools around it. I assumed it will reload when it sees a change in asset files, like figwheel is doing.

thheller15:08:39

css reloading yes that is supported but assumes that you put it into the correct place yourself

thheller15:08:03

html reloading no since typically you just rely on hot reload and never actually want to reload your full page

πŸ‘ 3
Ody15:08:56

There is also no reloading of jar files right? If say i add a new lib to deps

thheller16:08:35

modifying the CLJS dependencies requires a restart currently yes. npm packages don't

thanks3 3