Skip to content

Resolve location of @vue/apollo-composable using node module resolution algo#522

Closed
zenflow wants to merge 1 commit intonuxt-modules:v5from
zenflow:patch-1
Closed

Resolve location of @vue/apollo-composable using node module resolution algo#522
zenflow wants to merge 1 commit intonuxt-modules:v5from
zenflow:patch-1

Conversation

@zenflow
Copy link

@zenflow zenflow commented Jul 1, 2023

Fixes #519

See #519 (comment) for analysis of the problem and suggested solution (which this PR implements)

Tested this solution using patch-package and the module (@vue/apollo-composables main module) resolves correctly when it's at either location (./node_modules/@vue/apollo-composable or ./node_modules/@nuxtjs/apollo/node_modules/@vue/apollo-composable)

@netlify
Copy link

netlify bot commented Jul 1, 2023

Deploy Preview for apollo-module canceled.

Name Link
🔨 Latest commit 144e395
🔍 Latest deploy log https://app.netlify.com/sites/apollo-module/deploys/64a0a540aa71eb0008c4d8ad

@zenflow zenflow closed this Jul 1, 2023
@zenflow
Copy link
Author

zenflow commented Jul 1, 2023

Closing as I was a bit premature opening this.

I get the following error when I try to actually visit a page that uses an apollo composable (using vite dev server):

[7:01:55 PM] Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\matt_\Documents\dev\lucid-chat\node_modules\@nuxtjs\apollo\node_modules\@apollo\client\core\index.js from C:\Use
rs\matt_\Documents\dev\lucid-chat\node_modules\@nuxtjs\apollo\node_modules\@vue\apollo-composable\dist\index.js not supported.
Instead change the require of C:\Users\matt_\Documents\dev\lucid-chat\node_modules\@nuxtjs\apollo\node_modules\@apollo\client\core\index.js in C:\Users\matt_\Documents\dev\lucid-chat
\node_modules\@nuxtjs\apollo\node_modules\@vue\apollo-composable\dist\index.js to a dynamic import() which is available in all CommonJS modules.
    at C:\Users\matt_\Documents\dev\lucid-chat\node_modules\@nuxtjs\apollo\node_modules\@vue\apollo-composable\dist\index.js:259:30
    at ViteNodeRunner.directRequest (file:///C:/Users/matt_/Documents/dev/lucid-chat/node_modules/vite-node/dist/client.mjs:326:11)
    [...]

The first line of the stack trace points to this:

// node_modules/@nuxtjs/apollo/node_modules/@vue/apollo-composable/dist/index.js
// ...
var import_core = __toModule(require("@apollo/client/core/index.js")); // <-- line 259
// ...

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.

Can't use apollo composables when @vue/apollo-composable isn't directly inside node_modules

1 participant