Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: import serializeJs using default import instead of a namespace import #1485

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

DawidKopys
Copy link
Contributor

It fixess serializeJs is not a function error which appeared after upgrading @vue/apollo-ssr from 4.0.0-alpha.18 to 4.0.0-alpha.5 in a Nuxt 3 project.

Full error message:

[nuxt] [request error] [unhandled] [500] serializeJs is not a function
  at serializeStates (./.output/server/chunks/app/server.mjs:35:11)
  at ./.output/server/chunks/app/server.mjs:661:32
  at ./.output/server/chunks/app/server.mjs:107:44
  at fn (./.output/server/chunks/app/server.mjs:179:44)
  at Object.callAsync (./.output/server/node_modules/unctx/dist/index.mjs:68:55)
  at ./.output/server/chunks/app/server.mjs:181:56
  at Object.runWithContext (./.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3855:18)
  at callWithNuxt (./.output/server/chunks/app/server.mjs:181:24)
  at Object.runWithContext (./.output/server/chunks/app/server.mjs:76:29)
  at contextCaller (./.output/server/chunks/app/server.mjs:107:23)

Reproduction of the issue: https://github.com/DawidKopys/apollo-ssr-serializejs-repro

First - to make ES module work - I had to use default import from serialize-javascript instead of the namespace import.
Then - to make the CJS module work and the tests to pass again - I turned on the esModuleInterop option in tsconfig.ts, so that it works with the default import.

More info on the esModuleInterop ts option

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants