Fork me on GitHub
#shadow-cljs
<
2020-10-20
>
kennytilton00:10:49

I am getting a harmless error

Parse error. illegal use of unknown JSDoc tag "pd"; ignoring it
doing a release build, when it gets to this line in a library I am using: https://github.com/ptaoussanis/tufte/blob/master/src/taoensso/tufte.cljc#L315 There is a comment with a code snippet ending @pd. ANy way to quiesce that? Not a big deal at all.

thheller08:10:25

@kenny there is an option but I can't remember the name. I'll try to look it up later.

thheller08:10:50

@mail024 what are "duplicate require issues"? for now :npm-module should sort of work. :esm is sort of finished except for a "do not bundle X packages" setting I guess

victorb10:10:34

@thheller I keep trying to shoehorn shadow-cljs into lots of different contexts, and thinking about it, it would be helpful if you could provide new :target 's as plugins/extensions to shadow-cljs, to keep the core smaller and not having to implement everything in shadow-cljs. Something you thought about?

thheller10:10:51

this is the basic design

thheller10:10:32

:target accepts a symbol. so :target your.lib/my-target would call that function

victorb10:10:43

ooooh, didn't know that! That's cool, will take a look at that

victorb10:10:07

guessing it just has to be available on the classpath and it'll pick it up from there?

thheller10:10:28

and a keyword for :target just expands to shadow.build.targets.<name-of-kw>/process

victorb10:10:19

cool cool, thanks :thumbsup:

thheller10:10:37

yes its just a regular function you implement that inspects some keys to know what it is supposed to do

thheller10:10:35

:browser is by far the most complicated so can be hard to understand what is happening

thheller10:10:41

the API isn't documented at all though but happy to walk you through it

👏 3
thheller10:10:56

basically it gets the entire build state and just does whatever it needs to

thheller10:10:11

this is one of the custom targets someone else wrote as a lib https://github.com/titonbarua/shadow-cljs-gjs-target

Alexis Vincent10:10:38

@thheller duplicate require was a bad way to name it. I meant Namespace "xxx" already declared . Happens for both esm and npm-module. I think i remember similar things happening a little while back when I tried to import cljs code from shadow in webpack.

Error: Namespace "cljs.core" already declared.
    at Object.goog.provide (webpack-internal:///./dist/cljs/cljs-runtime/cljs_env.js:102:13)
    at eval (webpack-internal:///./dist/cljs/cljs-runtime/cljs.core.js:4:6)
    at Module../dist/cljs/cljs-runtime/cljs.core.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:199:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./dist/cljs/index.js:41:85)
    at Module../dist/cljs/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2298:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./pages/index.js:2:77)
    at Module../pages/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2310:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)

Alexis Vincent10:10:56

Super cool about the target thing mentioned above!

thheller10:10:10

weird. are you including multiple builds this way?

Alexis Vincent10:10:43

A single one. I can get you a repro project if thats useful.

Alexis Vincent10:10:14

;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 :dependencies
 [[reagent "0.8.1"]]

 :builds
 {:site {:target :npm-module
         :output-dir "site/src/cljs"
         :build-hooks [(shadow.next-js/create-pages)]
         :entries []}
  :esm {:target :esm
        :output-dir "dist/cljs"
        :build-hooks [(shadow.next-js/create-pages)]
        :modules {:index {:exports {page_index }}}}}}

Alexis Vincent10:10:03

Let me push a repro project

Alexis Vincent10:10:07

repro is for esm

Alexis Vincent10:10:43

npm run dev shadow-cljs watch esm

Alexis Vincent10:10:24

actually. Sorry, should remove the build hook for esm. Will fix

Alexis Vincent10:10:21

Also to note, on latest shadow last night I ran into an issue where I changed the shadow-cljs output-dir for either the npm-module or esm and even after restarting shadow watch, it was still outputting to the old dir. Deleting .shadow-cljs fixed it. Possible i had a shadow server running somewhere in emacs while this happened but i dont think i did

Alexis Vincent11:10:36

scratch that, I think i did have a shadow-cljs server running

Alexis Vincent11:10:06

ok. I’ve pushed a clean repro case for issues with next-js (although i think this is webpack reproducible as well) and esm. Super simple import. From fresh next and shadow cache. Terminal history is as follows:

Alexis Vincent11:10:06

> [email protected] dev /Users/alexisvincent/Code/next-cljs
> next dev

ready - started server on 
event - compiled successfully
event - build page: /
wait  - compiling...
[BABEL] Note: The code generator has deoptimised the styling of /Users/alexisvincent/Code/next-cljs/dist/esm/cljs-runtime/cljs.pprint.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /Users/alexisvincent/Code/next-cljs/dist/esm/cljs-runtime/cljs.pprint.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /Users/alexisvincent/Code/next-cljs/dist/esm/cljs-runtime/cljs.core.js as it exceeds the max of 500KB.
[BABEL] Note: The code generator has deoptimised the styling of /Users/alexisvincent/Code/next-cljs/dist/esm/cljs-runtime/cljs.core.js as it exceeds the max of 500KB.
warn  - ./dist/esm/cljs-runtime/cljs_env.js
Critical dependency: the request of a dependency is an expression
info  - ready on 
ReferenceError: WebSocket is not defined
    at shadow$cljs$devtools$client$websocket$start (webpack-internal:///./dist/esm/cljs-runtime/shadow.cljs.devtools.client.websocket.js:9:16)
    at shadow.cljs.devtools.client.shared.Runtime.attempt_connect_BANG_ (webpack-internal:///./dist/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:507:131)
    at Object.shadow$cljs$devtools$client$shared$init_runtime_BANG_ [as init_runtime_BANG_] (webpack-internal:///./dist/esm/cljs-runtime/shadow.cljs.devtools.client.shared.js:978:18)
    at eval (webpack-internal:///./dist/esm/cljs-runtime/shadow.cljs.devtools.client.browser.js:989:38)
    at Module../dist/esm/cljs-runtime/shadow.cljs.devtools.client.browser.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2046:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./dist/esm/index.js:130:112)
    at Module../dist/esm/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2286:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./pages/index.js:2:76)
Error: Namespace "shadow.cljs.devtools.client.browser" already declared.
    at Object.goog.provide (webpack-internal:///./dist/esm/cljs-runtime/cljs_env.js:102:13)
    at eval (webpack-internal:///./dist/esm/cljs-runtime/shadow.cljs.devtools.client.browser.js:5:6)
    at Module../dist/esm/cljs-runtime/shadow.cljs.devtools.client.browser.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2046:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./dist/esm/index.js:130:112)
    at Module../dist/esm/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2286:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./pages/index.js:2:76)
    at Module../pages/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2298:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
event - build page: /next/dist/pages/_error
wait  - compiling...
event - build page: /next/dist/pages/_error
warn  - ./dist/esm/cljs-runtime/cljs_env.js
Critical dependency: the request of a dependency is an expression
info  - ready on 
warn  - ./dist/esm/cljs-runtime/cljs_env.js
Critical dependency: the request of a dependency is an expression
info  - ready on 
Error: Namespace "cljs.core" already declared.
    at Object.goog.provide (webpack-internal:///./dist/esm/cljs-runtime/cljs_env.js:102:13)
    at eval (webpack-internal:///./dist/esm/cljs-runtime/cljs.core.js:4:6)
    at Module../dist/esm/cljs-runtime/cljs.core.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:199:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./dist/esm/index.js:41:85)
    at Module../dist/esm/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2286:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)
    at eval (webpack-internal:///./pages/index.js:2:76)
    at Module../pages/index.js (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:2298:1)
    at __webpack_require__ (/Users/alexisvincent/Code/next-cljs/.next/server/pages/index.js:23:31)

thheller11:10:17

uhm yeah watch won't work

thheller11:10:20

try compile

Alexis Vincent11:10:45

Have now added an npm-module case. Which works! I must have had bad caches yesterday? What doesn’t work however is interplay between hmr from webpack and shadow. I expect here that I could leave hmr up to shadow by using compile. But then i still want to have a shadow server for repl and hmr, how do I do this? Im assuming some combination of compile and server?

Alexis Vincent11:10:51

esm compile works, but fails for other reasons I dont think are related to shadow. Thanks! Having a way for shadow to do hmr but bypassing the flush step to avoid next attemping to hmr cljs code would be great. Do you know how i might achieve this?

thheller11:10:18

sorry don't have time for this today

thheller11:10:31

you cannot have both webpack hmr and shadow

thheller11:10:35

it is either or

thheller11:10:50

if you want REPL and stuff you need to use the shadow reloading only

Alexis Vincent12:10:37

Ok, thanks for the input. I’ll get some time to look closer into this tomorrow. Goal is to get reliable interplay between shadow and nextcljs

thheller12:10:04

I believe I said it is not a good match for CLJS and it still isn't and never will be great

thheller12:10:35

too many presumed JS-isms that don't translate well

victorb12:10:01

yeah, I got the same impression last time I looked at next.js, doesn't seem to fit with clojurescript development really. Question for people who used next.js more though, what exactly are you missing in cljs devlopment that next.js gives you? Might be something better in the ecosystem to give you the same or greater benefits

mauricio.szabo19:10:59

Hi, @thheller, I just found a really strange issue 😄. On Chlorine, I evaluate all shadow-cljs commands by treating the result - so they all go inside a let. So, if I do something like this:

(let [res (ns some.namespace (:require ["js-dependency" :as dependency]))] res)
And then try do define a function: (defn a-fn [] (.useThis dependency) It breaks with:
AssertionError Assert failed: (symbol? module)
        shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
        shadow.build.cljs-hacks/js-module-exists? (cljs_hacks.cljc:71)
        shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:109)
        shadow.build.cljs-hacks/invokeable-ns? (cljs_hacks.cljc:104)

mauricio.szabo19:10:10

If I don't wrap the ns form in a let, it works fine. It's not a big deal, really - Shadow's hot-reload makes evaluating ns forms unnecessary, but I thought I would explain the issue anyway 😄

thheller19:10:09

@mauricio.szabo ns is a special form which you cannot put into a let in CLJS

thheller19:10:52

that alone should already fail. dunno how you get to the second error

mauricio.szabo19:10:36

Yes, the simple fact that it works sometimes is something that amazes me 😄. For example, load-file simply do not work if you wrap on let

mauricio.szabo19:10:19

The result of the first command is nil, so it does run... to some extend

thheller19:10:35

all special forms can't possibly work