Issue with circular imports
stephenh opened this issue · 0 comments
We have a codebase that follows this pattern:
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
> circular-deps-4@1.0.0 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