arson icon indicating copy to clipboard operation
arson copied to clipboard

Circular dependency when building with rollup

Open arbesfeld opened this issue 9 years ago • 4 comments

I had to comment out custom.js in order to package this up with rollup, as it seems like this circular dependency is not getting resolved correctly:

https://github.com/benjamn/arson/blob/master/custom.js#L11

Is there a way that we'd be able to reorganize the code to not make this a problem? Happy to submit a PR if we can come up with a solution.

arbesfeld avatar Sep 14 '16 21:09 arbesfeld

This package uses pure CommonJS, which allows circular requires, and it works in Node. I also thought Rollup was only for ES2015 import and export? What's the error?

benjamn avatar Sep 15 '16 00:09 benjamn

I should clarify that we are using https://github.com/rollup/rollup-plugin-commonjs to bundle your library.

Here is the error that I am seeing at runtime:

LogRocket.js:2145 Uncaught TypeError: Cannot read property 'registerType' of undefined(anonymous function) 
@ LogRocket.js:2145createCommonjsModule 
@ LogRocket.js:11(anonymous function) 
@ LogRocket.js:2136(anonymous function) 
@ LogRocket.js:10089
VM424:2 Uncaught TypeError: Cannot read property 'config' of undefined(anonymous function) @ VM424:2

Happy to produce a minimum reproduction if you think it might be helpful.

arbesfeld avatar Sep 15 '16 18:09 arbesfeld

Instead of the circular require, custom.js could export a function registerTypes(arson), which would be a simple way to resolve this. (I'm not running into this, but just throwing in my two cents.)

1j01 avatar Jun 02 '19 00:06 1j01

#16 might help as it does not have any circular dependencies.

KnorpelSenf avatar Nov 21 '22 13:11 KnorpelSenf