-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular import dependencies #466
Comments
I think this message is generated by a circular import dependency problem:
|
Good article on this problem: How to fix nasty circular dependency issues once and for all in JavaScript & TypeScript. The solution offered is called the internal module pattern, and in TypeScript/JavaScript it is implemented as follows:
|
Complicated by generated imports using "src" in the path, which have to go. |
Is there any progress in solving this issue? I had following output by circular dependency error: |
+1 got error when using Parser which is caused circular import in vite rollup
|
Is there any workaround here @BurtHarris? We also hit the same issue that @usstwxy hit, using Vite rollup |
+1 During the building process, rollup.js reported: which consequently result the |
Are there any updates or plans to fix this? Since I am also having issues with simply importing Here is an example on RunKit simply using the default |
Hi, also run into this. Unfortunately, antlr4ts is a dependency of another package I'm using. Has anyone found a workaround to this? |
I have not found a solution to this for the package I am using ( However, in case it may work for others, there is an (older) version on NPM I managed to get running with Vite. https://www.npmjs.com/package/@panda2134/antlr4ts-esm I was then able to set Vite to alias
NOTE: This will not work for If anyone has found a workaround that might work for latest version, that'd be much appreciated. |
Just an update in case anyone else is looking for some form of workaround: The short of it is, I didn't find a good approach for this. I'm tied to Vite+Rollup for my build system. However, as my usage was with the https://www.npmjs.com/package/cashc-web If you're in a dire situation, you can probably just copy that repo and adjust slightly to your needs. |
Doing some experimentation with Rollup.js, I find that it (among many other things) identifies and generates a warning for cycles in
import
dependencies. The code-base has quite a number of these, 14 if I recall. These are not errors, but point up some potential problems due to incomplete initialization of dependencies.Some cycles can be resolved quite trivially, for example 3 cycles can be addressed by moving definition of constants MIN_CHAR_VALUE and MAX_CHAR_VALUE from Lexer.ts to somewhere like misc/Character.ts (which has no imports.) A number of the other cycles are similar, where some simple constants declared in a module with a high dependency count could be move to one with low dependencies to resolve.
But the most ugly cycles are indirect ones involving ATN.ts.
I'm going to stop exploring these right now, but they don't smell good.
The text was updated successfully, but these errors were encountered: