lys-lang / node-ebnf

Create AST PEG Parsers from formal grammars in JavaScript
https://menduz.com/ebnf-highlighter/
MIT License
104 stars 9 forks source link

Circular dependency problem #6

Closed ycmjason closed 6 years ago

ycmjason commented 6 years ago

Hi!

Thank you so much for making this. This package is amazing and is the best out there from what I have seen.

I am making a library with this package using rollup. But rollup seems to struggle with the circular dependencies that this module has.

(!) Circular dependency: node_modules/ebnf/dist/index.js -> node_modules/ebnf/dist/Grammars/index.js -> node_modules/ebnf/dist/Grammars/BNF.js -> node_modules/ebnf/dist/index.js
(!) Circular dependency: node_modules/ebnf/dist/index.js -> node_modules/ebnf/dist/Grammars/index.js -> node_modules/ebnf/dist/Grammars/BNF.js -> node_modules/ebnf/dist/index.js -> node_modules/ebnf/dist/index.js
(!) Circular dependency: node_modules/ebnf/dist/index.js -> node_modules/ebnf/dist/Grammars/index.js -> node_modules/ebnf/dist/Grammars/W3CEBNF.js -> node_modules/ebnf/dist/index.js
(!) Circular dependency: node_modules/ebnf/dist/index.js -> node_modules/ebnf/dist/Grammars/index.js -> node_modules/ebnf/dist/Grammars/Custom.js -> node_modules/ebnf/dist/index.js

Briefly inspecting, looks like to me the problem comes from the index.js files which act as the entry of the modules (Grammers and ebnf).

By removing index.js and importing corresponding files instead, this circular dependency issue should be solved.

This might also help rollup to shake the tree more accurately producing smaller module.

Happy to submit a PR if this is not something you really insist on. (index.js as entry of module)

Congratulate again on your great work! 💯

menduz commented 6 years ago

Merged