Fork me on GitHub
#clojurescript
<
2022-11-01
>
Dylon Edwards22:11:21

I'm trying to include the ES6 module from the snowball stemmer repo into my clojurescript application (https://github.com/mazko/jssnowball/), but am getting the error, 'The required namespace "snowball" is not available'. I've installed the file, locally, to resources/public/js/modules/es6/snowball.es6 . I've added the following line to my Leiningen project.clj:

:foreign-libs [{:file "resources/public/js/modules/es6/snowball.es6"
                :provides ["snowball"]
                :module-type :es6}]
And in the respective .cljs file, I've added the following:
(ns ...
 (:require [snowball]))
What am I doing wrong? I'm using Leiningen 2.9.10, Clojure 1.11.1, and ClojureScript 1.11.60.

timothypratley23:11:29

I often put build configuration in the wrong place 😆 Probably you didn't make that mistake, but it's something to check /shrug (perhaps show a bit more of the project file for context?)

thheller06:11:36

that sounds like a shadow-cljs error. do you use shadow-cljs?

thheller06:11:05

if so you follow this https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js, as :foreign-libs is not supported

thheller06:11:26

or you just use the npm package which also seems to exist? https://github.com/mazko/jssnowball/tree/master/js_snowball/npm

Dylon Edwards20:11:59

@U05224H0W, that is exactly my problem. I do use shadow-cljs, but only because it's used by the Leiningen template I used to generate my app. I've been out of the CLJS loop for a little while and shadow-cljs is new to me. I ended up rewriting the ES5 version of the stemmer to old-school JS and included it like a standard script file. I'll experiment with your suggestions, thanks!

thheller20:11:53

npm i snowball-stemmers

thheller20:11:16

(ns your.thing (:require ["snowball-stemmers" :as x])) (x/newStemmer ...)

colinkahn22:11:53

General question, why doesn't Range check equality using its start/end when comparing to another Range?