Fork me on GitHub
#shadow-cljs
<
2019-06-24
>
publicmayhem14:06:17

How do I start up a dev http server that supports a specific set of CORS headers? From the userguide I tried adding in :push-state/headers element into the :devtools config but had no effect? All I need is for the dev server to offer a single index.html page with specific CORS support so my re-frame app can login via aws-cognito

thheller15:06:29

can you point me to the AWS docs that explain the CORS headers needed? I don't understand why it is needed?

publicmayhem17:06:10

I’m writing a serverless app that will allow user to login via aws cognito over ajax, then it will call several lambda fns via api gateway, that is the plan. For development on my local machine, I need to allow the browser to post ajax to aws, hence the cors. I’m sure there are possible routes for logging in, but for accessing api gateway I definitely need cors.

publicmayhem17:06:10

If there is no way at present to simply tell devtools to inject cors headers into responses, then I will add a small handler to do this for me, but thought I would ask, as most things seem to have been thought out already

thheller17:06:32

hmm maybe I'm missing something but you posting against some AWS host does not require CORS locally?

publicmayhem18:06:51

Sorry if I’m not clear. I’m developing the app via shadow-cljs which is serving the app locally via devtools server. I’m creating a form in re-frame which will capture login details and send to AWS cognito via Ajax (this is where it will need cors permissions). Once logged in, it has access to AWS Lambda resources via api gateway again via Ajax which requires cors. The server provided by shadow-cljs needs to give my browser permission to access AWS resources cross origin.

thheller18:06:18

no it doesn't?

thheller18:06:29

the server answering the AJAX request has to set CORS headers

thheller18:06:45

the server serving the initial page is not involved in that?

publicmayhem18:06:02

Hmm, u think I’m barking up the wrong tree then. Will see what I can get working

thheller18:06:28

from what I understand of what you are trying to do yes

souenzzo14:06:17

Unused extern imports like

(ns  (:require ["@material-ui/core/AppBar" :as mui-AppBar]))
(def app-bar (factory-apply mui-AppBar)) ;; app-bar isn't used
Will be included in final bundle?

pez15:06:33

I listened to the ClojureScript podcast episode about npm interop, @thheller . Got curious about the Closure compiler's advanced compilation... Do you know if it makes any attempt to make the generated code more suited for gzipping?

thheller15:06:06

what is gripping?

thheller15:06:38

still no clue what that would mean in that context

pez16:06:44

Damn autocorrect. Gzipping.

4
thheller16:06:42

yes, it is optimizing for that

thheller16:06:01

IIRC there was an article about that on the closure tools blog http://closuretools.blogspot.com/

thheller16:06:25

but can't remember exactly where

thheller16:06:21

but the gist is that closure tries to minimize the number of properties it generates on classes and such. and rename them in a way that has as much re-use as possible

thheller16:06:11

ie. all locals and function args args are renamed after the same pattern (eg. a,b,c,d,...)

thheller16:06:32

but I think webpack does that too nowadays

thheller16:06:09

but some of the more advanced patterns don't work too well in CLJS since we don't type-hint our code

thheller16:06:20

and some of those things require fully typed code

pez16:06:16

Thanks! Some of the gzip optimizations require fully typed code? I'll go read that blog. I had a specific idea I was wondering about.

thheller16:06:31

some of the optimizations require typed code. some of those are relevant to gzipping since it can pick better names

thheller16:06:46

property ambiguation or whatever that is called

👍 4
ro618:06:27

I'm new to shadow-cljs and enjoying it a lot so far. Thanks for the good work @thheller! I'm trying to use https://github.com/kylefox/jquery-modal in throwing together a prototype and wondering if there's something special I should do to get that library to load. Right now it seems the $(...).modal() fn it's supposed to add to jQuery isn't available. Maybe just require it somewhere to make sure the module loads?

ro618:06:02

All I had to do was

(:require ["jquery-modal"])
and everything worked.

👍 8