Fork me on GitHub
#shadow-cljs
<
2019-03-27
>
manuel10:03:44

hi everybody, I have a problem with my shadow-cljs project. I am trying to use carbon-react, so these are the steps I did: - yarn add react react-dom create-react-class carbon-react - yarn Then I used its components:

(ns carbon-example.dashboard.views
  (:require ["carbon-react/lib/components/app-wrapper" :as AppWrapper]
            ["carbon-react/lib/components/navigation-bar" :as NavigationBar]
            [re-frame.core :as rf]))

(defn- navbar
  []
  (fn []
    [:> NavigationBar]))

(defn panel
  []
  (fn []
    [:> AppWrapper
     [navbar]]))
But shadow-cljs compile carbon-example doesn't work:
shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn  cli version: 2.8.24  node: v8.15.1
[:carbon-example] Compiling ...
The required JS dependency "core-js/modules/es7.symbol.async-iterator" is not available, it was required by "node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js".

Searched in:/home/manuel/7bridges/code/carbon-example/node_modules

You probably need to run:
  npm install core-js/modules/es7.symbol.async-iterator

See: 

manuel10:03:17

This is my shadow-cljs.edn file:

{:builds
 {:carbon-example {:asset-path "/js"
                   :modules {:main {:entries [carbon-example.core]}}
                   :output-dir "resources/public/js"
                   :target :browser}}

 :dependencies [,,,]

 :dev-http {8020 "resources/public/"}

 :devtools {:http-root "resources/public"
            :http-port 8020}

 :nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]
         :port 8777}

 :source-paths ["src"]}

thheller10:03:38

@manuel I'd guess that that is a version conflict somewhere, or just a missing peer dep

thheller10:03:46

did you see this message?

npm WARN [email protected] requires a peer of flux@^3.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of i18n-js@^3.0.0 but none is installed. You must install peer dependencies yourself.

thheller10:03:53

on npm install carbon-react

manuel10:03:56

yes, I added those as well

manuel10:03:05

running npm ls, the problem seems to be:

├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
An old version of core-js.

thheller10:03:11

so carbon-react depends on "core-js": "^2.6.3",

thheller10:03:26

but I also have [email protected] installed

thheller10:03:59

probably works if you just add core-js to you deps with the proper version

thheller10:03:04

so it doesn't get the nested install

manuel10:03:10

let me try

manuel10:03:39

I did: - yarn add [email protected] - shadow-cljs compile carbon-example Now I get:

shadow-cljs - config: /home/manuel/7bridges/code/carbon-example/shadow-cljs.edn  cli version: 2.8.24  node: v8.15.1                                                                                                  
[:carbon-example] Compiling ...                                                                                                                                                                                      
failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js                                                       
{:relative-to #object[java.io.File 0x6164b3a2 "/home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js"], :entry "../../utils/helpers/tags"}                   
ExceptionInfo: failed to resolve: ../../utils/helpers/tags from /home/manuel/7bridges/code/carbon-example/node_modules/carbon-react/lib/components/app-wrapper/app-wrapper.js                       

thheller10:03:58

wtf is that pattern ... first time I see this

manuel10:03:41

me too 🙂

thheller10:03:00

ok yeah ... they have a weird directory structure I didn't know was allowed

thheller10:03:06

I'll see if I can add support for that in a bit

manuel10:03:23

thank you, but no worries, we are testing different JS/CSS toolkits, so it may be the only case.

thheller10:03:55

shouldn't be that hard. just never saw that pattern before

manuel11:03:30

I'll try it asap and report back, thanks for the quick fix!

manuel11:03:46

@thheller fantastic, it works. Thanks again.

👍 4
ccann13:03:48

how might one go about adding the output-name from manifest.edn into index.html?

ccann14:03:57

I ended up doing this with sed:

- run: HASH=$(sed 's/.*:output-name \"main\.\([a-zA-Z0-9]*\)\.js\".*/\1/' public/js/manifest.edn)
      - run: echo $HASH
      - run: sed -n "s|\"/js\/main\.js\"|main.$HASH\.js\"|g" public/index.html
if anyone has a better idea

thheller15:03:20

@ccann if you just have a static HTML file you can generate that via :build-hooks or clj-run.

ccann17:03:17

Sweet, I used clj-run and it works great. Thanks!