-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug]: Browser build is used in CF workers environment #1548
[bug]: Browser build is used in CF workers environment #1548
Comments
Hey! Thanks for reporting and keeping up with the upgrade :) Looking at https://developers.cloudflare.com/workers/wrangler/bundling/#conditional-exports everything looks correctly defined in our exports, but it seems to in the end fallback to our default field, which should be used for browser only was it working on v4? maybe it used one of the root fields https://github.com/algolia/algoliasearch-client-javascript/blob/v4/packages/algoliasearch/package.json#L12 cc @Haroenv maybe you know |
@shortcuts I'm not 100% sure it was working in v4, since I haven't done a production build with v4. Primary reason for that was algolia/api-clients-automation#3608 If you really need to know if v4 was working I could find out, but that would take some effort / time |
Thanks for letting me know!
No worries it's not necessary, it could just have gave hints on how to resolve the issue One workaround here could be to import algoliasearch node directly: |
Already tried that (in local dev), but got
same thing for .cjs |
I believe you should use the fetch requester, which isn't used in any build by default in v4 or v5 |
as in
?? |
@Haroenv For example; I still can't use the
|
Hey @remihuigen, I think the issue is that we don't provide a |
Hey, I'm releasing the 5.4.0 which provides a new |
@shortcuts Yup, module now resolves to the node build! It did introduce a new TS error though
It also brought me back to the issue I started out with two weeks ago |
Could you please provide a minimal reproductive example? I've tried my best with vitest and miniflare here but it seems to work 🤔 |
I'll check downstream first. I'll circle back if there is no solution there. Thanks though! |
Seems like it firebase resolves to a browser build too rather than the node one 🤔 Does it solves the issue when using |
@shortcuts, You responded as I was deleting my comment (thank you!) since using
It appears I can fix the issue by swapping my tsconfig.json file to the below instead of ESNext + Bundler.
|
Ahhh good to know you resolved your issue then! |
Hi @shortcuts, sorry to ping you here. Was I just migrated to import { algoliasearch } from 'algoliasearch'; // Works and what I'm currently using as a workaround!
import { liteClient as algoliasearch } from 'algoliasearch/lite'; // Doesn't work |
I'm getting Property 'generateSecuredApiKey' does not exist on type 'Algoliasearch'. in 5.6.1 using nextjs. Any ideas? When I run the code it works just my builds are failing in production. |
Description
After migrating from v4 to v5 (which was confusing in itself, as others have mentioned), I'm encountering weird issues with the algolia client in production. Such as:
algolia.generateSecuredApiKey is not a function
orReferenceError: XMLHttpRequest is not defined
I did some digging in the output of the production build, and noticed:
Apparently the browser build is used, and not the node js build. But I can't figure why this is happening...
I'm using a Nitro server in a CF workers environment. Version of Algolia client is 5.2.5, but it's been having this issue since at least 5.2.1
for context, this is how the client is set up 👇
Client
All
Version
5.2.5
Relevant log output
No response
The text was updated successfully, but these errors were encountered: