This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-08
Channels
- # announcements (7)
- # babashka (44)
- # beginners (162)
- # cider (22)
- # clara (11)
- # clj-kondo (14)
- # cljsrn (8)
- # clojure (91)
- # clojure-dev (24)
- # clojure-europe (6)
- # clojure-france (4)
- # clojure-italy (11)
- # clojure-nl (4)
- # clojure-spec (11)
- # clojure-uk (14)
- # clojurescript (92)
- # community-development (1)
- # core-logic (1)
- # cryogen (1)
- # cursive (6)
- # data-science (3)
- # datahike (3)
- # datomic (32)
- # degree9 (3)
- # dirac (3)
- # emacs (9)
- # eql (1)
- # events (1)
- # find-my-lib (1)
- # fulcro (67)
- # graphql (13)
- # helix (9)
- # jobs (1)
- # jobs-discuss (92)
- # leiningen (31)
- # malli (8)
- # meander (3)
- # news-and-articles (1)
- # off-topic (46)
- # pathom (2)
- # practicalli (1)
- # re-frame (52)
- # reitit (12)
- # shadow-cljs (40)
- # spacemacs (10)
- # sql (4)
- # xtdb (8)
Finally got around to create a repro for broken source-mapping when targeting :node-libray
(and to an extent :node-script
): https://github.com/martinklepsch/shadow-src-map-issues
Did anyone else encounter unexpected results with source maps and these targets?
@martinklepsch private repo? it get a 404
@thheller oops, fixed!
I tried latest but somehow
npm install --save-dev shadow-cljs
didnβt add a package.json, will fixbtw dunno if you tried but
$ node -r source-map-support/register -e 'var x = require("./functions/index"); x.throw()'
/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/index.js:253
556298533),Ve=new Tb(null,"more-marker","more-marker",-14717935);function qf(a){throw Error(["[",G.a(a),"] Fabricated example exception"].join(""));}var rf=["icebreaker","server","util_reduced","something_that_throws"],sf=aa;rf[0]in sf||"undefined"==typeof sf.execScript||sf.execScript("var "+rf[0]);for(var tf;rf.length&&(tf=rf.shift());)rf.length||void 0===qf?sf=sf[tf]&&sf[tf]!==Object.prototype[tf]?sf[tf]:sf[tf]={}:sf[tf]=qf;
^
Error: [api-endpoint-error] Fabricated example exception
at qf (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/cljs/core.cljs:10747:20)
at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/goog/base.js:169:3)
at [eval]:1:46
at Script.runInThisContext (vm.js:96:20)
at Object.runInThisContext (vm.js:303:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at evalScript (internal/bootstrap/node.js:582:27)
at startup (internal/bootstrap/node.js:267:9)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
I guess this fails https://github.com/martinklepsch/shadow-src-map-issues/blob/master/view-source.clj#L1
Seeing the similar results with -r source-map-support/register
Do you want me to open an issue for this?
@martinklepsch suppose this looks better π
Error: [api-endpoint-error] Fabricated example exception
at Object.throw (/mnt/c/Users/thheller/code/tmp/shadow-src-map-issues/functions/icebreaker/server/util_reduced.cljs:4:30)
at [eval]:1:46
That indeed looks better π
This is probably a horrible idea and I probably won't pursue it, but let's say I want to allow my self-hosted cljs app to be distributed as just html+js files with no server. I then wouldn't be able to make any ajax calls due to cross origin policy. I believe I could support this by replacing ajax calls with dynamically adding a script tag to the DOM linking to the a js file that puts the json in a variable.
To do this with shadow, in theory, could I just add a postprocessing step to put index.transit.json
and the bootstrap analysis files into js files, and then rewrite a selfhost load
/`init` function based on the current shadow browser load mechanism? Or is there something obvious I'm missing
no clue how that would work but I guess you could also create one gigantic .html file that just already contains everything
I believe I could append a <script src="x.js">
tag with the source being
var transit123 = ...
and kinda have a "fake ajax" layer that way, but yeah maybe I should try the big file first to see how that worksyou can create <script type="my-transit" data-key="some-name">... transit contents here ...</script>
(or <template>
) tags
then when its time to parse them just look it up by data-key
or so and parse the text
I was thinking for performance reasons though to defer the loading until needed, but I might be overthinking that
if its not script
tags have a non-js type
the parser just skips over them. that should be pretty fast and you are talking about local access so no network concerns.
just gotta be careful whats in those transit strings. will get you into trouble if there is a {:foo "</script">"}
transit encoded value in there since the HTML parser is just looking for </script>
and doesn't to any kind of other parsing