This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-04
Channels
- # announcements (8)
- # beginners (27)
- # calva (8)
- # cider (26)
- # clara (19)
- # cljdoc (4)
- # cljsjs (1)
- # clojure (221)
- # clojure-dev (6)
- # clojure-europe (11)
- # clojure-gamedev (18)
- # clojure-italy (8)
- # clojure-nl (12)
- # clojure-spec (85)
- # clojure-uk (17)
- # clojurescript (34)
- # community-development (1)
- # cursive (26)
- # datomic (16)
- # dirac (19)
- # duct (6)
- # editors (4)
- # figwheel-main (1)
- # fulcro (68)
- # graphql (41)
- # juxt (16)
- # luminus (11)
- # off-topic (30)
- # pathom (35)
- # planck (2)
- # re-frame (18)
- # reagent (20)
- # remote-jobs (6)
- # rum (1)
- # shadow-cljs (37)
- # spacemacs (9)
- # vim (14)
@markx I actually don't like it much. the interceptor design is better in general but some design choices are weird
I liked the fact that Pedestal was ready to go for “production” with some logging etc (and also I liked the interceptor concept). No regrets so far for using it, as you can reuse all the ring middleware out there.
Hi, I'm fairly new shadow-cljs, but very impressed so far.
I'm having an issue though where I get a Uncaught ReferenceError: regeneratorRuntime is not defined
message in the browser console.
I'm using the npm workbox-precaching
package (in a service worker) and the error is occurring in one of the source files this uses (`node_modules/workbox-core/_private/quota.mjs`). It seems that this file (that uses async
/`await`) is getting transpiled to ES5 and the transpiled version is expecting a global regeneratorRuntime
to be defined:
var executeQuotaErrorCallbacks = function () {
var _ref = global.shadow.js.babel.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, callback;
return regeneratorRuntime.wrap(function _callee$(_context) {
Has anyone come across this before?As a workaround, I've found I can get this to work by prepending the JS file that defines regeneratorRuntime
(https://raw.githubusercontent.com/facebook/regenerator/master/packages/regenerator-runtime/runtime.js) to my worker.js
file that shadow-cljs generates. Is there a mechanism in shadow-cljs that will allow me to prepend some JS to a module?
@mike469 what do you require? by default it should be using the node_modules/workbox-precaching/dist/workbox-precaching.prod.js
. which doesn't work either but for different reasons?
I'm doing (:require ["workbox-precaching/precacheAndRoute.mjs" :refer (precacheAndRoute)])
currently which is causing the regeneratorRuntime
error. I don't seem to have a dist
dir in node_modules/workbox-precaching
hmm which version do you use? I just installed [email protected]
my current versions are:
`
"workbox-precaching": "^4.1.1",
"workbox-routing": "^4.2.0",
"workbox-strategies": "^4.2.0"
not sure why there would be no dist, I just npm install'd
them
so the problem is that the babel parts are not meant to rewrite the async/await at all
I'm only using babel to rewrite import -> require since it works differently than what the closure compiler does
hmm I see, so have you managed to get workbox-precaching
working with shadow-cljs previously? Perhaps I just need to figure out why I'm missing the 'dist' versions?
ah ok, so is it babel that inserts the regenerator
references?
it shouldn't touch this at all and just leave async/await
as they are as server workers support that
so usually you'd set :compiler-options {:output-feature-set :es7}
(or whatever async/await was)
yes I did try that but found it had no effect
but that doesn't yet work for node_modules
since it goes through some naive babel processing first
I had to go through babel since babel added some non-standard ESM->CJS interop that lots of npm libs rely on
FYI adding the regenerator-runtime/runtime.js
verbatim to the start of my generated worker js bundle does fix it for me in this instance
(I'm only testing in dev mode currently)
service-workers support async/await so they should not be rewritten to add that huge regenerator crap
Right yes understood. I have to go out now but thanks for your help and drop me a message if you want me to try anything out