-
Notifications
You must be signed in to change notification settings - Fork 114
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
Support generating ESM output #387
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of regression. *.js
import should be emitted only for esm.
4366ba7
to
ef99728
Compare
This is how I'd originally written the change, but I didn't like needing to pass |
Setting `emitESM=true` in the generator's configuration will switch from using `require` to `import` calls in the generated code. I haven't been successful in actually using the ESM output. Bi-directional relationships between models lead to circular dependencies in `*WhereInput` and `*ListRelationFilter` and cause the following error at start-up: > ReferenceError: Cannot access 'FooWhereInput' before initialization > at file:///app/node_modules/@generated/type-graphql/resolvers/inputs/FooListRelationFilter.js:10:31 Regardless of ESM setting, create a package.json if generating into node_modules. This makes sure that the generated code doesn't inherit a parent package's `type`.
i second this PR |
So esm support not happening anytime soon right? |
+1 Need this) |
re: #372
Setting
emitESM=true
in the generator's configuration will switch from usingrequire
toimport
calls in the generated code.I haven't been successful in actually using the ESM output. Bi-directional relationships between models lead to circular dependencies in
*WhereInput
and*ListRelationFilter
and cause the following error at start-up:Even without setting
emitESM=true
, changing imports to use filenames with extension makes Typescript withmoduleResolution=node16
stop complaining about missing types.