arson
arson copied to clipboard
Circular dependency when building with rollup
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.
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?
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.
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.)
#16 might help as it does not have any circular dependencies.