Fork me on GitHub
#re-frame
<
2018-07-26
>
dijonkitchen16:07:25

Have people had success with :npm-deps? I made a new re-frame project with lein new re-frame npm-deps-test then added

:npm-deps {:react "16.4.1"
                    :react-text-mask "5.4.3"}
:install-deps true
in the :compiler map. But when I :require [react-input-mask] in views.cljs, I get the following error:
No such namespace: react-input-mask, could not locate react_input_mask.cljs, react_input_mask.cljc, or JavaScript source providing "react-input-mask" 

henrik16:07:07

Check out #shadow-cljs. I was tearing my hair out over that, and then I switched to Shadow. Worked flawlessly, with no additional configuration.

henrik16:07:29

Just yarn add and then use directly in require. Didn't bother with npm-deps.

dijonkitchen16:07:23

Thanks henrik, I looked into this a little, but I’m not sure if it’ll be fragile long-term versus the native npm-deps.

henrik16:07:13

Well, if it is, switching shouldn’t be more work than you’re spending on it right now.

henrik16:07:10

This is roughly what my package.json looks like:

{
  "name": "server+client",
  "description": "Basic setup",
  "scripts": {
    "purge": "./clean.sh",
    "sass:dev": "sass --watch src/sass/main.sass:../public/css/main.css",
    "sass:release": "sass src/sass/main.sass:../public/css/main.css",
    "server:dev": "./shadow-cljs watch server",
    "server:release": "./shadow-cljs release server",
    "client:dev": "./shadow-cljs watch client",
    "client:release": "./shadow-cljs release client",
    "release": "yarn purge; yarn server:release && yarn client:release && yarn sass:release"
  },
  "dependencies": {
    "react": "^16.4.0",
    "react-dom": "^16.4.0",
    "shadow-cljs": "^2.4.5"
  },
  "private": true
}

henrik16:07:12

where ./shadow-cljs is just a symlink to node_modules/.bin/shadow-cljs

dijonkitchen16:07:13

Thanks henrik, I’ll take a deeper look at shadow-cljs. If anyone else has advice, I’m all ears.

valtteri18:07:00

npm-deps should be considered still experimental and is thus only for those who are adventurous. Most common alternatives that I know of for consuming packages from npm are: - shadow cljs (simplest setup and best developer experience) - “double bundle” (use webpack to manage and build npm deps) https://clojurescript.org/guides/webpack

👍 4
dijonkitchen02:07:00

So sad… but thanks!

valtteri21:07:35

Also you may find some libraries ”pre-packaged” in cljsjs. http://cljsjs.github.io They are easy to use but only small subset of npm libraries and versions are there.

👍 4
dijonkitchen19:07:51

Thanks, but not everything is on it, e.g., react-input-mask