Skip to content

Rework exports and bundling and dependencies#1471

Merged
Strift merged 12 commits into
mainfrom
esm-only
Apr 20, 2026
Merged

Rework exports and bundling and dependencies#1471
Strift merged 12 commits into
mainfrom
esm-only

Conversation

@flevi29
Copy link
Copy Markdown
Collaborator

@flevi29 flevi29 commented Apr 7, 2026

Pull Request

What does this PR do?

Migration

  • CommonJS and UMD bundles aren't available anymore
  • package.json "main" and "types" fields aren't available anymore

If you relied on any of these outdated features, you will have to bundle for any target environment that requires them, or update the environment if that's possible.

  1. From now on meilisearch is a peer dependency (if the package manager used doesn't automatically install it, add it to the list of dependencies manually):
- import { meilisearch } from '@meilisearch/instant-meilisearch'
- import { meilisearch } from '@meilisearch/autocomplete-client'
+ import * as meilisearch from 'meilisearch'
+ import { Meilisearch } from 'meilisearch'

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • Breaking Changes

    • Renamed MeiliSearch → Meilisearch across public types and exports.
    • Removed CommonJS/UMD bundles; packages now publish modern ES module sources.
    • meilisearch is a peer dependency; legacy main/types fields removed in favor of exports.
  • Chores

    • Node.js target bumped to v24 and build/publishing simplified.
  • Documentation

    • README examples updated to ES module + importmap usage.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 2b61af9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@meilisearch/autocomplete-client Minor
@meilisearch/instant-meilisearch Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5296c3b9-23c3-4da4-9e75-05d701a1db87

📥 Commits

Reviewing files that changed from the base of the PR and between 8663696 and 2b61af9.

📒 Files selected for processing (1)
  • packages/instant-meilisearch/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/instant-meilisearch/README.md

📝 Walkthrough

Walkthrough

Refactors packaging and build: updates Node version, moves to TypeScript-first publishing (exports point to ./src), removes UMD/CJS bundles and version-generation scripts, makes meilisearch a peer dependency, switches runtime imports to Meilisearch, and adjusts configs/scripts across packages and playgrounds.

Changes

Cohort / File(s) Summary
Root config
.nvmrc, package.json, tsconfig.json, turbo.json, vite.config.ts, pnpm-workspace.yaml
Bumped Node to v24, removed workspace entries, simplified scripts, upgraded TS/Vitest/pnpm versions, changed TS module/emit settings, removed turbo build deps, added meilisearch catalog mapping in workspace.
Autocomplete client package
packages/autocomplete-client/package.json, packages/autocomplete-client/tsconfig.json, packages/autocomplete-client/vite.config.ts, packages/autocomplete-client/src/..., packages/autocomplete-client/__tests__/*, packages/autocomplete-client/scripts/update_version.cjs
Switched exports to ./src/index.ts, removed UMD bundling and version generator, build now runs tsc, tsconfig consolidated to ./dist/, user-agent version now read from root package.json, tests and utils updated to use Meilisearch, added peer dep for meilisearch.
Instant Meilisearch package
packages/instant-meilisearch/package.json, packages/instant-meilisearch/tsconfig.json, packages/instant-meilisearch/vite.config.ts, packages/instant-meilisearch/src/..., packages/instant-meilisearch/__tests__/*, packages/instant-meilisearch/scripts/update_version.cjs
Same packaging shift: exports → ./src/index.ts, publishConfig exposes ./dist/index.js, removed version generator and UMD build config, tsconfig consolidated, replaced PACKAGE_VERSION usage with root pkg.version, renamed type/imports to Meilisearch, removed export * as meilisearch.
Playgrounds — autocomplete & local-react
playgrounds/autocomplete/*, playgrounds/local-react/*
Switched setup scripts to tsx/.mts, replaced CommonJS vite configs with .mts Vite configs, updated Meilisearch instantiation to new Meilisearch(...).
Playgrounds — node-env & others
playgrounds/node-env/*, playgrounds/vue3/src/App.vue
Changed runtime to tsx for dev, removed exports field, updated Meilisearch import/instantiation to Meilisearch, simplified error/exit handling, minor UI text change (MeiliSearchMeilisearch).
Tests & types adjustments
packages/.../__tests__/*, packages/.../src/types/*, packages/.../src/adapter/...
Replaced angle-bracket casts with as assertions, updated type imports/exports to Meilisearch, adjusted function/type signatures where needed to new type name; test expectations updated to read package pkg.version.
Misc — README & changeset
packages/instant-meilisearch/README.md, .changeset/*
Updated HTML example to use module/importmap and Meilisearch import; changeset documents packaging/export and peer-dep changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 I hopped from eighteen-twenty to sweet twenty-four,
No bundles to chase — TypeScript opens the door,
Peer-deps paired, exports point to src delight,
Meilisearch now spelled just right,
I nibble at changes and thump with delight. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main focus of the changeset: reworking how exports are structured, bundling strategy, and dependency management (making meilisearch a peer dependency). This accurately reflects the substantial architectural changes across all package configurations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch esm-only

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Strift
Copy link
Copy Markdown
Collaborator

Strift commented Apr 14, 2026

Hey @flevi29, this is looking good.

If we can merge soon, I'd love to have this and #1469 in the same release.

Releasing separately is fine too if you don't have time to finish here.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/instant-meilisearch/README.md (1)

551-554: ⚠️ Potential issue | 🟡 Minor

Update stale Node/NPM compatibility info.

This section still states NodeJS >= 12.10 <= 18 and NPM >= 6.x, but the package now requires ^20.19.0 || >=22.12.0 per packages/instant-meilisearch/package.json's engines. Given this PR drops CJS/UMD and targets modern Node + ESM, please update these lines (or remove the section) to avoid misleading consumers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/instant-meilisearch/README.md` around lines 551 - 554, The README's
"Node / NPM versions" block is stale; update or remove it so it matches the
package's engines field. Replace the lines "NodeJS >= 12.10 <= 18" and "NPM >=
6.x" with the current engine requirement from
packages/instant-meilisearch/package.json (engines: "^20.19.0 || >=22.12.0") or
remove the entire compatibility section if you prefer to rely on package.json
for authoritative info; ensure the README references the same engines string or
an equivalent modern-Node statement and mention ESM-only / dropped CJS/UMD if
relevant.
🧹 Nitpick comments (1)
packages/autocomplete-client/__tests__/test.utils.ts (1)

2-18: Exercise autocomplete-client’s own subpath in its tests.

This currently imports the SDK through instant-meilisearch, so @meilisearch/autocomplete-client/meilisearch could regress without this test utility noticing. Reuse HOST/API_KEY while you’re touching the constructor.

Proposed test utility cleanup
-import { MeiliSearch } from '@meilisearch/instant-meilisearch/meilisearch'
+import { MeiliSearch } from '@meilisearch/autocomplete-client/meilisearch'
@@
 const meilisearchClient = new MeiliSearch({
-  host: 'http://localhost:7700',
-  apiKey: 'masterKey',
+  host: HOST,
+  apiKey: API_KEY,
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/autocomplete-client/__tests__/test.utils.ts` around lines 2 - 18,
The test utility imports MeiliSearch from the wrong package: replace the import
from '@meilisearch/instant-meilisearch/meilisearch' with the package's own
subpath '@meilisearch/autocomplete-client/meilisearch' so tests exercise the
library's export; also reuse the existing HOST and API_KEY constants when
constructing both searchClient (meilisearchAutocompleteClient) and
meilisearchClient (new MeiliSearch) so they share the same config instead of
hardcoding values—update references to MeiliSearch,
meilisearchAutocompleteClient, HOST, API_KEY, searchClient, and
meilisearchClient accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/autocomplete-client/package.json`:
- Around line 10-13: The exports map in the package.json is missing an entry for
"./package.json", causing workspace consumers to be blocked from resolving the
package metadata; update the "exports" object in packages' package.json (the
object containing "." and "./meilisearch") to include the "./package.json":
"./package.json" export so the package.json subpath is allowed (apply the same
change to the instant-meilisearch package.json exports block).
- Line 18: The exported "./meilisearch" entry re-exports from the external
"meilisearch" package but that package isn’t declared or marked external,
causing consumers to fail; fix by either adding "meilisearch" as a
peerDependency in packages/autocomplete-client/package.json (so the consumer
must install it) or marking "meilisearch" as external in the Vite/Rollup build
config that produces ./meilisearch (and also add "meilisearch" as a
peerDependency in `@meilisearch/instant-meilisearch` package.json if it re-exports
it), and update packages/autocomplete-client/src/meilisearch.ts usage
accordingly so the built "./meilisearch" export does not bundle or omit the
unresolved module.

In `@packages/instant-meilisearch/package.json`:
- Around line 27-30: The workspace exports object is missing the
"./package.json" entry that exists in publishConfig.exports; update the exports
block (the "exports" property) to include an entry mapping "./package.json" to
"./package.json" so that consumers can import
`@meilisearch/instant-meilisearch/package.json` in local dev as they can after
publish, ensuring parity with publishConfig.exports.

In `@packages/instant-meilisearch/src/meilisearch.ts`:
- Line 1: The package currently re-exports the external module via
src/meilisearch.ts (export * from 'meilisearch') but
packages/instant-meilisearch/package.json does not declare "meilisearch" as a
dependency, and vite.config.ts has no rollupOptions.external/noExternal setting;
to fix, add "meilisearch" as a peerDependency (preferred for re-exporting a
public API) in package.json or alternatively update vite.config.ts to explicitly
externalize "meilisearch" via rollupOptions.external (or add it to noExternal to
force bundling) so consumers won't get duplicate copies or build failures;
locate the export in src/meilisearch.ts and the packaging config in
vite.config.ts/package.json to implement the chosen change.

In `@playgrounds/local-react/package.json`:
- Around line 7-9: The package.json scripts "predev" and "setup" reference the
old filename setup.mjs which was renamed to setup.mts; update both script
entries ("predev" and "setup") to call "tsx setup.mts" so they point to the new
module name and the commands will run correctly.

---

Outside diff comments:
In `@packages/instant-meilisearch/README.md`:
- Around line 551-554: The README's "Node / NPM versions" block is stale; update
or remove it so it matches the package's engines field. Replace the lines
"NodeJS >= 12.10 <= 18" and "NPM >= 6.x" with the current engine requirement
from packages/instant-meilisearch/package.json (engines: "^20.19.0 ||
>=22.12.0") or remove the entire compatibility section if you prefer to rely on
package.json for authoritative info; ensure the README references the same
engines string or an equivalent modern-Node statement and mention ESM-only /
dropped CJS/UMD if relevant.

---

Nitpick comments:
In `@packages/autocomplete-client/__tests__/test.utils.ts`:
- Around line 2-18: The test utility imports MeiliSearch from the wrong package:
replace the import from '@meilisearch/instant-meilisearch/meilisearch' with the
package's own subpath '@meilisearch/autocomplete-client/meilisearch' so tests
exercise the library's export; also reuse the existing HOST and API_KEY
constants when constructing both searchClient (meilisearchAutocompleteClient)
and meilisearchClient (new MeiliSearch) so they share the same config instead of
hardcoding values—update references to MeiliSearch,
meilisearchAutocompleteClient, HOST, API_KEY, searchClient, and
meilisearchClient accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c63cc16-130f-405c-9d29-d4c610db3c9a

📥 Commits

Reviewing files that changed from the base of the PR and between aea695f and 40c3d0c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .nvmrc
  • package.json
  • packages/autocomplete-client/__tests__/test.utils.ts
  • packages/autocomplete-client/package.json
  • packages/autocomplete-client/scripts/update_version.cjs
  • packages/autocomplete-client/src/client/autocompleteSearchClient.ts
  • packages/autocomplete-client/src/meilisearch.ts
  • packages/autocomplete-client/src/package-version.ts
  • packages/autocomplete-client/tsconfig.json
  • packages/autocomplete-client/vite.config.ts
  • packages/instant-meilisearch/README.md
  • packages/instant-meilisearch/__tests__/configure.attributes-to-retrieve.test.ts
  • packages/instant-meilisearch/__tests__/search-resolver.test.ts
  • packages/instant-meilisearch/package.json
  • packages/instant-meilisearch/scripts/update_version.cjs
  • packages/instant-meilisearch/src/adapter/search-request-adapter/search-params-adapter.ts
  • packages/instant-meilisearch/src/client/agents.ts
  • packages/instant-meilisearch/src/index.ts
  • packages/instant-meilisearch/src/meilisearch.ts
  • packages/instant-meilisearch/src/package-version.ts
  • packages/instant-meilisearch/tsconfig.json
  • packages/instant-meilisearch/vite.config.ts
  • playgrounds/autocomplete/package.json
  • playgrounds/autocomplete/setup.mts
  • playgrounds/autocomplete/vite.config.mts
  • playgrounds/autocomplete/vite.config.ts
  • playgrounds/local-react/package.json
  • playgrounds/local-react/setup.mts
  • playgrounds/local-react/vite.config.mts
  • playgrounds/local-react/vite.config.ts
  • playgrounds/node-env/index.ts
  • playgrounds/node-env/package.json
  • tsconfig.json
  • turbo.json
  • vite.config.ts
💤 Files with no reviewable changes (7)
  • packages/autocomplete-client/src/package-version.ts
  • packages/instant-meilisearch/scripts/update_version.cjs
  • playgrounds/autocomplete/vite.config.ts
  • packages/autocomplete-client/scripts/update_version.cjs
  • packages/instant-meilisearch/src/index.ts
  • playgrounds/local-react/vite.config.ts
  • packages/instant-meilisearch/src/package-version.ts

Comment thread packages/autocomplete-client/package.json
Comment thread packages/autocomplete-client/package.json Outdated
Comment thread packages/instant-meilisearch/package.json
Comment thread packages/instant-meilisearch/src/meilisearch.ts Outdated
Comment thread playgrounds/local-react/package.json Outdated
@flevi29 flevi29 marked this pull request as draft April 18, 2026 12:34
@flevi29 flevi29 marked this pull request as ready for review April 18, 2026 15:09
@flevi29 flevi29 changed the title Esm only Rework exports and bundling and dependencies Apr 18, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/instant-meilisearch/README.md (1)

559-562: ⚠️ Potential issue | 🟡 Minor

Update the compatibility section for the new engine floor.

The README advertises NodeJS >= 12.10 <= 18, but package.json specifies ^20.19.0 || >=22.12.0. Update the compatibility section to match the actual supported versions:

 **Node / NPM versions**:
 
-- NodeJS >= 12.10 <= 18
-- NPM >= 6.x
+- Node.js ^20.19.0 || >=22.12.0
+- npm version compatible with the supported Node.js releases
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/instant-meilisearch/README.md` around lines 559 - 562, The README's
"Node / NPM versions" compatibility text is out of date; update the NodeJS
constraint to match package.json's engine field (^20.19.0 || >=22.12.0) by
replacing "NodeJS >= 12.10 <= 18" with the equivalent supported range, and
verify the NPM line if package.json specifies an NPM constraint—ensure the
README's Node and NPM version lines reflect the exact engine string from
package.json.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.changeset/crisp-wasps-flow.md:
- Line 13: Update the Node.js version note in .changeset/crisp-wasps-flow.md so
it matches the package engines; replace the phrase "Node.js ^20" with wording
that reflects the configured engines (for example "Node.js >=20.19.0 (or
>=22.12.0)" or similar text that matches "engines: ^20.19.0 || >=22.12.0") so
the note no longer claims support for versions below the declared minimum.

In `@packages/instant-meilisearch/README.md`:
- Around line 496-528: The example currently imports InstantSearch as a UMD
side-effect and then expects a global instantsearch; instead replace the UMD
side-effect import with explicit ESM imports and use the widget exports
directly: import the instantsearch factory (instantsearch) and the widget
constructors (searchBox, hits) from an ESM-compatible CDN, keep the existing
instantMeiliSearch call to obtain searchClient, then instantiate search with
instantsearch({ indexName, searchClient }) and add widgets using the imported
searchBox and hits functions (instead of instantsearch.widgets.searchBox /
instantsearch.widgets.hits) before calling search.start(); this ensures the
example works in type="module" contexts.

---

Outside diff comments:
In `@packages/instant-meilisearch/README.md`:
- Around line 559-562: The README's "Node / NPM versions" compatibility text is
out of date; update the NodeJS constraint to match package.json's engine field
(^20.19.0 || >=22.12.0) by replacing "NodeJS >= 12.10 <= 18" with the equivalent
supported range, and verify the NPM line if package.json specifies an NPM
constraint—ensure the README's Node and NPM version lines reflect the exact
engine string from package.json.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e54d2a85-3d44-4b9a-a173-c171e6523d8a

📥 Commits

Reviewing files that changed from the base of the PR and between 40c3d0c and 8663696.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (22)
  • .changeset/crisp-wasps-flow.md
  • package.json
  • packages/autocomplete-client/__tests__/test.utils.ts
  • packages/autocomplete-client/package.json
  • packages/autocomplete-client/tsconfig.json
  • packages/autocomplete-client/vite.config.ts
  • packages/instant-meilisearch/README.md
  • packages/instant-meilisearch/__tests__/assets/utils.ts
  • packages/instant-meilisearch/__tests__/search-resolver.test.ts
  • packages/instant-meilisearch/package.json
  • packages/instant-meilisearch/src/adapter/search-request-adapter/search-resolver.ts
  • packages/instant-meilisearch/src/client/instant-meilisearch-client.ts
  • packages/instant-meilisearch/src/types/types.ts
  • packages/instant-meilisearch/tsconfig.json
  • packages/instant-meilisearch/vite.config.ts
  • playgrounds/autocomplete/setup.mts
  • playgrounds/local-react/package.json
  • playgrounds/local-react/setup.mts
  • playgrounds/node-env/index.ts
  • playgrounds/vue3/src/App.vue
  • pnpm-workspace.yaml
  • tsconfig.json
✅ Files skipped from review due to trivial changes (7)
  • pnpm-workspace.yaml
  • packages/instant-meilisearch/src/client/instant-meilisearch-client.ts
  • playgrounds/vue3/src/App.vue
  • playgrounds/autocomplete/setup.mts
  • playgrounds/local-react/setup.mts
  • playgrounds/local-react/package.json
  • packages/autocomplete-client/tests/test.utils.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/instant-meilisearch/tests/search-resolver.test.ts
  • packages/instant-meilisearch/tsconfig.json
  • playgrounds/node-env/index.ts
  • tsconfig.json
  • packages/instant-meilisearch/vite.config.ts
  • packages/instant-meilisearch/package.json

Comment thread .changeset/crisp-wasps-flow.md
Comment thread packages/instant-meilisearch/README.md
@flevi29
Copy link
Copy Markdown
Collaborator Author

flevi29 commented Apr 18, 2026

@Strift I think I've done it.

Copy link
Copy Markdown
Collaborator

@Strift Strift left a comment

Choose a reason for hiding this comment

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

Awesome stuff 🙌

Much welcome cleanup of the dev workflow and build pipeline.

@Strift Strift added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit b6bfbd7 Apr 20, 2026
8 checks passed
@Strift Strift deleted the esm-only branch April 20, 2026 04:53
@flevi29 flevi29 mentioned this pull request Apr 20, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change The related changes are breaking for the users maintenance

Projects

None yet

2 participants