Closed macrozone closed 2 months ago
looks like a "left-pad" situation. https://github.com/josephg/resolvable is a 17 liner and has not been updated in 3 years.
come on, just don't use dependencies like that
I use the following patch-package
patch
diff --git a/node_modules/@apollo/server/dist/esm/ApolloServer.js b/node_modules/@apollo/server/dist/esm/ApolloServer.js
index b716f63..25370aa 100644
--- a/node_modules/@apollo/server/dist/esm/ApolloServer.js
+++ b/node_modules/@apollo/server/dist/esm/ApolloServer.js
@@ -1,7 +1,7 @@
import { isNodeLike } from '@apollo/utils.isnodelike';
import { InMemoryLRUCache, PrefixingKeyValueCache, } from '@apollo/utils.keyvaluecache';
import { makeExecutableSchema } from '@graphql-tools/schema';
-import resolvable from '@josephg/resolvable';
+import resolvable from '@josephg/resolvable/index.js';
import { GraphQLError, assertValidSchema, print, printSchema, } from 'graphql';
import loglevel from 'loglevel';
import Negotiator from 'negotiator';
I use the following
patch-package
patchdiff --git a/node_modules/@apollo/server/dist/esm/ApolloServer.js b/node_modules/@apollo/server/dist/esm/ApolloServer.js index b716f63..25370aa 100644 --- a/node_modules/@apollo/server/dist/esm/ApolloServer.js +++ b/node_modules/@apollo/server/dist/esm/ApolloServer.js @@ -1,7 +1,7 @@ import { isNodeLike } from '@apollo/utils.isnodelike'; import { InMemoryLRUCache, PrefixingKeyValueCache, } from '@apollo/utils.keyvaluecache'; import { makeExecutableSchema } from '@graphql-tools/schema'; -import resolvable from '@josephg/resolvable'; +import resolvable from '@josephg/resolvable/index.js'; import { GraphQLError, assertValidSchema, print, printSchema, } from 'graphql'; import loglevel from 'loglevel'; import Negotiator from 'negotiator';
thank you, this indeed fixes the issue.
its weird that this happens though, shouldn't node respect the main field as fallback?
fails on node 20 and above, works on 18 i didn't test any other versions
I haven't spent much time trying to understand the issue, the JS file appears to be ESM compatible. Maybe the package.json
from the resolvable
dependency needs a module
field? In any case, I opened a PR to inline the dependency which should resolve it. Could someone with a reproduction handy please test it out? There are builds on the PR you can install via the Codesandbox CI comment. Thanks for reporting!
@trevor-scheer I can confirm that your MR works
Fixed via #7900, should be available in @apollo/server@4.10.5
momentarily. Thanks for reporting!
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.
Issue Description
when switching to ESM, apollo server no longer starts. you get this error:
Link to Reproduction
not yet
Reproduction Steps
"type": "module"
in package.json