This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-06
Channels
- # announcements (4)
- # aws (2)
- # beginners (48)
- # calva (39)
- # cljsrn (12)
- # clojure (98)
- # clojure-dusseldorf (1)
- # clojure-serbia (2)
- # clojure-spec (13)
- # clojure-uk (13)
- # clojurescript (97)
- # code-reviews (1)
- # datomic (14)
- # fulcro (24)
- # jobs-discuss (160)
- # juxt (1)
- # luminus (2)
- # nrepl (1)
- # off-topic (1)
- # other-languages (1)
- # overtone (1)
- # perun (6)
- # protorepl (16)
- # re-frame (20)
- # reagent (1)
- # reitit (6)
- # rum (8)
- # shadow-cljs (96)
- # spacemacs (8)
- # specter (4)
- # tools-deps (18)
- # uncomplicate (1)
- # vim (1)
is there a way to kind of force shadow-cljs
to not include a namespace? e.g. we get cljs.pprint
in our bundle due to some bad DCE and would like to force it to be gone ๐ thinking maybe a hook could do this?
that is currently not possible with hooks. the closure compiler supports stripping by namespace so it could remove everything starting with cljs.pprint
. the option for that however is not exposed since its kind of a footgun and easy to destroy your entire build using it
so I just released 2.7.11
which exposes those options. I'll just document with a warning but basically you can now add :compiler-options {:strip-type-prefixes #{"cljs.pprint"}}
that will remove everything cljs.pprint
related, which also includes every USE of cljs.pprint
so beware ๐
I have a Node and browser build, with some shared code between the two. Remind meโis it recommended to split these into two separate projects, or can I stick them in the same one?
Follow up question: when selecting a build with shadow.cljs.devtools.api/nrepl-select
, how can I switch over to another build? Can I require shadow-cljs from within the build?
OK, so I'm trying to do something really wonky to see if it works: running separate scripts in dev mode in the same browser tab at the same time. Doesn't work, even a little bit. Namespaces (cljs., goog., etc.), in assuming they're alone in the global scope, clash of course. Any ideas of how to make it work? Basically, I have two scripts, where either one, or both, might be in dev mode at the same time. One script calls stuff in the other one.
@henrik in general it is not advised to run 2 separate CLJS builds in the same app at all ever. dev or release. both will include their own version of cljs.core and won't be compatible with each other
Alright. So this essentially means that I couldn't have a CLJS-generated script sitting on a CDN somewhere, to be pulled into a site as a JS script, compiled and ready for consumption, if that site itself happens to use CLJS.
I admit, it probably doesn't happen much. A thing built in CLJS, targeted at a JS audience, but not available as CLJS library.
https://github.com/uscensusbureau/citysdk does exactly that
Hi, just trying out shadowcljs for the first time. I'm making progress getting through all the compilation errors, but I keep getting this warning:
------ WARNING #1 --------------------------------------------------------------
File: shadow/module/main/append.js:2
variable shadow$umd$export is undeclared
--------------------------------------------------------------------------------
any clues as to what might be wrong would be super helpful, thanksMore info: I'm compiling for node and running on AWS lambda. This is the execution error I get:
{
"errorMessage": "Cannot find module 'bluebird'",
"errorType": "Error",
"stackTrace": [
"require (internal/module.js:11:18)",
"/var/task/main.js:494:240",
"shadow$umd$export (/var/task/main.js:5:22)",
"Object.<anonymous> (/var/task/main.js:9:3)",
"Module._compile (module.js:652:30)",
"Object.Module._extensions..js (module.js:663:10)",
"Module.load (module.js:565:32)"
]
}
I can see the shadow$umd$export
mentioned in there, so I suspect it's relatedah thanks, i'm learning about npm as i go. i take it those deps aren't pulled in by leiningen?
ok cool. can you recommend somewhere i can read about how to use the npm dependencies once i've done npm install bluebird
(i've done yarn add bluebird
, which i'm hoping does the same thing)?
so in my case i'm trying to work out how to get these npm deps into AWS lambda, they don't seem to go into the target
folder which is what i'm sending to AWS
your help is much appreciated, and i'm writing a blog post about how to do this so hopefully it'll go a little further yet!
just out of interest, when developing with shadow-cljs, how do you know which npm deps you need to install?
for example, you add a clojurescript library, and when it runs it'll throw errors for all the missing npm libraries until you install them, right?
those can't install the deps automatically since the cljsjs deps don't declare their npm dependencies
when using anything react related you probably just do yarn add react react-dom create-react-class
so yeah its just libraries that don't declare npm deps properly since they typically just use cljsjs instead
on that js/fetch
, what is that? is there some js interop i can use to make http requests without having to use a cljs one?
no, it doesn't because there's no XmlHttpRequest in node, which cljs-http requires. i've also looked at kvlt, but that has the similar problem of needing other stuff, which is why i'm learning about npm
cool, maybe straight interop will be easier, although it seems to require npm as well which is the main problem
yeah it looks as though that's always available, but i'd have to write a bunch of code to handle chunked responses. i'm guessing that solving the npm problem will be easier, and it has obvious other benefits for the future
incidentally i always get the variable shadow$umd$export is undeclared
warning on compilation. is that something to worry about?
)$ yarn shadow-cljs release app; cd target; rm arch
ive.zip; zip -r archive.zip *; cd ..
yarn run v1.12.3
$ /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/node_modules/.bin/shadow-cljs release app
shadow-cljs - config: /mnt/c/Users/conan/dev/minimal-shadow-cljs-nodejs/shadow-cljs.edn cli version: 2.7.9 node: v8.15.0
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm release app
[:app] Compiling ...
------ WARNING #1 --------------------------------------------------------------
File: shadow/module/main/append.js:2
variable shadow$umd$export is undeclared
--------------------------------------------------------------------------------
nil
[:app] Build completed. (130 files, 1 compiled, 0 warnings, 16.52s)
Done in 37.80s.
shadow-cljs.edn
:
{:lein true
:builds {:app {:target :node-library
:exports {:handler server.main/handler}
:output-dir "target"
:output-to "target/main.js"}}}
just to wrap up, i went through all the npm errors one by one installing each dep and now it's working! in the end i used kvlt. thanks for your help!
@huxley has always been possible. just not as smooth as it could be since I don't do any react-native development myself and haven't worked on support for a while