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

Support for ES Modules #2891

Open
gilgardosh opened this issue Oct 3, 2021 · 0 comments
Open

Support for ES Modules #2891

gilgardosh opened this issue Oct 3, 2021 · 0 comments

Comments

@gilgardosh
Copy link
Collaborator

gilgardosh commented Oct 3, 2021

Describe the bug
Mesh errors on build once package.json contains "type": "module

Failed to generate schema: require() of ES Module .../graphql-mesh/examples/odata-msgraph-programmatic/.mesh/sources/Microsoft Graph/metadata.json.js from .../graphql-mesh/examples/odata-msgraph-programmatic/node_modules/@graphql-mesh/cli/bin.js not supported.
metadata.json.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename metadata.json.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in .../graphql-mesh/examples/odata-msgraph-programmatic/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

To Reproduce
Steps to reproduce the behavior:

  1. Take an example from the repo, such as odata-msgraph-programmatic.
  2. Add "type": "module" to the package.json
  3. run mesh build
  4. error thrown

Expected behavior
Build with no issues :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant