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

fix: support esm; fix imports #257

Merged
merged 3 commits into from
Sep 13, 2024
Merged

fix: support esm; fix imports #257

merged 3 commits into from
Sep 13, 2024

Conversation

boopathi
Copy link
Member

@boopathi boopathi commented Sep 13, 2024

Even with new changes it is buggy to use graphql-jit with esm. The problems are - file imports without extensions (e.g. "./execution"), internal package imports ("graphql/utils/Path"), and also directory imports ("graphql/language").

The other set of problems happen with esbuild (part of tsup) not being able to strip away type names from the build. For this it is required to mark the type imports with the type keyword in the import statements.

So, the PR fixes -

  1. use .js extension for imports that are not modules (relative imports and internal file / directory imports from packages)
  2. add type modifier to all type only imports. This was done with the help of typescript 5's new feature verbatimModuleSyntax. We are not preserving this TSConfig option because it requires the package to be of type: module which is not the case for us.
  3. Because we add extension, we configure jest to remove the .js extension so that Jest is able to import the ts file directly.

As a follow up PR, we can validate in CI using tsc or other tool that we don't export types without the type modifier.

@boopathi boopathi added the minor label Sep 13, 2024
@boopathi
Copy link
Member Author

👍

@boopathi boopathi merged commit 2007b7c into main Sep 13, 2024
13 checks passed
@boopathi boopathi deleted the fix-imports-1 branch September 13, 2024 11:02
@boopathi boopathi mentioned this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants