Fork me on GitHub
#shadow-cljs
<
2019-01-25
>
orestis08:01:31

Trying to integrate graphiql into a CLJS page. I get this log message on the shadow-cljs build:

[2019-01-25 09:09:15.405 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/graphql-language-service-interface/dist/GraphQLLanguageService.js", :requires [{:line 149, :column 30}]}
— the graphiql thing appears correctly but it’s broken in weird ways. Might the above log message have anything to do with it?

orestis08:01:06

Probably not, here’s the code in question:

customRules = void 0;
            customRulesModulePath = projectConfig.extensions.customValidationRules;

            if (customRulesModulePath) {
              /* eslint-disable no-implicit-coercion */
              rulesPath = require.resolve('' + customRulesModulePath);

              if (rulesPath) {
                customRules = require('' + rulesPath)(this._graphQLConfig);
              }
              /* eslint-enable no-implicit-coercion */
            }

orestis08:01:24

Hopefully there shouldn’t be any of those customValidationRules

orestis08:01:37

Hah, stupid codemirror. Needs to have the CSS mounted and parsed before it can do its thing. Got it working 🙂

thheller09:01:41

yeah don't worry about the warning. it just has a dynamic require which is not currently supported

orestis11:01:40

OMG javascript is annoying. I want to use the rangy npm module, which exposes just a single “rangy” global object - but! if you require some other file present in the node_modules lib folder, it mutates the global rangy object. Is there any way to do this with shadow-cljs? I’ve tried copying the rangy-textrange.js file in my classpath, but I can’t figure out a way to require it from CLJS. Shadow complains it can’t be found.

thheller11:01:17

not sure I understand. JS libs do this often

thheller11:01:57

are you sure you want to use a lib that hasn't been updated in 4 years? thats not a good sign is JS land 😉

orestis11:01:31

I want to use paren-soup to show a nice cljs editor in a browser, and it depends (via cljsjs) on that.

orestis11:01:38

There’s an updated fork I should look at though.

thheller11:01:18

but what exactly is the problem? the lib looks pretty straightforward?

orestis11:01:03

The npm package.json says that main is rangy-core.js. Which is what I get when I do :require ["rangy" :as rangy] in shadow.

orestis11:01:33

But, I also need to somehow require rangy-textrange.js, which adds a few methods to the global rangy object.

thheller11:01:33

["rangy" :as rangy]
    ["rangy/lib/rangy-textrange"]

orestis11:01:24

I didn’t realize you could do that, because I mistyped it first and got the message about installing the npm package 🙂

thheller11:01:08

can also just do ["rangy/lib/rangy-textrange" :as rangy]

thheller11:01:14

pretty much the same as including both

orestis11:01:47

Ok, hurdle overcame. Still paren-soup doesn’t work as I’d expect it to 😞

orestis11:01:18

Yep. I’m getting it loaded just fine, it’s just that it’s not doing what it’s supposed to do.

orestis11:01:37

It does some things, so it’s loading right.

thheller11:01:54

ah ok. no idea what its supposed to be doing 😉

orestis11:01:34

I think I’ll go for CodeMirror if I want some nicely formatted snippets there.

thheller11:01:54

codemirror + parinfer works well

orestis11:01:14

Cool, there’s a plugin for it. I’ll play around with that.

thheller11:01:02

you can see it in action at http://localhost:9630/repl if you have shadow-cljs server running

thheller11:01:20

(click connect on the :clj line thing)

orestis15:01:36

I’m already doing a bunch of work in a custom build namespace — starting my API server in the background, watching the filesystem and compiling SCSS etc, and now I want to be able to send some commands from the hosted cljs build to the shadow/clojure server running the watch. At what point does it make sense for me to use shadow-cljs as a library, instead of launching it via the command line?

orestis16:01:29

Whaaaat, there’s already an hud/open-file function I can use? I was about to go down that path on my own 🙂

orestis16:01:26

It’s the gift that keeps on giving!

thheller16:01:22

as far as other commands are concerned: I think at that point it makes sense opening your own websocket connection to a custom server

orestis16:01:49

Yeah, I’ll cross that bridge if I need to. I like to keep in shadow land if I can, then my backend server won’t need to worry about this (since it’s a dev-only concern) and I don’t want to bring yet another web server into the mix.

richiardiandrea19:01:34

reading all this prepl business I am worried about the fact that prepl will receive way less love than nrepl (check the activity boom in the last months)...so...would nrepl still be supported for the time being by shadow?

thheller19:01:28

nrepl isn't going anywhere

thheller19:01:46

to be honest prepl doesn't seem to solve any of the issues tools have today

richiardiandrea19:01:46

cool thanks, I am relieved 😄

richiardiandrea19:01:58

yeah that's what I think as well

thheller19:01:29

but it is better than normal socket repl

thheller19:01:44

just another option really. nothing regarding nrepl will change

richiardiandrea19:01:46

agree, at least is not character-based 😄

richiardiandrea19:01:55

thank you Thomas for confirming

David Pham21:01:18

Is it possible that the cider/shadow-cljs combo does not handle well pprint?

David Pham21:01:56

I am using cider 0.20 and I can’t get my repl to get pprint :/

richiardiandrea05:01:30

Have the same problem

David Pham09:01:48

Thanks! I wondered if I was alone

lilactown22:01:02

@neo2551 you can print, but not pprint?