@ketan.srivastav shadow-cljs has no notion of manifest versions, you just put whatever into the manifest. no clue how that works nowdays.
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-xlsxI 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-npmI’d be curious why the world is like this but at least got it to work!
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
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.So “works on my computer!” 🙂
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
👍
try :as
instead of :default
(as per 2nd paragraph in https://shadow-cljs.github.io/docs/UsersGuide.html#_about_default_exports)
Still getting (.-build xlsx) => nil
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.
but there is a // Or var xlsx = require('node-xlsx').default;
example so should be fine?
I tried plain js/require but got an empty ja map there too. I’ll give this another try tomorrow