Skip to content

Import differences with different bundlers #258

@lazka

Description

@lazka

I've initially reported it here: rolldown/rolldown#6438 but they said it's recommended to be fixed in typesense-instantsearch-adapter instead.

When importing typesense-instantsearch-adapter you get different results with rollup vs esbuild vs rolldown when bundling.

  • rolldown: { default: [Function: TypesenseInstantsearchAdapter] }
  • rollup: [Function: TypesenseInstantsearchAdapter]

publint has a warning for this here: https://publint.dev/[email protected]

This file sets both exports.__esModule = true and exports.default. This pattern breaks default imports when importing from an ESM-interpreted file in some bundlers. Consider using ESM syntax instead of CommonJS with __esModule or avoid the default export. https://publint.dev/rules#cjs_with_esmodule_default_export

Unfortunately, I don't know enough about this to be able to fix it. Maybe you have an idea.

I've currently worked it around in my code using:

import TypesenseInstantSearchAdapter from 'typesense-instantsearch-adapter';
let TypesenseInstantSearchAdapterClass =
    TypesenseInstantSearchAdapter.default ?? TypesenseInstantSearchAdapter;

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