Clojurians
#cljs-dev
<
2018-01-14
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

p-himik06:01:29

I'm trying to use https://github.com/olahol/react-tagsinput with :npm-deps. It doesn't get resolved in the browser, I think because the main file there has to be executed in order to provide some exports (see react-tagsinput.js). But if react-tagsinput.js is mentioned in :foreign-libs, I can use js/ReactTagsInput with no problem, which is good. I decided to try to use :global-exports so that I don't have to write (def react-tagsinput js/ReactTagsInput) or something like that:

{:file           "node_modules/react-tagsinput/react-tagsinput.js"
 :provides       ["react-tagsinput"]
 :global-exports {react-tagsinput ReactTagsInput}}
However, it doesn't work. The :global-exports produces my_namespace.global$module$react_tagsinput = goog.global.ReactTagsInput; and using react-tagsinput produces my_namespace.node$module$react_tagsinput. Do I misunderstand the usage of :global-exports? Or maybe there's a bug?

p-himik06:01:23

Hmm, it also throws Error: Can't resolve 'react' in my_project/node_modules/react-tagsinput And any attempt to debug cljsbuild result in a compilation failed by NPE.

juhoteperi08:01:27

@p-himik Global-exports is not for node modules

p-himik08:01:18

Ok, thanks for confirming.

juhoteperi08:01:12

Hmph, thought the react-tagsinput.js file seems to be UMD module, so in this case that could be OK

juhoteperi08:01:53

But the problem with node_modules and foreign-libs is, that node_modules always take precedence so the foreign-lib entry and global-exports is not going to be used if you have node_modules dir

juhoteperi08:01:03

react-tagsinput seems to be available from Cljsjs, that would work the same as foreign-lib entry