Skip to content
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

Issue with circular imports #63

Open
stephenh opened this issue Dec 30, 2021 · 0 comments
Open

Issue with circular imports #63

stephenh opened this issue Dec 30, 2021 · 0 comments

Comments

@stephenh
Copy link

We have a codebase that follows this pattern:

https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de

For avoiding circular import issues with classes. Specifically class Foo extends Bar when Bar is undefined will cause a runtime error. Unfortunately, in large codebases it can be surprisingly easy to trip this up, hence following the pattern in that article of an internal.ts file that controls a defined import order.

However, esbuild-jest seems to not currently support the right import order / semantics.

I have a reproduction with the ~5 tiny files from the above blog post, converted to TS, and using esbuild-jest here:

https://github.com/stephenh/esbuild-register-circular

If you clone the repo, run npm i and npm test, you should see:

$ npm test

> [email protected] test
> jest

 FAIL  src/AbstractNode.test.ts
  ● Test suite failed to run

    TypeError: Class extends value undefined is not a constructor or null



      at Object.<anonymous> (src/Node.ts:28:36)
      at Object.<anonymous> (src/internal.ts:21:27)

Where as running with ts-jest will work (I don't technically have ts-jest setup in the repro project, but can add it if you'd like).

FWIW I'm having the same issue with esbuild-register, see: egoist/esbuild-register#62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant