Skip to content

Conversation

@trusktr
Copy link
Contributor

@trusktr trusktr commented Jun 22, 2022

Importing in Node.js directly, or with tools that strictly follow Node ESM spec (like Webpack), will cause an error.

Note that the import type lines don't require this, only the import lines that end up in JS.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 22, 2022

WIthout this, bundling an app with Webpack 5 produce such errors:

ERROR in ./node_modules/@merged/solid-apollo/dist/es/createLazyQuery.js 1:0-51
Module not found: Error: Can't resolve '@apollo/client/core' in '/home/trusktr/app/node_modules/@merged/solid-apollo/dist/es'
Did you mean 'index.js'?
BREAKING CHANGE: The request '@apollo/client/core' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@merged/solid-apollo/dist/es/index.js 5:0-55 5:0-55
 @ ./src/App.tsx 14:0-54 19:27-41
 @ ./src/main.ts 2:0-28 7:7-10

ERROR in ./node_modules/@merged/solid-apollo/dist/es/createMutation.js 1:0-51
Module not found: Error: Can't resolve '@apollo/client/core' in '/home/trusktr/app/node_modules/@merged/solid-apollo/dist/es'
Did you mean 'index.js'?
BREAKING CHANGE: The request '@apollo/client/core' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./node_modules/@merged/solid-apollo/dist/es/index.js 3:0-53 3:0-53
 @ ./src/App.tsx 14:0-54 19:27-41
 @ ./src/main.ts 2:0-28 7:7-10

ERROR in ./node_modules/@merged/solid-apollo/dist/es/index.js 6:0-71
Module not found: Error: Can't resolve '@apollo/client/core' in '/home/trusktr/app/node_modules/@merged/solid-apollo/dist/es'
Did you mean 'index.js'?
BREAKING CHANGE: The request '@apollo/client/core' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
 @ ./src/App.tsx 14:0-54 19:27-41
 @ ./src/main.ts 2:0-28 7:7-10

@ruohki
Copy link

ruohki commented Jun 26, 2023

Another case where patch-packet saves the day, since the pr will likely never get merged :(

@EthanDawes
Copy link

Thank you @ruohki for introducing me to patch-package! For anyone implementing this, here's the patch file I used:

patches/@merged+solid-apollo+1.7.1.patch

diff --git a/node_modules/@merged/solid-apollo/dist/es/createLazyQuery.js b/node_modules/@merged/solid-apollo/dist/es/createLazyQuery.js
index 3434b51..055f573 100644
--- a/node_modules/@merged/solid-apollo/dist/es/createLazyQuery.js
+++ b/node_modules/@merged/solid-apollo/dist/es/createLazyQuery.js
@@ -1,4 +1,4 @@
-import { mergeOptions } from '@apollo/client/core';
+import { mergeOptions } from '@apollo/client/core/index.js';
 import { createSignal, createResource, onCleanup, untrack } from 'solid-js';
 import { createStore, reconcile } from 'solid-js/store';
 import { useApollo } from './ApolloProvider.js';
diff --git a/node_modules/@merged/solid-apollo/dist/es/createMutation.js b/node_modules/@merged/solid-apollo/dist/es/createMutation.js
index 243e40e..ef9c41c 100644
--- a/node_modules/@merged/solid-apollo/dist/es/createMutation.js
+++ b/node_modules/@merged/solid-apollo/dist/es/createMutation.js
@@ -1,4 +1,4 @@
-import { mergeOptions } from '@apollo/client/core';
+import { mergeOptions } from '@apollo/client/core/index.js';
 import { createSignal, createResource, untrack } from 'solid-js';
 import { useApollo } from './ApolloProvider.js';
 
diff --git a/node_modules/@merged/solid-apollo/dist/es/index.js b/node_modules/@merged/solid-apollo/dist/es/index.js
index f2203d8..89e39ac 100644
--- a/node_modules/@merged/solid-apollo/dist/es/index.js
+++ b/node_modules/@merged/solid-apollo/dist/es/index.js
@@ -3,4 +3,4 @@ export { createQuery } from './createQuery.js';
 export { createMutation } from './createMutation.js';
 export { createSubscription } from './createSubscription.js';
 export { createLazyQuery } from './createLazyQuery.js';
-export { ApolloClient, InMemoryCache, gql } from '@apollo/client/core';
+export { ApolloClient, InMemoryCache, gql } from '@apollo/client/core/index.js';

For posterity, seems like if apollographql/apollo-client#8218 is resolved, so will this.

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

Successfully merging this pull request may close these issues.

3 participants