This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-05
Channels
- # asami (13)
- # aws (7)
- # babashka (4)
- # beginners (16)
- # biff (7)
- # cljdoc (10)
- # clojure (32)
- # clojure-europe (27)
- # clojure-nl (14)
- # clojure-norway (7)
- # clojure-uk (3)
- # clojurescript (2)
- # conjure (2)
- # core-async (13)
- # datalevin (4)
- # datomic (3)
- # holy-lambda (7)
- # kaocha (3)
- # lsp (23)
- # off-topic (39)
- # pedestal (10)
- # portal (5)
- # practicalli (2)
- # rdf (10)
- # releases (1)
- # shadow-cljs (66)
- # tools-deps (146)
- # uncomplicate (1)
- # xtdb (10)
> Typically all JS Dependencies are foreign and won’t be passed through :advanced and thus require Externs. > from https://shadow-cljs.github.io/docs/UsersGuide.html#externs Does that mean Closure Compiler not doing dead code elimination on the dependency library?
I've been updating dependencies in a project and running into Module not provided: @babel/runtime/helpers/interopRequireDefault
often. Tricky that it doesn't list which npm package / file is to blame. I think it has to do with using either @babel/runtime
@babel/preset-react
@babel/preset-env
to pre-compile. Is it perhaps because I didn't configure .babelrc
properly? I do have a babel.config.json
that I think shadow-cljs uses.
In this case it couldn't compile: https://github.com/dmonad/isomorphic.js/blob/main/browser.mjs
[2022-09-05 17:14:53.607 - WARNING] :shadow.build.babel/babel-transform-ex - {:code "/* eslint-env browser */\nexport const performance = typeof window === 'undefined' ? null : (typeof window.performance !== 'undefined' && window.performance) || null\n\nconst isoCrypto = typeof crypto === 'undefined' ? null : crypto\n\n/**\n * @type {function(number):ArrayBuffer}\n */\nexport const cryptoRandomBuffer = isoCrypto !== null\n ? len => {\n // browser\n const buf = new ArrayBuffer(len)\n const arr = new Uint8Array(buf)\n isoCrypto.getRandomValues(arr)\n return buf\n }\n : len => {\n // polyfill\n const buf = new ArrayBuffer(len)\n const arr = new Uint8Array(buf)\n for (let i = 0; i < len; i++) {\n arr[i] = Math.ceil((Math.random() * 0xFFFFFFFF) >>> 0)\n }\n return buf\n }\n", :file "/Users/baruchberger/nexus-core/node_modules/isomorphic.js/browser.mjs", :preset-config {:targets {"chrome" "90"}}, :shadow.build.babel/reply-to #object[clojure.core.async.impl.channels.ManyToManyChannel 0x2d46eb58 "clojure.core.async.impl.channels.ManyToManyChannel@2d46eb58"]}
RuntimeException EOF while reading
this isomorphic.js
thing is a dependency of y-webrtc
which is you'd use with yjs
a pretty cool lookin' crdt lib.
as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
you definitely shouldn't have a babel config or manually call babel on the output or input. that is not expected to work
okay, that's a bit confusing to me in how far shadow-cljs
will go there, there is some mention of manually passing things through babel, and that has worked out for me in the past. So just a .babelrc
is supported, and I should get rid of the babel.config.json
in my root?
I don't know. what do you use them for? shadow-cljs ONLY uses babel to transform npm ESM code to commonjs. nothing else, not for polyfilling or whatever else
I wouldn't use babel for this at all but unfortunately the closure compiler is rather picky about its input, so I kinda have to
I use them because I thought it was needed to get some npm deps to work, here and there I've run into these babel-transform-ex
.
no, you should not have any babel config whatsoever. unless you actually use babel manually anywhere I guess
Great, the babel.config.json
seemed to be the problem, code now runs. Thank you very much!
On the topic of the babel config and closure compiler, I’m running into an ES6 transpilation of 'Public class fields' is not yet implemented.
from the closure compiler and was trying to get shadow’s babel config to use include @babel/plugin-proposal-class-properties
, but it doesn’t seem to. Is this a bad idea?
yes, that is bad. it is not a supported use case. basically if you need to use code that the closure compiler doesn't support you are better off using webpack
Hey! Anyone seen any videos or “for-dummies” material on externs?
I get them, yeah. 188 about core.cljs, one about garden color, two about reader_types
Have you seen any shadow-cljs projects using d3 v7? Maybe I could dig that
Or may I buy 30-60 minutes of your time for a zoom session, if you’re open to that. I promise to release a guide for shadow-cljs <-> d3 if that’ll be fruitful.
Sourcemapping with simple optimizations is wrong too
I also have warnings about param names (based on function doc comment) Like
Resource: flow_ui/views/graph-tree-v2.js:809:19
Parse error. invalid param name "optContextPatch.changedNodeId"
> I get them, yeah. 188 about core.cljs, one about garden color, two about reader_types
yes, I got that long list on :infer-externs :all
retrying on :auto
the most direct way to debug externs issues is via shadow-cljs release app --pseudo-names
pseudo-names names variables in a way that lets you recognize what they were originally
retried. Got 29 regular warnings about param names
yeah, pseudo-names may help indeed, thanks!
about these 29 warnings – yeah, my guess is that my doc param naming doesn’t match the Closure scheme
yes, including JS that way only really works if you follow the closure compiler style
on js usage – using it from a CLJS wrapper. Had some issues with d3 modules system, ended up with a crutch (pic). At the time I felt like d3 is written to be compiled by babel or something.
but if the graph-tree-v2.js
file does any interop with d3 then that is likely the source of your externs issues
> follow the closure compiler style will try, thanks!
shadow-cljs release app --pseudo-names
produces good source mapping
I guess I’ll prioritise fixing annotations to exclude their influence. Thanks for the tips!
they don't really fix and externs issues but yes, getting rid of warnings should always be the goal
Externs solved it! Is there a way to generate externs automatically? I need to scan a couple of JS files and dump field names from every constructor in those.
Externs solved it! Is there a way to generate externs automatically? I need to scan a couple of JS files and dump field names from every constructor in those.