Skip to content

@vue/apollo-ssr doesn't work in SSR mode #1524

@lermontex

Description

@lermontex

Describe the bug

I'm using Vue 3 + Vite 4/5 + NodeJS 20

When trying to use the @vue/apollo-ssr package in SSR mode, I get the following error:

node-1   | import { exportStates } from "@vue/apollo-ssr";
node-1   |          ^^^^^^^^^^^^
node-1   | SyntaxError: Named export 'exportStates' not found. The requested module '@vue/apollo-ssr' is a CommonJS module, which may not support all module.exports as named exports.
node-1   | CommonJS modules can always be imported via the default export, for example using:
node-1   |
node-1   | import pkg from '@vue/apollo-ssr';
node-1   | const { exportStates } = pkg;
node-1   |
node-1   |     at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
node-1   |     at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
node-1   |     at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
node-1   |     at async file:///srv/app/server.js:87:9

I tried applying the patch and adding type: 'module' to the package.json file of the @vue/apollo-ssr package - it works. It seems the error is due to an incorrect configuration of the package.json file

To Reproduce
Use @vue/apollo-ssr + Vite in SSR mode

Versions
vue: 3.3.0
@apollo/client: 3.8.* / 3.9.0-beta.1
@vue/apollo-composable: 4.0.0-beta.12
@vue/apollo-ssr: 4.0.0-beta.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions