Closed kasperaamodt closed 2 months ago
Hey, thanks for reporting the issue! Could you please let me know which env (node or browser)?
Types for algoliasearch/lite
are gone too, typecheck failed in CI for me. May want to check out https://arethetypeswrong.github.io if you haven't already. Doesn't look like they were quite right™️ in 5.2.1 either but they were more right, I guess. 🙂
5.2.1: https://arethetypeswrong.github.io/?p=algoliasearch%405.2.1 5.2.2: https://arethetypeswrong.github.io/?p=algoliasearch%405.2.2
Huge, thanks for the suggestion, I didn't knew that website. Bundling for node and browser is so complicated, sorry for the issues.
I think I know why types are gone but it should resolve the ones from node/browser instead 🤔
algoliasearch@5.2.3
is unable to resolve the main algoliasearch
import specifier in bundlers:
> tsdx build --format esm --target node --tsconfig tsconfig.src.json
⠼ Building modules
(typescript) Error: src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts:2:31 - error TS2307: Cannot find module 'algoliasearch' or its corresponding type declarations.
2 import { algoliasearch } from 'algoliasearch';
~~~~~~~~~~~~~~~
import { liteClient } from 'algoliasearch/lite'
No longer works with 5.2.3, works with 5.1.1. Node v20.17.0. Had to roll back algolia search update. :(
ps - typescript project.
Hey team! We just attempted to upgrade to 5.2.3 today and ran into the same issue.
I think I know why types are gone but it should resolve the ones from node/browser instead 🤔
It looks like you have found the cause of the issue, but as to why it breaks, it's not always determinable ahead of time if code is browser or node only (react server components or Nextjs for example)
It looks like node recommends to use "node" and "default"
over "node" and "browser"
for this reason.
https://nodejs.org/api/packages.html#:~:text=When%20using%20environment,browser%22%20condition%20branches.
We had attempted to implement a pnpm patch for this, but ran into some CI/CD build issues stopping us, although changing browser back to default did solve our issue.
Hey @Zach-Jaensch sorry for the issues, https://github.com/algolia/api-clients-automation/pull/3640 have everything fixed up, I'll try to ship that today
Amazing. Will try it out in the morning and let you know!
Still seeing a problem with 5.2.4 - forgot to mention I am using pnpm 9.9.0 too.
▲ Next.js 14.2.7
- Environments: .env.local
- Experiments (use with caution):
· turbo
· webpackBuildWorker
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types ..Failed to compile.
./src/components/search/Search.tsx:3:28
Type error: Cannot find module 'algoliasearch/lite' or its corresponding type declarations.
1 | 'use client'
2 |
> 3 | import { liteClient } from 'algoliasearch/lite'
| ^
4 | import { InstantSearch, useInstantSearch } from 'react-instantsearch'
5 |
6 | import { env } from '@/config/env.mjs'
ELIFECYCLE Command failed with exit code 1.
Hey, yup nothing has changed in 5.2.4, https://github.com/algolia/api-clients-automation/pull/3640 is not yet merged
Hey there, I just released a 5.2.4-beta.2 version with a fix for this issue, if you have time, please try it out and let me know so I can go ahead with the PR :)
Thanks
@shortcuts Yay! It works again > algoliasearch@5.2.4-beta.2. Happy Labor Day! :)
leeeeetsss goooooooooooo!!
this will be released in stable tomorrow, happy labor day :)
Can confirm 5.2.4-beta.2 works for us as well. It also fixed another issue with the types from "algoliasearch" not resolving correctly for the search client! Looking forward to the stable release.
Thanks for the fix!
Sorry to bring more issues (can create a new issue if it is too unrelated) there appears to be missing type exports from the subdeps of algoliasearch. Here is the output of our nextjs app, and a minimum repo (vite react) to help with testing.
Failed to compile.
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
Attempted import error: 'Region' is not exported from '@algolia/client-abtesting' (imported as 'ABTestingRegion').
Import trace for requested module:
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
./src/utils/algolia/client.ts
./src/utils/algolia/search.ts
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
Attempted import error: 'AbtestingClient' is not exported from '@algolia/client-abtesting' (imported as 'AbtestingClient').
Import trace for requested module:
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
./src/utils/algolia/client.ts
./src/utils/algolia/search.ts
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
Attempted import error: 'AdvancedSyntaxFeatures' is not exported from '@algolia/client-search' (imported as 'AdvancedSyntaxFeatures').
Import trace for requested module:
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
./src/utils/algolia/client.ts
./src/utils/algolia/search.ts
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
Attempted import error: 'AlternativesAsExact' is not exported from '@algolia/client-search' (imported as 'AlternativesAsExact').
Import trace for requested module:
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
./src/utils/algolia/client.ts
./src/utils/algolia/search.ts
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
Attempted import error: 'AnalyticsClient' is not exported from '@algolia/client-analytics' (imported as 'AnalyticsClient').
Import trace for requested module:
../../node_modules/.pnpm/algoliasearch@5.2.4-beta.2/node_modules/algoliasearch/dist/browser.js
./src/utils/algolia/client.ts
./src/utils/algolia/search.ts
> Build failed because of webpack errors
ngl your 2 comments were an emotional rollercoaster @Zach-Jaensch................
but it's fixed in -beta.6 :D
The fix has been released in 5.2.5!
@shortcuts thanks!
I can confirm that algoliasearch@5.2.5
has now resolved the algolia
package resolution problems
Are The Types Wrong? also reports successful checks for algoliasearch@5.2.5
:
Thanks for testing!! I've also integrated attw and publint to our CI so we can make sure not to introduce regressions :D
Sorry for the delay (had a busy week come out of nowhere), it works fine for us now. Thanks for getting the types all fix up, rollercoaster and all.
Description
Seems like the the issue of types not being included is back in v5.2.2. When I downgrade to 5.1.1, they are included.
Client
All
Version
5.2.2.
Relevant log output
No response