# Circular dependency in rollup project

**URL:** <https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975>\
**Category:** Build a Solid App\
**Created:** [December 20, 2022, 11:57pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975 "2022-12-20T23:57:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 20, 2022, 11:57pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/1 "2022-12-20T23:57:06Z")

</div>

Hello there,

I’m working on a Solid Obsidian Plugin and running into a puzzling issue:

While building the code, I get:

node\_modules/@inrupt/solid-client/dist/rdfjs.internal.mjs → node\_modules/@inrupt/solid-client/dist/datatypes.mjs → node\_modules/@inrupt/solid-client/dist/rdfjs.internal.mjs  
node\_modules/n3/src/N3DataFactory.js → node\_modules/n3/src/N3Util.js → node\_modules/n3/src/N3DataFactory.js

Trying to run my plugin in Obsidian now crashes, giving me:

Plugin failure: xxxxxx TypeError: Class extends value undefined is not a constructor or null  
at anonymous (duplexify.js:50:25)  
at e. (app.js:1:1547485)  
at app.js:1:235078  
at Object.next (app.js:1:235183)

Has anyone already faced such circular dependency errors? Any idea on how to debug this?

Candide

---

<div class="post-metadata">

**Author:** ![jeswr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeswr/32/3924_2.png) [@jeswr](https://forum.solidproject.org/u/jeswr)\
**Post date:** [December 21, 2022, 3:14am UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/2 "2022-12-21T03:14:43Z")

</div>

This seems related to [readable-stream upgrade breaks build · Issue #310 · rdfjs/N3.js · GitHub](https://github.com/rdfjs/N3.js/issues/310) rather than being an issue with circular dependencies. Could you open a new issue in [GitHub - rdfjs/N3.js: Lightning fast, spec-compatible, streaming RDF for JavaScript](https://github.com/rdfjs/N3.js/) reporting this?

Can you also try adding

```auto
  "overrides": {
    "n3": {
      "readable-stream": "3.6.0"
    }
  }

```

To your package.json and report whether that fixes the error or not? This would indicate whether it is caused by a breaking change in the readable-stream package.

---

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 21, 2022, 5:50am UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/3 "2022-12-21T05:50:13Z")

</div>

Thank you for the quick update. I created the issue [here](https://github.com/rdfjs/N3.js/issues/315). Unfortunately, the override doesn’t fix the problem.

---

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 21, 2022, 8:20pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/4 "2022-12-21T20:20:30Z")

</div>

Here’s a quick repro repo that demonstrates the issue: [GitHub - ckemmler/solid-circular-dependencies: repro repo demonstrating circular dependencies with inrupt libraries](https://github.com/ckemmler/solid-circular-dependencies)

UPDATE: there was an error in my previous message; I reported the issue to the n3 repo [here](https://github.com/rdfjs/N3.js/issues/31)

That being said, it is possibly related to the inrupt libraries as well.

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [December 24, 2022, 10:52pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/5 "2022-12-24T22:52:56Z")

</div>

Hi from the Developer Tools team at Inrupt, we’re aware of these circular dependencies, however, we’ve never yet seen these be a source of a crash during builds or usage of our SDKs (though I did start work a year ago to attempt to resolve, it’s tricky without potentially breaking API, something we avoid as much as possible)

---

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 25, 2022, 10:41am UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/6 "2022-12-25T10:41:23Z")

</div>

Hi Miss Em,

Thank you for your reply. Indeed I can see that this wasn’t really a problem and I am still trying to identify the root cause of the many issues I’m having since I introduced the inrupt libraries in my project.

At this point, it looks like the simples first issue I am able to nail down is the one I documented here: [crypto.getRandomValues() not supported. · Issue #2550 · inrupt/solid-client-authn-js · GitHub](https://github.com/inrupt/solid-client-authn-js/issues/2550). (I provide a simple repository that demonstrates it [here](https://github.com/ckemmler/solid-build-issues))

I am suspecting something rather deep-rooted, as it looks that, whatever I try to do in my setup is doomed to fail somehow… but I can’t quite put my finger on it, yet.

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [December 25, 2022, 2:45pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/7 "2022-12-25T14:45:48Z")

</div>

I’ve replied to that issue.

---

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 25, 2022, 9:07pm UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/8 "2022-12-25T21:07:23Z")

</div>

Thank you. And I just replied. Unfortunately using @inrupt/solid-client-authn-node instead of @inrupt/solid-client-authn-browser doesn’t solve the issue.

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [December 27, 2022, 12:11am UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/9 "2022-12-27T00:11:11Z")

</div>

Summary for anyone else finding this thread, the warnings were exactly that, and the issue faced appears to have been due to the build tooling being used (looked like it was building for browser but trying to be run in node.js, where different APIs exist for now)

---

<div class="post-metadata">

**Author:** ![ckemmler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/ckemmler/32/3555_2.png) [@ckemmler](https://forum.solidproject.org/u/ckemmler)\
**Post date:** [December 27, 2022, 11:38am UTC](https://forum.solidproject.org/t/circular-dependency-in-rollup-project/5975/10 "2022-12-27T11:38:59Z")

</div>

To be a little bit more precise, the build tool is [rollup.js](https://rollupjs.org/guide/en/) in this case. And the one thing that had everything collapse in unpredictable ways is the use of a plugin to this build tool, namely [nodeResolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve). Even if everything is reset to target node exclusively (thus _not_ browser), in my case, the code does not work. Essentially it looks like one of this plugin’s side-effects is that it will rename some global dependencies; e.g. `crypto` will be renamed `crypto_1`, and thus any code that refers to `crypto` from the global context will crash.
