shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
thheller 2021-05-31T16:54:17.293100Z

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

martinklepsch 2021-05-31T18:54:03.295300Z

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

rberger 2021-06-01T23:55:51.304600Z

I just went thru something similar with https://github.com/daily-co/daily-js It had two “libraries” under node-modules@daily-co/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

rberger 2021-06-01T23:57:37.304900Z

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

rberger 2021-06-02T00:19:59.305100Z

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

rberger 2021-06-02T00:27:31.305400Z

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.

rberger 2021-06-02T00:33:39.305700Z

So “works on my computer!” 🙂

martinklepsch 2021-06-02T12:17:35.311Z

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

rberger 2021-06-02T21:50:10.318400Z

👍

nivekuil 2021-05-31T19:09:41.295600Z

try :as instead of :default (as per 2nd paragraph in https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports)

martinklepsch 2021-05-31T19:20:44.295800Z

Still getting (.-build xlsx) => nil

thheller 2021-05-31T20:02:37.296Z

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.

thheller 2021-05-31T20:03:06.296200Z

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

martinklepsch 2021-05-31T20:57:24.297700Z

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