7.6.4 ESM build broken
See original GitHub issueBug report
- [✔] I have checked other issues to make sure this is not a duplicate.
Describe the bug
Generated ESM index.js
contains the following (which is identical to typings/index.d.ts
):
export { IRule } from './types';
export { allow, and, chain, deny, inputRule, not, or, race, rule } from './constructors';
export { shield } from './shield';
with types.js
containing:
export {};
Problems here are:
- Empty
types.js
module - noIRule
export. - Reference to
'./types'
,'./constructors'
, and'./shield'
- all are missing.js
extensions that are required due to relative import rules. IRule
is TypeScript-specific and should not be emitted in the JavaScript file to begin with…
To Reproduce
-
"type": "module"
inpackage.json
file -
Import
{ IRules }
from"graphql-shield"
. (Or pick your favorite export) -
This is my GraphQL Schema.
Not required to reproduce the error
- This is the invoked query
Not required to reproduce the error.
- I use these permissions
Not required to reproduce the error.
- This is the error I see
node:internal/errors:478
ErrorCaptureStackTrace(err);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../node_modules/graphql-shield/esm/constructors' imported from .../node_modules/graphql-shield/esm/index.js
at new NodeError (node:internal/errors:387:5)
at finalizeResolution (node:internal/modules/esm/resolve:330:11)
at moduleResolve (node:internal/modules/esm/resolve:907:10)
at defaultResolve (node:internal/modules/esm/resolve:1115:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}```
If I add `--es-module-specifier-resolution=node` to the command line, I get:
```bash
(node:7897) ExperimentalWarning: The Node.js specifier resolution flag is experimental. It could change or be removed at any time.
(Use `node --trace-warnings ...` to show where the warning was created)
file://.../node_modules/graphql-shield/esm/index.js:3
export { IRule } from './types';
^^^^^
SyntaxError: The requested module './types' does not provide an export named 'IRule'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
When I keep the node resolution flag but comment out the first line of esm/index.js
and run the application, it starts up fine. Without the flag, Node complains about the next module without a .js
extension…
Expected behavior
The build process should produce ESM compliant code.
Actual behaviour
See the description above.
Issue Analytics
- State:
- Created 10 months ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
D3 packages are incompatible with Node projects that use ...
When CommonJS is imported from ESM, Node treats module.exports as the ... UMD build is still generated for legacy uses (script tags etc)...
Read more >webpack/webpack - Gitter
I'm using module federation and promised based dynamic remotes (https://webpack.js.org/concepts/module-federation/#promise-based-dynamic-remotes). Everything is ...
Read more >Error importing Framer Motion v5 in React (with create-react ...
I downgraded the Framer motion version to "4.1.17" by changing the package.json file and running npm install and it works for me.
Read more >7 Working with file system paths and file URLs on Node.js
In this chapter, we learn how to work with file system paths and file URLs on Node.js. 7.1 Path-related functionality on Node.js #....
Read more >Upgrading Ember - Issues with Tests - Questions
But for some reason the update and switch from ember-cli-mocha to ember-mocha broke something. The tests run, then launch the browser like ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the fix was released in 7.6.5 please feel free to reopen if the issue still exists
I was having the same issue, downgrade it to
v7.6.2
works for me it’s the same issue logged in here