linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
562 stars 142 forks source link

error in some compilation contexts (due to circular dependencies?) #580

Open eroux opened 1 year ago

eroux commented 1 year ago

I'm experiencing a bug in an edge case of compilation. The issue can be boiled down the to following example:

git clone https://github.com/eroux/mwe-bug2.git
cd mwe-bug2
yarn build
yarn link
cd ..
git clone https://github.com/eroux/mwe-bug3.git
yarn link mwe-bug2
yarn start

the compilation works but then the app crashes in the browser with a cryptic error message

Uncaught TypeError: Super expression must either be null or a function

This only happens when using yarn link. Note also that changing

export const defaultGraphNode = new rdf.NamedNode(rdf.Store.defaultGraphURI)

into

export const defaultGraphNode = rdf.sym(rdf.Store.defaultGraphURI)

makes everything work for some reason.

According to this so answer, this could be due to circular dependencies. I checked rdflib with dpdm and it reports 97 circular dependencies in rdflib.js.

In my experience, fixing this is not particularly straightforward, but if a PR can be accepted, I might give it a try