Fork me on GitHub
#shadow-cljs
<
2023-01-04
>
chrisn14:01:09

I have a mixed js,cljs https://github.com/cnuernber/ham-scripted written js I would like to consume from another project. What is the recommended way of doing this? Is there an example of a mixed js,cljs npm module I can reference?

thheller14:01:25

its only those files I assume? no actual npm dependency?

thheller14:01:27

assuming the only target audience is cljs users? not actual npm JS consumers?

chrisn18:01:56

Potentially both pure js users and cljs but probably not initially. There are two js files that probably should be in a subdir and two cljs files at the moment

chrisn18:01:39

First will be upgrading tmdjs to use hashmap from bimaptrie.js

chrisn19:01:33

Only cljs for now

thheller20:01:06

if you are ok with cljs only consumers for now you should just put the files on the classpath

thheller20:01:31

so src/ham_fisted/BitmapTrie.js

thheller20:01:07

them slap a goog.module("ham_fisted.BitmapTrie"); goog.module.declareLegacyNamespace(); in the first two lines

thheller20:01:22

and change your module.exports.x assignments to just exports.x assignments

thheller20:01:42

than you can require and use this like any other ClojureJS namespace from cljs

thheller20:01:10

so just (:require [ham-fisted.BitmapTrie :as bm]) with the usual bm/stuff access

thheller20:01:59

it might be picky about the _ vs - situation. never tried a goog.module namespace with a - but should be fine

thheller20:01:45

all the manual node require hacks you are doing you remove of course

thheller20:01:27

all the aget stuff to get the exports obviously isn't needed anymore either

chrisn20:01:04

Wow gotcha will try and get back to you.

chrisn13:01:42

The manual hacks are there to get hot reloading - I imagine there are similar hacks to get hot reloading of the goog module pathway.

chrisn14:01:06

That definitely worked - but it is really difficult to work with. The cljs file can't be recompiled without restarting the emacs cider connection and the js file cannot be recompiled without killing the repl process itself and restarting it.

chrisn14:01:50

I have noticed that so far that files with extend-type in them can often get into states where they will fail to recompile after the first compilation.

chrisn14:01:37

regardless, this is at least a way forward now that the systems have been at least partially debugged.