Skip to content

fix(build): correct cjs interop#6915

Merged
Haroenv merged 4 commits intomasterfrom
fix/build-cjs
Mar 5, 2026
Merged

fix(build): correct cjs interop#6915
Haroenv merged 4 commits intomasterfrom
fix/build-cjs

Conversation

@Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Mar 4, 2026

fixes #6914

In #6886 we upgraded from babel to swc through rollup for cjs builds, however the build output was slightly different, notably from:

new InstantSearch.default()

to

new InstantSearch()

for an import from instantsearch.js in react-instantsearch-core.

This PR fixes that by ensuring interop is correctly set for swc commonjs modules.

example diff we fix: https://npmdiff.dev/react-instantsearch-core/7.25.0/7.26.0/package/dist/cjs/lib/useInstantSearchApi.js/

fixes #6914

In #8668 we upgraded from babel to swc through rollup for cjs builds, however the build output was slightly different, notably from:

```
new InstantSearch.default()
```

to

```
new InstantSearch()
```

for an import from instantsearch.js in react-instantsearch-core.

This PR fixes that by ensuring interop is correctly set for swc commonjs modules.

example diff we fix: https://npmdiff.dev/react-instantsearch-core/7.25.0/7.26.0/package/dist/cjs/lib/useInstantSearchApi.js/
@Haroenv Haroenv requested review from a team, aymeric-giraudet and shaejaz and removed request for a team March 4, 2026 09:13
@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 4, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 671ad53:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to restore correct CommonJS default-export interop in the Rollup+SWC CJS build output (regression introduced in the Babel→SWC migration), fixing runtime failures such as Expo/Hermes TypeError: constructor is not callable when instantiating instantsearch.js from CJS builds.

Changes:

  • Adjust createCJSConfig() to pass explicit SWC module settings intended to restore CJS interop behavior.
  • Update yarn.lock (lockfile entry normalization/removal of unused semver selectors).

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/build/rollup.base.mjs Modifies SWC options for CJS builds to enforce CommonJS interop behavior.
yarn.lock Lockfile entry updates (appears incidental to the build tooling change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Haroenv Haroenv merged commit 366e8a7 into master Mar 5, 2026
14 checks passed
@Haroenv Haroenv deleted the fix/build-cjs branch March 5, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React InstantSearch + Expo SDK 54 — TypeError: constructor is not callable

3 participants