Fork me on GitHub
#shadow-cljs
<
2018-07-21
>
richiardiandrea00:07:55

has anybody ever seen:

goog.nodeGlobalRequire=function(path){return false};goog.provide("goog.debug.Error");goog.debug.Error=function(opt_msg){if(Error.captureStackTrace)Error.captureStackTrace(this,goog.debug.Error);else{var stack=(new Error).stack;if(stack)this.stack=stack}if(opt_msg)this.message=String(opt_msg);this.reportErrorToServer=true};goog.inherits(goog.debug.Error,Error);goog.debug.Error.prototype.name="CustomError";goog.provide("goog.dom.NodeType");goog.dom.NodeType={ELEMENT:1,ATTRIBUTE:2,TEXT:3,CDATA_SECTION:4,ENTITY_REFERENCE:5,ENTITY:6,PROCESSING_INSTRUCTION:7,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,NOTATION:12};goog.provide("goog.string");goog.provide("goog.string.Unicode");goog.define("goog.string.DETECT_DOUBLE_ESCAPING",false);goog.define("goog.string.FORCE_NON_DOM_HTML_UNESCAPING",false);goog.string.Unicode={NBSP:" "};goog.string.startsWith=function(str,prefix){return str.lastIndexOf(prefix,0)==0};goog.string.ends

TypeError: Cannot set property 'Error' of undefined
    at /home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:69:102
    at Object.<anonymous> (/home/arichiardi/git/laputa/continuous-delivery/bin/create-publish-pipeline:3038:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3

richiardiandrea00:07:43

the target is :node-script

thheller07:07:25

@richiardiandrea that might be :whitespace not being compatible with node.

thheller08:07:18

@eoliphant it always helps to run a shadow-cljs browser-repl and then calling (require '["aws-sdk" :as x]) (js/console.dir x)

thheller08:07:03

if the object has a AWS property you want :refer. if it has a .default property you want :default. if it has no properties at all and is just a function you want :as

peteypete17:07:13

I’m testing out shadow.cljs with a seemingly basic implementation of the npm package react-select. I’m using the code from here, which works fine with cljsjs. https://gist.github.com/pesterhazy/6c517653945f84a39c1ae3cc8b20c552. Shadow however, serves me up this error.

Uncaught Error: Assert failed: Expected React component in: [:> nil {:value nil, :options #js [#js {:value "a", :label "alpha"} #js {:value "b", :label "beta"} #js {:value "c", :label "gamma"}], :onChange #object[Function]}]
Any ideas?

p-himik17:07:31

js/window.Select is not defined. Most likely, importing of cljsjs.react-select creates a global Select object but shadow-cljs does not. Instead of js/window.Select you want to use the stuff that you explicitly import.

p-himik17:07:20

Also, I always thought that such things must be wrapped in reagent.core/adapt-react-class. But maybe I'm wrong here.

p-himik17:07:08

Ah, :> handles that.

peteypete18:07:33

Thanks @U2FRKM4TW. I got the Select element to render with :require ["react-select" :refer [Select]] Now on-click of the select item gives

Uncaught Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development. See  for more information.

thheller21:07:15

what do you do on click?

peteypete21:07:58

I attempt to access the dropdown selection list.

thheller21:07:13

and are you doing any cross origin stuff? ie. loading the JS from a different domain or such?

peteypete21:07:58

I used Jacekschaes template

thheller21:07:55

so you are using ?

peteypete21:07:56

I moved it to 3010 because I had another project running.

peteypete21:07:20

but yes, error still exists running on :3000

thheller22:07:03

port itself doesn't matter. was just checking if you use the built-in server or something else

thheller22:07:55

I just checked the package

thheller22:07:08

this is not actually valid :require ["react-select" :refer [Select]]

thheller22:07:32

should be :require ["react-select" :default Select]

peteypete22:07:28

corrected but same error

thheller22:07:26

are you sure you are using things correctly? the :refer [Select] shouldn't have worked at all

peteypete22:07:28

I am a nOOb but it did render the Select element on the DOM

thheller22:07:48

and what exactly are you doing in the onclick?

peteypete22:07:20

the dropdown arrow on the select menu

p-himik02:07:11

@U8KRRN70S He meant whether you do any requests or call something that does some requests.

thheller22:07:12

that looks like something is writing to the DOM?

peteypete22:07:39

yes even with :refer [Select]

thheller22:07:54

please post the code of you onChange

thheller22:07:12

:refer [Select] is absolutely not valid and shouldn't even render anything

peteypete22:07:29

k something wierd going on

thheller22:07:18

(ns app.views
  (:require
    [app.state :refer [app-state]]
    [app.events :refer [increment decrement]]
    ["react-select" :default Select]))

(defn header
  []
  [:div
   [:h1 "A template for reagent apps"]
   [:> Select {:onChange (fn [e]
                          (js/console.log "onChange" e))
               :options
               [{:value 1 :label "1"}
                {:value 2 :label "2"}]}]])

thheller22:07:24

this works fine

peteypete22:07:47

(ns app.views
  (:require [app.state :refer [app-state]]
            [app.events :refer [increment decrement]]
            [reagent.core :as r :refer [atom]]
            ["react-select" :default Select]
            ["prop-types" :refer [PropTypes]]))

(defonce value (r/atom nil))

(defn header
  []
  [:div
   [:h1 "A template for reagent apps"]])

(defn counter
  []
  [:div
   [:button.btn {:on-click #(decrement %)} "-"]
   [:button {:disabled true} (get @app-state :count)]
   [:button.btn {:on-click #(increment %)} "+"]])

(defn select-ui []
  [:> js/window.Select {:value @value
                        :options #js [#js {:value "a" :label "alpha"}
                                      #js {:value "b" :label "beta"}
                                      #js {:value "c" :label "gamma"}]
                        :onChange #(reset! value (aget % "value"))}])

(defn root-ui []
  [:div {:style {:width 400}}
   [:h3 "Select test"]
   [select-ui]])

thheller22:07:24

js/window.Select is not what you get from shadow-cljs. thats something else entirely. don't know where tthat is from

thheller22:07:38

its just [:> Select ...]

thheller22:07:03

if you have a script tag included otherwise you are not actually using the npm package

peteypete22:07:34

sweet works. I’m learn alot.

thheller22:07:07

in general js/ is for accessing global variables which is very common in cljsjs packages but never required in shadow-cljs

thheller22:07:28

you use directly what you require in your ns like any other CLJS namespace/refer

peteypete22:07:31

ah yea I jammed a script in there to try and load another way

peteypete22:07:49

Thanks @thheller. Shadow looking good. Moving onto trying ag-grid. Thanks again

thheller22:07:00

so import { AgGridReact } from 'ag-grid-react'; becomes (:require ["ag-grid-react" :refer (AgGridReact)])

peteypete22:07:20

excellent reference

thheller22:07:22

the css stuff is not yet supported

thheller22:07:36

so that needs to be done manually. everything else is though.