shadow-cljs icon indicating copy to clipboard operation
shadow-cljs copied to clipboard

Can't require imaskjs in npm-module build

Open khmelevskii opened this issue 2 years ago • 2 comments

I'm using the following build

  :storybook {:target           :npm-module
              :output-dir       "public/js/stories"
              :ns-regexp        "platform(.*).stories$"
              :compiler-options {:infer-externs true}
              :release          {:compiler-options {:infer-externs   true
                                                    :reader-features #{:release}}}

              ;; storybook already handles all reloading
              :devtools {:enabled  false
                         :preloads [env.dev]}}

And when I require react-imask (https://github.com/uNmAnNeR/imaskjs - version 7.0.1)

(:require
   ["imask" :as imask] )

I have the following exception:

shadow.js.shim.module$imask.createMask is not a function
TypeError: shadow.js.shim.module$imask.createMask is not a function

As I can see required imask is just empty js object #js {}.

In :browser build everything works great.

khmelevskii avatar Aug 14 '23 20:08 khmelevskii

In a :npm-module build shadow-cljs will not be processing or providing any npm dependencies. That is left to the tool that runs everything, so probably node/storybook? I don't know why it would be empty. shadow-cljs side of code/config looks fine, can't say anything about the other side though.

You can check that the public/js/stories/shadow.js.shim.module$imask.js file contains basically shadow.js.shim.module$imask = require("imask"); and I guess try to find out what storybook makes out of that since it'll replace the require with something (or should).

thheller avatar Aug 14 '23 20:08 thheller

Thank you! I will investigate and share what I found

khmelevskii avatar Aug 14 '23 21:08 khmelevskii