Fork me on GitHub
#shadow-cljs
<
2022-11-15
>
mkvlr16:11:14

@thheller hey Thomas, when using shadow with target :esm trying to load the js built by shadow from another port it fails because browsers are more strict about module includes, requiring a Access-Control-Allow-Origin` header set. I tried using my own http-handler but that only gets called when a file doesn't exist. Wondering if you'd be open to adding that header with a * value?

thheller17:11:53

wouldn't it be easier to have your server serve the JS files?

thheller17:11:10

thats my general suggestion for anything that requires a custom header?

mkvlr17:11:07

easier no, in this case the other server is clerk and I’d prefer to have the config related to serving of js files in a single place in shadow-cljs.edn

thheller17:11:43

it requires no config? its just static files? which I assume clerk can already do?

thheller17:11:37

the websocket :9630 server already sets all the proper headers and is not affected by which server you use

mkvlr17:11:14

it would require setting the root

mkvlr17:11:31

so with clerk I also don’t want to be in the business of serving other content 🙃

mkvlr17:11:01

would love to offload this to shadow for the use case for when folks want to take over the js build for clerk

thheller17:11:01

but what is this script you are building? is this not part of clerk?

mkvlr17:11:33

it’s a custom js bundle for clerk, with more deps in it

mkvlr17:11:26

clerks customization point is specifying a different url to load the js bundle from

mkvlr17:11:52

but since switching to ESM this broke

thheller17:11:01

wouldn't that be the same as specifying a folder where to find the JS?

mkvlr17:11:34

similar but not quite

mkvlr17:11:58

anything against setting the header?

mkvlr17:11:46

wouldn’t this also be a problem for mobile esm builds where you run shadow on your PC and access it via the your phone?

thheller17:11:28

depends on which server you use. I have never used a separate webserver just for serving the JS files

thheller17:11:41

but I guess adding the header doesn't hurt anybody

mkvlr17:11:38

cool, I’ll do a PR tomorrow, ok?

thheller20:11:16

should be fixed in 2.20.11

mkvlr22:11:01

oh thank you!

mkvlr16:11:09

I can make sure my custom http hander is being called by not setting any :roots but defaulting to the header set might be simpler?

martinklepsch20:11:40

fs is part of the node-libs-browser polyfill package to provide node-native package support
for none-node builds. You should install shadow-cljs in your project to provide that dependency.

	npm install --save-dev shadow-cljs
I’m getting this message despite shadow cljs being installed in package.json. version is 2.20.10

thheller20:11:43

do you use custom :js-package-dirs?

martinklepsch20:11:42

I use one node_modules for client and server code though and above this message I’m seeing my client build fail because I’m requiring fs — which I guess kind of makes sense but worked with 2.15.10

thheller20:11:21

should be fine and nothing of the behaviour went through any intended change

martinklepsch20:11:18

works again after downgrading to 2.15.10