Fork me on GitHub
#shadow-cljs
<
2017-10-21
>
thheller06:10:29

@mhuebert for react v16 and closure you need these externs I think

thheller06:10:31

var ResponderEventPlugin;
var SimpleEventPlugin;
var TapEventPlugin;
var EnterLeaveEventPlugin;
var ChangeEventPlugin;
var SelectEventPlugin;
var BeforeInputEventPlugin;

thheller06:10:57

but even when it compiles fine it doesn’t quite work, no event handlers ever trigger

thheller06:10:25

CLJSJS has the latest externs

mhuebert07:10:39

oh, I see. The top of the file says React 15.xx but it has been updated.

thheller07:10:30

AFAICT only the plugins need externs for everything to compile properly

thheller07:10:37

what is needed to work I don’t know

thheller07:10:52

someone in #cljs-dev probably knows

mhuebert07:10:42

I updated the externs in re-view to the latest from CLJSJS and now it compiles and runs for me. pushed the updated template.

mhuebert07:10:25

must have been some symbols related to event handling that were munged but did not cause errors..

thheller07:10:51

yeah I just gave up but guess someone figured it out

thheller07:10:07

I tried the externs before but must have missed something

thheller07:10:19

good i can use this as a basis now

mhuebert07:10:15

still getting the externs error on shadow’s closure build

mhuebert07:10:33

the working cljsbuild :advanced base.js is 229,603 bytes

thheller07:10:51

yeah I’ll fix the closure build

mhuebert07:10:41

would seem it is not picking up the externs

thheller08:10:34

still trying to fix source maps for :advanced when JS deps are used. can’t quite figure it out.

mhuebert09:10:39

does shadow support the :preloads compiler option?

mhuebert09:10:03

looks like yes, seeing examples.

mhuebert09:10:35

ah, but it’s in :devtools not :compiler-options

thheller09:10:22

yeah since its a dev only thing

mhuebert09:10:12

makes a lot of sense to have it in :devtools

mhuebert09:10:18

have you ever tried to require “d3”?

thheller09:10:21

I think so yes

thheller09:10:36

doesn’t work with :closure IIRC

thheller09:10:15

what the heck?

thheller09:10:29

ns or shadow_re_frame/provide_js_deps.cljs?

thheller09:10:02

ok got the error as well with just "d3"

mhuebert09:10:03

this is the repo. shadow-re-frame/provide-js-deps + the :resolve options in shadow-cljs.edn are a workaround to use libs that require cljsjs stuff

mhuebert09:10:03

was getting cljsjs... not provided errors

thheller09:10:42

see BREAKING CHANGE: Removing :foreign-libs support

mhuebert09:10:24

but i don’t have control over those libraries. so I require the same deps from node_modules in the provide-js-deps namespace and set the global var that the lib expects

thheller09:10:14

but you are really abusing the system here, thats not a good idea

thheller09:10:44

also use (js/goog.exportSymbol "React" react) not the set!

thheller09:10:23

but the dummy cljsjs/react.cljs file really is a better option than resolve

thheller09:10:01

but putting that into a library might not be a good idea 😞

mhuebert09:10:39

I don’t think there is any good option because non-shadow build tools have no way to include libs that are not Closure compatible except via foreign libs?

mhuebert09:10:57

in that case I can’t submit a PR to these libs

thheller09:10:59

well the same way reagent fixed it in the alpha version

mhuebert09:10:23

but React is closure compatible

mhuebert09:10:27

no idea if d3 is

thheller09:10:59

uhm yeah that part is not clear to me either

thheller09:10:23

but react also works via :foreign-libs not just closure

thheller09:10:57

{:foreign-libs
 [{:file "cljsjs/react/development/react.inc.js",
   :provides ["react" "cljsjs.react"],
   :file-min "cljsjs/react/production/react.min.inc.js",
   :global-exports {react React}}],
 :externs ["cljsjs/react/common/react.ext.js"]}

thheller09:10:09

this is the cljsjs/react deps.cljs

thheller09:10:40

I think that it will use the :foreign-lib if node_modules/react doesn’t exist

thheller09:10:56

I honestly don’t know … I couldn’t figure it out from reading the CLJS code

thheller09:10:34

but it is possible to compile without closure while still using (:require [react])

mhuebert09:10:38

right. so if d3 would add :global-exports to cljsjs then maybe it works. i wonder if, given the “react” in :provides, the react in :global-exports is redundant?

thheller09:10:05

I have no idea really, it seemed confusing to me which is why I did the :resolve thing

thheller09:10:41

granted it solves a different problem

thheller09:10:44

d3 is also one of those packages that is actually split into many packages

thheller09:10:05

I’m open to ideas … I might just re-enable foreign-libs as a last resort but I really don’t want to 😞

thheller09:10:52

the potential for conflicts is just too high

mhuebert09:10:02

so this hack doesn’t work, in the end, because the :resolve stuff mapping cljsjs.* to global vars runs before the global var is defined

mhuebert09:10:09

yeah it is not a pretty sight.

thheller09:10:54

(ns cljsjs.d3
  (:require ["d3" :as d3]))

(js/goog.exportSymbol "d3" d3)

thheller09:10:31

I might just create a bunch of those and create a shadow-cljs-foreign-libs package or so

mhuebert09:10:58

am getting this:

shadow.js.provide("module$cljsjs_d3", function(global,require,module,exports) {
module.exports=(d3);
});

mhuebert09:10:05

errors out because d3 has not been defined

thheller19:10:32

@mhuebert you can get rid of a bunch of closure warnings by setting :compiler-options {:closure-warnings {:global-this :off}}

thheller19:10:51

got the :closure compile working again

mhuebert19:10:39

i haven’t looked at blessed before, this looks interesting

thheller19:10:25

ok closure works fine again … until you want custom :resolve … not sure how I bring that into Closure yet

thheller19:10:53

The required namespace "cljsjs.react.dom.server" is not available, it was required by "reagent/dom/server.cljs".

thheller19:10:09

was trying to test with shadow-re-frame

thheller19:10:47

tested with lein new re-view instead, works after bumping re-view to 0.4.6

thheller19:10:51

base.js (233722 bytes) closure vs shadow base.js (259810 bytes)

thheller19:10:10

not a huge difference after gzip but when it works closure is definitely better

mhuebert20:10:42

Uhg ok I'll fix in a bit

mhuebert20:10:22

updated template to 0.4.6 (keep forgetting to update both project.clj and shadow-cljs.edn)

mhuebert20:10:34

I could parameterize the version

mhuebert20:10:44

since the template stuff already makes that easy

mhuebert20:10:05

latest shadow-re-frame should work

mhuebert20:10:33

i was switching to some older versions of reagent while trying to get re-frame-trace to work. had to patch it to work with react 16.

mhuebert20:10:15

shadow-re-frame is compiling for me with closure but i’ve got externs problems again

mhuebert20:10:57

no externs problems with :release using shadow as js provider, but with closure, EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, mk`.` again

mhuebert21:10:25

user-options at command line: https://github.com/SBoudrias/Inquirer.js (less complex than a full-blown view layer -- this is what firebase-tools uses)