-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
How to use custom plugin in ES module project #6049
Comments
Hi @AndreasHald ! cc @PabloSzx |
Hi again @dotansimha, I saw that #6102 was closed and released, was that supposed to fix this issue, because even after installing @latest I'm still seeing it. |
This issue is due to prevent breaking changes and to be able to do require relative to a specific path, in the ESM support PR the require with "createRequire" was kept for the imports for the cli in config, but it is currently possible to do programmatic usage of graphql-codegen and importing using full ESM all the way oh, and btw, if you have "type": "module" and you have CJS files, simply use the ".cjs" extension and everything will work just fine
|
This is fucking awesome 🚀 |
Describe the bug
Hi, we recently updated our project to use ES modules by adding
"type": "module",
in our package.json file.We use a custom plugin to generate utility functions for our project, this custom plugin is simply a js file we include in our codegen.yml like so:
In order to comply with ES6 I converted our plugin file from
To
However when running the codegen we get the following error
The error appears to occur here
const pluginLoader = config.pluginLoader || makeDefaultLoader(context.cwd);
I'm guessing that the makeDefaultLoader is using require? I can see that it appears to be possible to supply your own loader? is there documentation of this somewhere? I haven't been able to find it.
Are there another suggested approach to this?
The text was updated successfully, but these errors were encountered: