algolia / algolia/docsearch

peerDependency warning for `search-insights`

Open
#2,516 1 comment 0 reactions 0 assignees View on GitHub
Investigation in progress
Dominant language
TypeScript
Stars
4.4k
Forks
439
Avg merge
14h 32m
Merged PRs (30d)
19

Description

## Description

When initializing a new Docusaurus site with pnpm, we get the following warning

```bash
npx create-docusaurus@latest my-website classic --javascript --package-manager pnpm
````

```
└─┬ @docusaurus/preset-classic 3.7.0
├─┬ @docusaurus/theme-search-algolia 3.7.0
│ └─┬ @docsearch/react 3.9.0
│ ├── ✕ missing peer search-insights@">= 1 < 3"
│ └─┬ @algolia/autocomplete-core 1.17.9
│ └─┬ @algolia/autocomplete-plugin-algolia-insights 1.17.9
│ └── ✕ missing peer search-insights@">= 1 < 3"
```

## Steps to reproduce

This can be reproduced outside Docusaurus:

```
mkdir test
cd test
pnpm init
pnpm add @docsearch/react
```

![Image](https://github.com/user-attachments/assets/8a0a6b00-f303-4b5d-8dac-3a7c3ef07419)

## Expected behavior

No warning

## Environment

- pnpm
- DocSearch version: 3.9

---

I'm not sure why this happens considering the lib has

```json
"peerDependenciesMeta": {
"search-insights": {
"optional": true
}
}
```

Maybe this is because it depends on other Algolia packages that do not declare this peerDependency as optional? 🤷‍♂

I didn't find any ref in the doc to install the `search-insights` package, so I guess it's fine to only depend on this lib?

Contributor guide

Open the contributing guide

Research direction

Start by running the pnpm reproduction with @docsearch/react 3.9.0, then inspect the peer dependency metadata for @docsearch/react and the listed @algolia packages. Trace which package declares search-insights as non-optional and verify the corrected dependency metadata by repeating the installation; done means pnpm emits no peerDependency warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.