algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 221 forks source link

'default' is not exported by node_modules/algoliasearch/index.js #1487

Open lukecharle opened 11 months ago

lukecharle commented 11 months ago

I'm using rollup and experiencing the below error when trying to use import algoliasearch from "algoliasearch";

'default' is not exported by node_modules/algoliasearch/index.js

Yet that index.js does export default?

/* eslint-disable functional/immutable-data, import/no-commonjs */
const algoliasearch = require('./dist/algoliasearch.cjs.js');

/**
 * The Common JS build is the default entry point for the Node environment. Keep in
 * in mind, that for the browser environment, we hint the bundler to use the UMD
 * build instead as specified on the key `browser` of our `package.json` file.
 */
module.exports = algoliasearch;

/**
 * In addition, we also set explicitly the default export below making
 * this Common JS module in compliance with es6 modules specification.
 */
module.exports.default = algoliasearch;

I've tried using @rollup/plugin-commonjs as many others have said but this doesn't resolve anything.

snolan-ethika commented 1 month ago

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

SchulteMarkus commented 2 days ago

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

Can you please provide details?

snolan-ethika commented 2 days ago

I was able to get this working with rollup using the https://rollupjs.org/tutorial/#using-config-files, not sure what your project is using (e.g. typescript, or javascript), but I was able to bundle it and run a simple algolia "getObject" method.

Can you please provide details?

Sure, try changing your "output" format, play around with that and see if that helps.