#SSR and Algolia (CommonJS)

1 messages · Page 1 of 1 (latest)

nimble idol
#

Hello!

I've been hitting a bunch of issues with SSR and external packages, mostly overcame them, but hit a bit of a snag when trying to use the Algolia recommend package.

I have a simple app set up like so:

import {
  frequentlyBoughtTogether,
  relatedProducts,
} from "@algolia/recommend-js"
import recommend from "@algolia/recommend"
// ...

When bundling for SSR and starting the server I get the following error in the terminal:

import { frequentlyBoughtTogether, relatedProducts } from '@algolia/recommend-js';
^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'frequentlyBoughtTogether' not found. The requested module '@algolia/recommend-js' is a CommonJS module, which may not support all module.exports as named exports.

Has anyone come against this kind of issue before?

Thanks 🙂

polar anvil
#

Question, why should the Algolia code go into SSR? Isnt this a client-only feature?