Chevrotain / chevrotain

Parser Building Toolkit for JavaScript
https://chevrotain.io
Apache License 2.0
2.44k stars 199 forks source link

Circular dependency warning when included in rollup build #1996

Closed dhowe closed 5 months ago

dhowe commented 8 months ago

I'm trying to use rollup(v4.1.4) to build a js project for various environments and get the following warnings whenever I include chevrotain (@11.0.3):

(!) Circular dependencies
node_modules/chevrotain/lib/src/scan/lexer_public.js -> node_modules/chevrotain/lib/src/scan/lexer.js -> node_modules/chevrotain/lib/src/scan/lexer_public.js
node_modules/chevrotain/lib/src/scan/lexer.js -> node_modules/chevrotain/lib/src/scan/reg_exp.js -> node_modules/chevrotain/lib/src/scan/lexer.js
node_modules/chevrotain/lib/src/parse/parser/parser.js -> node_modules/chevrotain/lib/src/parse/grammar/gast/gast_resolver_public.js -> node_modules/chevrotain/lib/src/parse/grammar/resolver.js -> node_modules/chevrotain/lib/src/parse/parser/parser.js
...and 11 more
created dist/index.js
dhowe commented 8 months ago

This doesn't seem to cause any problems, besides being annoying. But here's a workaround for anyone using rollup (in rollup.config.js):

const onwarn = warning => {
  // Silence circular dependency warning for chevrotain
  if (warning.code === 'CIRCULAR_DEPENDENCY'
    && warning.ids.every(id => id.includes('chevrotain'))) {
    return;
  }
  console.warn(`(!) ${warning.message}`);
}

export default [{
  onwarn,
  ...
bd82 commented 5 months ago

Thanks for the workaround @dhowe

As this will require too much effort to resolve relative to the trivial impact I will be closing this issue.