Fork me on GitHub
#shadow-cljs
<
2021-05-31
>
thheller16:05:17

@ketan.srivastav shadow-cljs has no notion of manifest versions, you just put whatever into the manifest. no clue how that works nowdays.

martinklepsch18:05:03

I’m trying to require node-xlsx but somehow I’m not having luck with this:

import xlsx from 'node-xlsx';
translated to this (https://shadow-cljs.github.io/docs/UsersGuide.html#npm)
["node-xlsx" :default xlsx]
With this approach xlsx is nil. With other approaches it returns an empty object but nothing that contains the build method mentioned in https://www.npmjs.com/package/node-xlsx

martinklepsch19:05:44

Still getting (.-build xlsx) => nil

thheller20:05:37

maybe try (js/require "node-xlsx"), there seem to some newer ESM only node packages that only work with import. those are not yet supported.

thheller20:05:06

but there is a // Or var xlsx = require('node-xlsx').default; example so should be fine?

martinklepsch20:05:24

I tried plain js/require but got an empty ja map there too. I’ll give this another try tomorrow

rberger23:06:51

I just went thru something similar with https://github.com/daily-co/daily-js It had two “libraries” under [email protected]/daily-js/dist/ I first tried out doing the explicit file import as part of the require:

(:require
  ["@daily-co/daily-js/dist/daily-iframe-esm.js" :default DailyIframe])
to see which one worked and then moved it into shadow-cljs:
:js-options
           {:resolve {"@daily-co/daily-js" {:target :npm
                                            :require "@daily-co/daily-js/dist/daily-iframe-esm.js"}}}
as per https://shadow-cljs.github.io/docs/UsersGuide.html#js-resolve-npm

rberger23:06:37

I’d be curious why the world is like this but at least got it to work!

rberger00:06:59

That being said, now that I did a quick try with xlsx, you are having a different problem. xlsx is being set from (:require ["node-xlsx" :as xlsx]) so the basic import is working

rberger00:06:31

Actually for me it works fine:

(:require ["node-xlsx" :as xlsx])
(js/console.log "XLSX: " (.-build xlsx))
Produces the following in the console:
XLSX:  λ[]
       jsƒ (worksheets,options)
Using :default instead of :as works the same for me.

rberger00:06:39

So “works on my computer!” 🙂

martinklepsch12:06:35

So for me it actually turned out the problem existed between the chair and the keyboard. I thought I installed a different library than what I had actually installed, thus the require didn’t work. Interestingly it didn’t hard-fail either