Fork me on GitHub
#shadow-cljs
<
2019-07-04
>
neupsh00:07:27

hi, what is the equivalent of the following in a cljs repl (shadow-cljs)?

var ice = require('./assets/ice.jpg');

neupsh00:07:10

I tried

(def ice (js/require "./assets/ice.jpg"))
but it seems to see "require" is not defined

neupsh00:07:36

repl/invoke error, [ReferenceError: Can't find variable: require]

neupsh00:07:37

i also tried

(require '["./assets/ice.jpg" :as ice])
but it just sits there

neupsh00:07:22

FWIW I am using it in expo project

thheller08:07:30

require is a compile time construct (in Expo/RN) so it doesn't work via the REPL

👍 8
p-himik20:07:08

Just tried to use react-vega and got an interesting error (paths truncated for brevity):

package in /.../node_modules/d3-scalespecified entries but they were all missing
{:tag :shadow.build.npm/missing-entries, :entries ["build/d3-scale.js"], :package-dir #object[java.io.File 0x58381a04 "/.../node_modules/d3-scale"]}
ExceptionInfo: package in /.../node_modules/d3-scalespecified entries but they were all missing
I think there's a space missing in d3-scalespecified. And d3-scale is missing from node_modules so it looks like the message "package d3-scale specified entries but they were all missing" is a bit misleading since it's the package itself that's missing.

p-himik20:07:49

Oh no, not again. It's in /.../node_modules/vega-scale/node_modules/d3-scale/.

p-himik20:07:02

And it's not even a git url dependency! NPM, WTH?