Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn build/start import @apollo/client/core/core.cjs.js? #9048

Open
productdevbook opened this issue Nov 12, 2021 · 9 comments
Open

yarn build/start import @apollo/client/core/core.cjs.js? #9048

productdevbook opened this issue Nov 12, 2021 · 9 comments
Labels
🔍 investigate Investigate further

Comments

@productdevbook
Copy link

productdevbook commented Nov 12, 2021

Environment


  • Operating System: Darwin
  • Node Version: v16.13.0
  • Nuxt Version: 3.0.0-27276275.abfbd2f
  • Package Manager: [email protected]
  • Bundler: Vite
  • User Config: build
  • Runtime Modules: -
  • Build Modules: -

Describe the bug

yarn build
yarn start

nuxt docs check -> https://v3.nuxtjs.org/concepts/esm

Reproduction

https://github.com/productdevbook/productdevbook.com

Additional context

No response

Logs

➜  productdevbook.com git:(main) yarn start
yarn run v1.22.15
$ node .output/server/index.mjs
Listening on http://localhost:3000
Directory import '/Users/productdevbook/Documents/GitHub/productdevbook.com/.output/server/node_modules/@apollo/client/core' is not supported resolving ES modules imported from /Users/productdevbook/Documents/GitHub/productdevbook.com/.output/server/chunks/app/server.mjs
Did you mean to import @apollo/client/core/core.cjs.js?
  at new NodeError (node:internal/errors:371:5)  
  at finalizeResolution (node:internal/modules/esm/resolve:412:17)  
  at moduleResolve (node:internal/modules/esm/resolve:932:10)  
  at defaultResolve (node:internal/modules/esm/resolve:1044:11)  
  at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)  
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)  
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)  
  at link (node:internal/modules/esm/module_job:75:36)

nuxt/nuxt#12740

@productdevbook productdevbook changed the title yarn build/start import @apollo/client/core/core.cjs.js? #1846 yarn build/start import @apollo/client/core/core.cjs.js? Nov 12, 2021
@productdevbook
Copy link
Author

productdevbook commented Nov 19, 2021

v3.5.x some problem

@vrana055
Copy link

Please remove .js extension if you are using core.cjs.js
Example
import ApolloClientCore from '@apollo/client/core/core.cjs.js'; => import ApolloClientCore from '@apollo/client/core/core.cjs';

https://github.com/apollographql/apollo-client/releases/tag/v3.5.4
Since Apollo Client v3.5.0, CommonJS bundles provided by @apollo/client use a .cjs file extension rather than .cjs.js, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whose resolver.sourceExts configuration does not include the cjs extension by default.

@productdevbook
Copy link
Author

Please remove .js extension if you are using core.cjs.js Example import ApolloClientCore from '@apollo/client/core/core.cjs.js'; => import ApolloClientCore from '@apollo/client/core/core.cjs';

https://github.com/apollographql/apollo-client/releases/tag/v3.5.4 Since Apollo Client v3.5.0, CommonJS bundles provided by @apollo/client use a .cjs file extension rather than .cjs.js, so Node.js won't interpret them as ECMAScript modules. While this change should be an implementation detail, it may cause problems for the Metro bundler used by React Native, whose resolver.sourceExts configuration does not include the cjs extension by default.

dont se .js -> https://github.com/productdevbook/productdevbook.com/blob/main/plugins/vue-apollo.ts check code please

@vrana055
Copy link

@productdevbook maybe it will work for you.

// eslint-disable-next-line import/extensions
import ApolloClientCore from '@apollo/client/core/core.cjs';

const {
  ApolloClient,
  InMemoryCache,
  createHttpLink,
} = ApolloClientCore;

@tobiasdiez
Copy link

@vrana055 This workaround works, but it would be nice if there would be a solution that doesn't need this. For example, other libraries (in my case vue apollo composable) import directly from @apollo/client/core which leads to problems.

@productdevbook
Copy link
Author

@vrana055
CleanShot 2021-11-28 at 10 33 04@2x

@xxSkyy
Copy link

xxSkyy commented Dec 12, 2021

Those workaround patches seems to work
https://github.com/JabRef/JabRefOnline/tree/afc92ac85f317fb81d32f07be00944209eebfdae/patches
can it be fixed on dependency site?

@pipinet
Copy link

pipinet commented Dec 25, 2021

3.5.6 same problem, is there any progress on this issue?

@mayconline
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 investigate Investigate further
Projects
None yet
7 participants