contra/graphql-helix

Usage in ESM project broken in v1.8.0

avaly opened this issue · 5 comments

avaly commented

Starting with version 1.8.0 using this package in an ESM project is broken. The most likely commit which broke it is #47.

Steps to reproduce

package.json:

{
  "name": "graphql-helix-bugs",
  "type": "module",
  "dependencies": {
    "graphql": "15.6.0",
    "graphql-helix": "1.8.0"
  }
}

index.js:

import { processRequest } from 'graphql-helix';

console.log(processRequest);

Actual result

$ node index.js 
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /tmp/graphql-helix-bugs/node_modules/graphql-helix/package.json imported from /tmp/graphql-helix-bugs/index.js
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:479:7)
    at packageResolve (internal/modules/esm/resolve.js:644:14)
    at moduleResolve (internal/modules/esm/resolve.js:696:18)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
    at Loader.resolve (internal/modules/esm/loader.js:86:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:230:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:56:40)
    at link (internal/modules/esm/module_job.js:55:36) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Expected result

Downgrading to v1.7.0:

$ node index.js 
[AsyncFunction: processRequest]

Screenshot from 2021-09-24 12-43-59

the "exports" literally doesn't have any "import" field for ESM

Screenshot from 2021-09-24 12-43-59

the "exports" literally doesn't have any "import" field for ESM

Oh oops! I somehow forget to include some ESM changes from #44

Working on a fix. Thank you

Fixed by @n1ru4l in #65
Fix is available as graphql-helix@1.8.3.