This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-13
Channels
- # beginners (50)
- # boot (27)
- # bristol-clojurians (7)
- # cider (30)
- # clara (1)
- # cljs-dev (130)
- # cljsrn (14)
- # clojure (179)
- # clojure-austin (6)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-spec (19)
- # clojure-uk (54)
- # clojurescript (64)
- # core-async (3)
- # data-science (1)
- # datomic (66)
- # duct (11)
- # emacs (5)
- # figwheel (1)
- # fulcro (26)
- # funcool (7)
- # jobs (1)
- # jvm (6)
- # keechma (5)
- # lein-figwheel (5)
- # luminus (5)
- # lumo (1)
- # off-topic (93)
- # parinfer (37)
- # pedestal (15)
- # protorepl (10)
- # re-frame (42)
- # reagent (12)
- # shadow-cljs (71)
- # spacemacs (3)
- # specter (7)
- # vim (8)
- # yada (9)
i’m trying to use PDFJS, which uses a web worker. the web worker is already distributed in the pdfjs-dist
npm module under build/pdf.worker.js
. what’s the right way to tell shadow-cljs about that file and that it need to be served during development and copied & minified during production?
@lee.justin.m when I npm install pdfjs
there is no such file?
Hi. I seem to remember that there was a way to see how much size each library is adding to the total size of the release build using shadow-cljs. Is that a thing, or am I mis-remembering?
@mjmeintjes very crude version exists yes. see https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9?u=thheller
Great, thanks. Exactly the post I was searching for.
No worries, just glad I'm not going mad as I was sure I had seen it somewhere but couldn't find it anywhere.
@lee.justin.m ah I looked at the wrong package. from what I can tell you don't need to use their bundle but instead you create a (ns your.app.worker (:require ["pdfjs-dist/lib/core/worker"]))
and then let shadow-cljs build it for you
@thheller so I thought with web workers you typically have to specify a uri in the worker constructor, which then goes and fetches the source at that uri and then runs it. in javascript all I do is
const PDFJS = window.PDFJS;
PDFJS.workerSrc = '/pdf.worker.js';
and then I make sure that the pdf.worker.js
bundle is available to be served. so if I just straight require it, won’t that just include the worker source rather than allowing it to be run in a new worker? or is there more shadow-cljs magic here?for what it is worth: i think it would be really cool to have shadow-cljs build it for me since the optimizations might be better. i was just trying to do it the easy way first
meaning that code used only by the worker will also only be loaded when the worker is started
the file that :web-worker true
generates is a standalone worker file, ie. you call it with the webworker constructor
Hmm, new error from the closure compiler in 2.1.7:
Closure compilation failed with 1 errors
--- node_modules/dialog-polyfill/dialog-polyfill.js:692
this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
the "problem" with the pre-built pdfjs.worker.js
is that it basically doubles the code your user has to download
code splitting would be better but I don't know exactly what pdfkit expects from the worker
i read through the modules section again. if i understand correctly: i should create an empty cljs file for the worker that includes the entry point for the worker code. then declare that file as a web worker module and shadow will be able to serve it and pdfjs will be able to use it
--- null:-1
Missing externs definition for Symbol. Did you forget to include the ES6 externs?
babel in theory is used for everything es6+ in node_modules for reasons such as this
https://github.com/google/closure-compiler/commit/41331b3d98612101fe09bd01bdd5b305526281e5
yeah I've always done dialogs manually. takes 5 lines of code or so. no idea why you'd need a standard api for that
do you use joker as a linter? it is cranky because of the extension to the ns
and I don’t think it is extensible in thatway