Fork me on GitHub
#shadow-cljs
<
2023-11-29
>
hkjels13:11:29

I'm trying to include "react-markdown", but it includes a library with exports defined in the package.json file (https://github.com/syntax-tree/unist-util-visit-parents/blob/58e20d8366363b8b6e22d2e9c82d2ded408ecf16/package.json#L34C19-L34C19) that shadow-cljs doesn't seem to catch. I found an issue stating that this is implemented https://github.com/thheller/shadow-cljs/issues/977 Do I need to turn this feature on some how?

thheller14:11:04

what exactly is the issue?

thheller14:11:19

exports is fully supported, unless you are on an older version since it is pretty recent

thheller14:11:21

and no, you don't need to enable it. it is on by default.

hkjels15:11:18

The required JS dependency "unist-util-visit-parents/do-not-use-color" is not available, it was required by "node_modules/unist-util-visit/node_modules/unist-util-visit-parents/lib/index.js". Happens with the latest version of shadow-cljs

hkjels15:11:44

The do-not-use-color is just specified in exports of the package-file. https://github.com/syntax-tree/unist-util-visit-parents/blob/58e20d8366363b8b6e22d2e9c82d2ded408ecf16/package.json#L34C19-L34C19 I'm not familiar with how that works tbh

hkjels15:11:37

This happens pretty much for all react libraries that work with markdown as they all use unist-util it seems

thheller15:11:28

and which version of that package do you have installed?

thheller15:11:07

as in node_modules/unist-util-visit-parents/package.json

hkjels15:11:32

I've tried a few. With the latest version of react-markdown, it takes in unist-util at "^5.0.0"

thheller15:11:49

and which version is it currently?

hkjels15:11:56

Let me check, one sec

thheller15:11:59

I mean if I look at it only v6 has this exports field

thheller15:11:15

so if you have 5.x the error is completely legit, as that file doesn't exist

hkjels15:11:09

You are absolutely correct. It seems like a very widely used library, so I don't get how this is not a problem for ones in the JavaScript ecosystem

thheller15:11:37

dependency conflicts are very common in JS world last time I checked 😉

hkjels15:11:48

Thank you for helping me out

hkjels20:11:20

actually, there seems to be a problem. There are just many dependencies with almost the same name, so it was a bit hard to spot. "unist-util-visit-parents": "^6.0.0" is a dependency of unist-util-visit. And unist-util-visit-parents is where the problem occurs

hkjels20:11:16

unist-util-visit is at version 5.0.0, so react-markdown is effectively using that either way with ^5.0.0

thheller21:11:27

I'm not sure I follow

thheller21:11:11

npm dependency conflict resolution is basically non existent and sometimes needs a hand

thheller21:11:33

so your constellation of dependencies just might end up getting the wrong version somehow

thheller21:11:44

this is nothing shadow-cljs can do anything about or work around, so you have so resolve it

Eric Dvorsak23:01:17

@U0B1SDL67 did you find a solution? seems like it's an ESM related issue?

hkjels11:01:31

No. I wrote a parser myself instead