This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-21
Channels
- # beginners (25)
- # cljsrn (3)
- # clojars (4)
- # clojure (37)
- # clojure-news (1)
- # clojure-poland (2)
- # clojure-uk (6)
- # clojurescript (9)
- # datomic (2)
- # duct (7)
- # fulcro (2)
- # hoplon (3)
- # jobs (1)
- # keechma (1)
- # luminus (1)
- # off-topic (27)
- # om (3)
- # om-next (2)
- # overtone (4)
- # pedestal (2)
- # re-frame (11)
- # reagent (4)
- # reitit (6)
- # rum (2)
- # shadow-cljs (212)
- # slack-help (3)
- # spacemacs (1)
- # sql (1)
- # test-check (32)
- # tools-deps (1)
Actually reagent
has React as cljsjs dependency. And if you download and compile the sample project above - you'll see that it pulls React from cljsjs. The question is - can I use :exclusions
like in leiningen
project setup to exclude that dependency?
I don’t think you have to (but you can). The cljsjs dependency won’t actually import the JavaScript because shadow’s cljsjs shim doesn’t let it. That’s why you need it in the package.json.
@achikin it downloads cljsjs packages since it just follows the dependencies. It does not however ever use any cljsjs packaged code. Its just on the classpath, never in your build. You can exclude it from the deps if you care about that but it doesn't matter.
I see that I can have :dev
and :release
configuration options. But can I have dev dependencies? Or it does not make sense?
@achikin doesn't really apply to CLJS since the build decides what is used not the classpath
but in general I find the pattern of using the classpath to replace certain namespaces horrible and annoying to work with
see https://code.thheller.com/blog/shadow-cljs/2018/02/08/problem-solved-source-paths.html
I talked to Daniel about re-frame-10x and read the tracing code and the conclusion is that there is no harm in not using the stubs. You need only to have the correct closure defines for dev and prod. The tracing is added using macros that use the closure defines to decide to do the tracing or use the core fn
and defn
.
does the presence of warnings prevent hot swapping? i was doing a refactor and i have a bunch of warnings that i’m trying to fix and it seems like hot swap is off
At least I’m not losing it. Can I force a reload anyway or turn that feature off? Sometimes it is helpful to be able to iterate on code to get rid of the warnings.
@thheller I keep running into all sorts of half-mangled stuff with the advanced optimisation and the JS-on-classpath stuff; some things in the node_modules that get imported by that JS don't get mangled, yet in that JS the same property name does get mangled
not sure if you have any suggestions, but in the meantime I've reverted back to simple optimisations; it's a bummer because I lose DCE, but at least things work 😛
@thheller on a somewhat unrelated topic, how can I build a local test version from source of shadow-cljs? I managed to build it following the circleci setup, but it always tries to pull down the jar from maven/clojars, at least when I try and integrate that test version into the actual project I'm trying things on
I've worked out something terribly hacky by copying the jar into the local ~/.m2 under a new version that doesn't exist, etc, but I hope there's a better way 😛
I've tried hacking shadow-cljs so that it runs the js-on-classpath through closure/convert-sources-simple
instead of closure/convert-sources
, but perhaps unsurprisingly that doesn't really work, it doesn't recognize the es6 module export/imports
@alex340 do you have reproducable examples for the name mangling sometimes not working? seems like something the closure folks may be interested in
trying to disable optimizations, for example, but that doesn't fix anything; it just reduces the bundle size somewhat
I don't have any nice factored-out examples of the mess I'm getting myself into with that name mangling, no. I might try that tomorrow
if you change this https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/resolve.clj#L145
the hack with treating them the same as npm fails in practice, even though it compiles
yeah like I said .. playing with fire ... surprised it worked for the Toolbar thing but I guess export saved it
anyway. maybe the way forward is to see if closure compiler on its own on that js file, without any of shadow-cljs or any cljs in general around it, trips up
can you share the JS code that gets mangled? maybe there is a clue in there somewhere
might also be some of my externs inference or other JS processing. maybe its just skipping over something important
the latest thing that was tripping it up is mangling the "onlyIn" to "zG" or whatever, but not in the soft-break module
never used closure compiler on its own, but I think I'm going to see if I can set it up on just that one file (removing the cljs dependencies)
hmm one other thing. you aren't actually writing this code by hand? it looks like it was pre-processed by babel?
This is the babelrc:
{
"presets": [
["env", {
"modules": false
}]
],
"plugins": [
"transform-object-rest-spread",
"transform-class-properties",
"transform-react-jsx"
]
}
some props don't get renamed since they are standard props with externs in either react or just DOM/HTML generic stuff
you can fine tune almost everything but yeah disabling one thing might prevent another thing from working
I wrote this closure pass. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/closure/PropertyCollector.java
is there some sane way of getting closure compiler (standalone) to pick up the stuff in node_modules?
sounds like you are suggesting adding externs for all properties that that thing finds
{tmp/alex.js=[hasMark, data, handleListOpClick, plugins, focus, type, hasInline, collapseTo, renderNode, ref, fontFamily, leaves, typeCell, checked, text, href, state, fontWeight, editorDeserialize, showLinkModal, onChange, textAlign, constructor, alt, textDecoration, renderMark, readOnly, check, fontStyle, handleBlock, node, borderRadius, style, object, tableOp, onKeyDown, flexGrow, blockName, typeItem, handleHideLinkModal, document, editorStateFromText, className, typeDefault, title, renderEditor, writable, spellCheck, listOp, flex, enumerable, handleLinkButtonClick, handleTableOpClick, disabled, onlyIn, hasBlock, placeholder, value, key, __proto__, editor, padding, types, backgroundColor, editorSerialize, typeTable, src, typeRow, handleMark, flexDirection, display, onPaste, marks, renderToolbar, toggleMark, prototype, handleHeading, editorEmptyState, nodes, toggleBlock, decorateNode, nodeKey, Editor, configurable]}
can you check if you .shadow-cljs/builds/<build-id>/release/externs.shadow.js
has them?
❯ cat .shadow-cljs/builds/prod/release/externs.shadow.js | grep onlyIn ShadowJS.prototype.onlyIn;
I started by only adding export.foo
props but that didn't work well enough so I added everything
not sure if my example is really representative, but closure compiler does the right thing on a super trimmed down version with just that slate-soft-break, at least if I use the Es6 module that slate-soft-break provides
[2018-04-21 22:14:11 - SEVERE] node_modules/hoist-non-react-statics/index.js:7: ERROR - The define function must be called as a top-level statement. typeof define === 'function' && define.amd ? define(factory) :
somehow I'm still puzzled why this stuff doesn't just work (TM); don't you end up feeding everything to closure compiler as well? sure, the node_modules stuff gets pre-processed through babel (& a first round of closure compiler?) but then it gets fed in to build it all together, doesn't it?
no. the :shadow-js
stuff (ie. node_modules
) is never passed to the :advanced
compile
it is processed separately with :simple
and then added to the final build AFTER :advanced
https://github.com/thheller/shadow-cljs/commit/e56ec0bcfaddc234bd82e767daf343fddd5377a0
just you running lein install
should invalidate all cache since the shadow-cljs jar changed
well, I've added a println just above your changes for extra paranoia, and that's certainly getting printed
yea, definitely not working. not getting into that externs file, and not affecting what closure compiler outputs