shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
thheller 2021-05-15T06:47:54.294700Z

your question really is a little vague. there are about hundreds of ways to do this, it really depends on your app and how you want to do it. :closure-defines would be the build-config driven variant. see also https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration

thheller 2021-05-15T06:49:15.295Z

you can also get stuff from the HTML directly, or load if via fetch on startup. really far to many options to mention them all.

yalu 2021-05-15T07:09:05.297200Z

👋 I have this problem working with npm library called js-waku https://stackoverflow.com/questions/66309813/the-required-js-dependency-readable-stream-writable-js-is-not-available-it-wa

yalu 2021-05-15T07:11:50.298900Z

I tried forcing version 2.0.2 of readable-stream as suggested in SO solution but get another error after that transpilation of BigInt is not supported

yalu 2021-05-15T07:12:15.299500Z

Thank you for any help unraveling this mystery

thheller 2021-05-15T07:14:57.300400Z

try :compiler-options {:output-feature-set :es2018} in your build config. maybe :es2019 or :es2020. not sure which language level bigints were

yalu 2021-05-15T07:52:07.301100Z

Cool thank you that make sense I will give it a go

yalu 2021-05-15T08:00:17.302400Z

Seems it was in :es2020 but still no dice 😞 I get failed to convert sources on a whole bunch of libraries

thheller 2021-05-15T08:00:44.302800Z

I cannot guess the errors you get sorry

thheller 2021-05-15T08:01:47.303100Z

:ex-next-in is the highest level possible, maybe that works

yalu 2021-05-15T08:03:04.304Z

ooohh that might js-waku is written in typeScript with compiler option esnext

thheller 2021-05-15T08:03:19.304200Z

that isn't relevant, js config options don't apply to closure compiler options

yalu 2021-05-15T08:05:14.304800Z

still that did not work same failed to convert sources error

npx shadow-cljs watch frontend
shadow-cljs - config: /Users/yalu/Projects/nemonymous/shadow-cljs.edn
shadow-cljs - HTTP server available at <http://localhost:8080>
shadow-cljs - server version: 2.13.0 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 50869
shadow-cljs - watching build :frontend
[:frontend] Configuring build.
[:frontend] Compiling ...
[:frontend] Build failure:
failed to convert sources
{:tag :shadow.build.closure/convert-error, :sources [[:shadow.build.npm/resource "node_modules/object-assign/index.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.production.min.js"] [:shadow.build.npm/resource "node_modules/react/cjs/react.development.js"] [:shadow.build.npm/resource "node_modules/react/index.js"] .............................................

thheller 2021-05-15T08:05:51.305200Z

don't shorten errors ... you cut out the reason why it failed

yalu 2021-05-15T08:14:24.307900Z

It was too big to fit.. so attaching file of log

thheller 2021-05-15T08:15:18.308300Z

RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SHEQ): node_modules/bcrypto/lib/native/bn.js:3605:6
  if ((y &amp; 1n) === 0n)
  Parent(IF): node_modules/bcrypto/lib/native/bn.js:3605:2
  if ((y &amp; 1n) === 0n)

thheller 2021-05-15T08:15:46.308800Z

this is a closure-compiler error, it appears that it doesn't support the code

thheller 2021-05-15T08:16:20.309200Z

you can try using webpack with this method https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external

yalu 2021-05-15T08:17:34.310400Z

Thank you for the prompt response and incredible patience 🙏 I will give webpack a go

thheller 2021-05-15T08:18:01.310900Z

are you sure this code is supposed to be supported in the browser? I see a bunch of node specific stuff so it looks like a node thing to me?

yalu 2021-05-15T08:23:39.311400Z

I am pretty sure it is supposed to be supported in the browser https://www.npmjs.com/package/js-waku

thheller 2021-05-15T08:27:11.311700Z

hmm yeah seems rather cutting edge

yalu 2021-05-15T08:29:15.313200Z

yeah.. freshly released.. hardly battle tested.. I'm also communicating with the dev.. so let's see I'm going to try everything I can