MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

Home Page:https://typegraphql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when compiling with ESbuild (ESModule)

cjnoname opened this issue · comments

Describe the Bug
Error when compiling with ESbuild (ESModule)

Error details:
"Expected name to be a non-empty string."

We encountered an error while attempting to build the project with ESbuild Typescript (ESModule).

Simply add a basic resolver to the buildSchema function and you'll observe the error. You can reproduce it by following the links below. It's a straightforward setup.

https://eisenbergeffect.medium.com/an-esbuild-setup-for-typescript-3b24852479fe
https://github.com/thomaschaaf/esbuild-plugin-tsc#readme

@carlocorradini can you take a look?

I've never used ESBuild... I'm reading this:

IMG_20240328_083211.jpg

Have you tried with force: true ?

I've never used ESBuild... I'm reading this:

IMG_20240328_083211.jpg

Have you tried with force: true ?

Hey mate, I tried but doesn't work.

@cjnoname Any update?

Hey man,

esbuild-plugin-tsc is something that I used at the beginning, but it doesn't work.

We also tried Rollup, but still had no luck and encountered a different error with graphql-yoga.

We have given up because it seems like this package supports TypeScript ESM but doesn't support the compiled TypeScript ESM.

I hope that you guys can take a few minutes to create a TypeScript ESM project with this package and try to compile it with both esbuild and Rollup. Then you'll see the issues.

ESM is the future of NodeJS, and we will wait to move to ESM until your package fully supports it. It would be great if you could add an example of ESM setup that is compilable.

I think this is not the package fault. It's the fault of 3rd party compilers that have issues with decorator metadata.
It would end up in the same way if you would use cjs and a 3rd party bundler.

I think this is not the package fault. It's the fault of 3rd party compilers that have issues with decorator metadata. It would end up in the same way if you would use cjs and a 3rd party bundler.

I don't agree, bro. We've been using webpack for 7 years with CJS without any issues, same as Rollup. If the package uses the old CJS way to import the package or employs the ES5 method of exporting a module, then it won't compile correctly on ESM.

ESBuild might not support decorators properly, but Rollup does support them in a great way, yet it also gets stuck on the graphql-yoga package.

Additionally, I tried both and found that the typegraphql package seems to be the only one that could not be compiled across all the packages I am using. Both compilers throw errors and stop at this point.