This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-30
Channels
- # announcements (15)
- # beginners (143)
- # boot (2)
- # calva (48)
- # cider (93)
- # cljsrn (2)
- # clojure (127)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-losangeles (8)
- # clojure-nl (10)
- # clojure-spec (67)
- # clojure-uk (51)
- # clojurescript (20)
- # cursive (9)
- # data-science (2)
- # datomic (10)
- # duct (13)
- # figwheel-main (1)
- # fulcro (74)
- # instaparse (10)
- # jobs (3)
- # joker (8)
- # juxt (4)
- # lumo (1)
- # malli (11)
- # nrepl (3)
- # off-topic (4)
- # pathom (5)
- # pedestal (6)
- # planck (5)
- # re-frame (18)
- # reagent (5)
- # reitit (17)
- # shadow-cljs (165)
- # sql (30)
- # vim (12)
- # xtdb (6)
@thheller Sorry to bother you again with this. Some more info with the broken stuff I'm seeing whenever I restart shadow-cljs. This seems to be the "root" error, AFAICT.
it is just telling you that it failed to load that module. the reason that it failed is somewhere else
try {
moduleFn.call(
module,
goog.global,
shadow.js.jsRequire,
module,
module["exports"]
);
} catch (e) {
console.warn("shadow-cljs - failed to load", name);
throw e;
}
It's a huge log that doesn't copy well -- but this snippet shows shows that the root error is below.
The only "error" in the console is at the very end:
main.cljs:105 Uncaught TypeError: nosco.routes.start_routing_BANG_ is not a function
at Object.nosco$views$main$start [as start] (main.cljs:105)
at admin:14
nosco$views$main$start @ main.cljs:105
(anonymous) @ admin:14
well it might be ... the problem is that it might not exist because loading it failed
main.js:2176 failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function
at Object.shadow$provide.module$node_modules$react_redux$lib$components$Context (Context.js:11)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_redux$lib$components$Provider (Provider.js:15)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_redux$lib$index (index.js:8)
at shadow.js.jsRequire (js.js:63)
at Object.shadow$provide.module$node_modules$react_beautiful_dnd$dist$react_beautiful_dnd_cjs (react-beautiful-dnd.cjs.js:14)
at Object.shadow.js.jsRequire (js.js:63)
at Object.shadow.js.require (js.js:97)
at eval (/js/cljs-runtime/nosco.views.page_list.js:8)
ok failed to load nosco.views.page_list.js TypeError: global(...).default.createContext is not a function
that seems to be the actual error
then start the watch again and please verify that it does NOT say connected to server
on startup
Done. BTW the offending file looks like so:
shadow$provide["module$node_modules$react_redux$lib$components$Context"] = function(global,require,module,exports) {
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = exports.ReactReduxContext = void 0;
var _react = _interopRequireDefault(require("react"));
var ReactReduxContext = _react["default"].createContext(null);
exports.ReactReduxContext = ReactReduxContext;
var _default = ReactReduxContext;
exports["default"] = _default;
};
No other shadow running, verified by jcmd, here's the new startup log
shadow-cljs - config: /Users/orestis/dev/nosco/gamma/shadow-cljs.edn cli version: 2.8.55 node: v12.9.0
shadow-cljs - starting via "clojure"
INFO [main] org.xnio - XNIO version 3.7.3.Final
INFO [main] org.xnio.nio - XNIO NIO Implementation Version 3.7.3.Final
INFO [main] org.jboss.threads - JBoss Threads version 2.3.2.Final
shadow-cljs - server version: 2.8.53 running at
shadow-cljs - nREPL server started on port 61137
And now everything works because I was poking around before, and renamed something in .shadow-cljs/builds/main/dev/
. I have the original files around.
if people resort to the standard lein clean
practice before compiling ... just because ... I'll consider this project failed.
Yep, browser cache is disabled, serving files with Cache-Control: private, no-cache, no-store
{:target :browser
:output-dir "dev-resources/public/main/js"
:asset-path "/js"
:modules {:main {:entries [nosco.views.main]}}
:compiler-options {:infer-externs :auto}
:devtools {:watch-dir "dev-resources/public/main"
:loader-mode :eval}
:release {:output-dir "gamma-dist/main/js"
:closure-defines {nosco.routes/WORMHOLE-EXIT true
nosco.controllers/ALL-FEATURE-FLAGS-ENABLED false}
:module-hash-names true
:cache-blockers #{gamma.translate}
:build-hooks [(gamma.translate/write-pot-file "translations/gamma.pot")
(gamma.translate/clear-messages)]
:build-options {:manifest-name "manifest.json"}}}
No, that's called by index.html:
<script src="/js/main.js"></script>
<script>
nosco.views.main.start(document.getElementById("main"))
</script>
The code for that is
(defn ^:export start [el]
(reset! EL el)
(add-watch nosco.controllers/app-state :main-render
(fn [_ _ _ s]
(js/console.log "new state is " s)
(let [{:keys [user siteConfiguration]} s]
(when (and user siteConfiguration)
(js/console.log "initial render")
(react-dom/render
(hx/f [Main])
el)))))
(routes/start-routing!))
(ns nosco.views.page-list
(:require
[hx.react :as hx :refer [defnc]]
[hx.hooks :refer [useState useContext]]
[nosco.ui.table :as table]
[nosco.ui.components :as components]
[cljs-bean.core :refer [bean ->clj ->js]]
["react-beautiful-dnd" :refer [DragDropContext Droppable Draggable]]))
(def initial-items
(mapv #(hash-map :order % :id (str "oid-" %) :title (str "Item " %)) (range 10)))
do you have a (:require ["React" ...]
somewhere in your code or is that caused by some library?
I'm on macOS which I is case insensitive, so the filename resolves to the correct file I guess.
How should I debug this now? Changing the import and relying on hot reload threw an error.
There might be a chance that with all other react libraries, something else might be doing the same thing, but I think that various CI tools would catch it.
I think this might be the actual cause of your problems .. let me know if it happens again
And should it be done while shadow is running? Or should I stop shadow, wipe the cache, start again?
ok I think I found the bug causing this ... something I've been meaning to address for a while
Things are working again (but they always work if I blow away the cache). I'll start over again and see what happens.
Works! Many thanks for helping here. Final question, is calling the start function from HTML discouraged?
no that is fine. from the stacktraces it just looked like things were going wrong while loading because of the start call
still trying to figure out how your bug actually happens ... seems like it should either always happen or never
@thheller I think case-(in)sensitivity is a major theme in my codebase 😄. Just found a case where importing date-fns/parseIso
(wrong) vs date-fns/parseISO
(correct) was breaking. The funny thing is that: (:require ["date-fns/parseIso" :as parseIso])
was returning something (an empty js object), which then broke downstreams consumers.
Does anyone have a quick example on how to generate a basic index.html using manifest.edn?
like this one https://github.com/thheller/shadow-cljs/blob/master/out/demo-browser/index.src.html
and in your build config
:build-hooks
[(shadow.html/copy-file
"out/demo-browser/index.src.html"
"out/demo-browser/public/index.html")]
basically that'll replace the <script src="/js/base.js" defer></script>
with <script src="/js/base.<hash>.js" defer></script>
> Could not locate shadow/html__init.class, shadow/html.clj or shadow/html.cljc on classpath.
ah, {:type :shadow.html/source-does-not-exist, :source "public/js/index.src.html", :shadow.build.log/level :info}
Hi, I am trying to call a constructor for JS object from npm as follows:
(:require ["bezier-js" :as bezier])
(bezier/Bezier. x1 y1 x2 y2 x3 y3)
The object is from this library: https://pomax.github.io/bezierjs/#constructor.
I am getting this error:
TypeError: module$node_modules$bezier_js$index.Bezier is not a constructor
at orgpad$client$util$geom_link$create_quadratic_bezier_from_control_point (orgpad/client/util/geom_link.cljs:39:9)
at eval (eval at shadow$cljs$devtools$client$browser$global_eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js), <anonymous>:1:73)
at eval (<anonymous>)
at Object.shadow$cljs$devtools$client$browser$global_eval [as global_eval] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:829:16)
at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:838:44)
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:145:108)
at Object.shadow$cljs$devtools$client$browser$repl_invoke [as repl_invoke] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:836:46)
at shadow$cljs$devtools$client$browser$handle_message (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.browser.js:921:37)
at eval (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:294:151)
at Object.shadow$cljs$devtools$client$env$process_next_BANG_ [as process_next_BANG_] (/js/compiled/cljs-runtime/shadow.cljs.devtools.client.env.js:273:90)
I can access functions from that module, i.e.,
(.quadraticFromPoints bezier ...)
@pavel.klavik unfortunately, how to import foreign JS can often vary depending on how the JS is packaged
based on their docs, I would expect that you would use the bezier
as the constructor but it’s hard to know for sure
cool, it works
I'm trying to use https://github.com/Pikaday/Pikaday. shadow-cljs fails the build with
The required JS dependency "moment" is not available, it was required by "node_modules/pikaday/pikaday.js".
However, the GitHub library page says "No dependencies (but plays well with Moment.js)". Why does shadow think it needs it?Is there a way to tell shadow that I actually don't need a dependency? The error message seems to hint that shadow isn't sure: "You probably need to run:"
You probably need to run:
npm install moment
Oh gotcha. That'd be useful to have here: https://shadow-cljs.github.io/docs/UsersGuide.html#_missing_js_dependency.