You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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).
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
whenBar
isundefined
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 aninternal.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
andnpm test
, you should see: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#62The text was updated successfully, but these errors were encountered: