Require scoped module in Clojurescript

274 views Asked by At

I have started using the :target :nodejs compiler options for a cljs project (src). By and large, it works well.

However, when attempting to convert @mapbox/react-native-mapbox-gl to the updated require syntax, e.g.

(:require [@mapbox/react-native-mapbox-gl])

it fails -

Library name must be specified as a symbol

as the npm module is scoped with @. Using a string does not work either.

This works-

(set! js/MapboxGL (js/require "@mapbox/react-native-mapbox-gl"))

But I was curious if there was any way to get this compiled with the require syntax.

1

There are 1 answers

3
ka yu Lai On BEST ANSWER

if you using 1.9.854 or above,

you can now use string in :require

(:require ["@mapbox/react-native-mapbox-gl" :as mapbox])

hope you enjoy using ClojureScript