You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The issue provides a reproduction available on Github
2. A failing test has been provided
3. A local solution has been provided
4. A pull request is pending review
Describe the bug
The hello-world-esm example doesn't start.
To Reproduce Steps to reproduce the behavior:
Copy the hello-world-esm example folder under a clean folder in local desktop
Run npm install in terminal, opened on the ./hello-world-esm folder
Run npm run prestart in terminal -> schema generated successfully
Run 'npm start` in terminal -> error:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /<FOLDER>/hello-world-esm/index.ts
Expected behavior
The example should start without any issues
Environment:
OS: MacOS Ventura 13.1
@graphql-mesh/...: (as defined in the example)
"@graphql-mesh/cli": "0.82.24",
"@graphql-mesh/json-schema": "0.37.16",
"@graphql-mesh/plugin-mock": "0.1.14",
"graphql": "16.6.0"
NodeJS: v18.13.0
Additional context
Modifying the tsconfig.json file to add ESM support to ts-node solves the error but exposes another issue
Issue workflow progress
Progress of the issue based on the
Contributor Workflow
1. The issue provides a reproduction available on
Github
2. A failing test has been provided
3. A local solution has been provided
4. A pull request is pending review
Describe the bug
The
hello-world-esm
example doesn't start.To Reproduce Steps to reproduce the behavior:
hello-world-esm
example folder under a clean folder in local desktopnpm install
in terminal, opened on the ./hello-world-esm foldernpm run prestart
in terminal -> schema generated successfullyExpected behavior
The example should start without any issues
Environment:
@graphql-mesh/...
: (as defined in the example)"@graphql-mesh/cli": "0.82.24",
"@graphql-mesh/json-schema": "0.37.16",
"@graphql-mesh/plugin-mock": "0.1.14",
"graphql": "16.6.0"
Additional context
Modifying the tsconfig.json file to add ESM support to
ts-node
solves the error but exposes another issuemodified tsconfig.json:
Now running
npm start
reports another error:The .mesh folder doesn't have index.mjs, but index.js
changing the example
index.ts
to import the js instead of mjs cause this error:I then changed the
tsconfig.json
file to have ESMmodule
(instead ofcommon
), as well as thetarget
:The mesh builds now outputs ESM instead of CJS
The example program runs and outputs:
The graphql mesh source code - https://github.com/Urigo/graphql-mesh/blob/8429bf23457aea19969dab246fc4f0517644bf12/packages/cli/src/commands/ts-artifacts.ts#L502 - creates an esmjob('.js') for "type": "module" (i.e. ism) of package.json.
therefore the
mjs
will never be generated and the reference to it inindex.ts
will always fail.I can create a PR to fix this, but would like to first know if the owners agree with this issue.
The text was updated successfully, but these errors were encountered: