algolia: Can't build project with v1.4.0 – `Agent` is not exported
WARN Error when using sourcemap for reporting an error: Can't resolve original location of error.
ERROR 'Agent' is not exported by __vite-browser-external, imported by node_modules/.pnpm/@algolia+requester-node-http@4.14.2/node_modules/@algolia/requester-node-http/dist/requester-node-http.esm.js
file: /Users/lukaszflorczak/my-project/node_modules/.pnpm/@algolia+requester-node-http@4.14.2/node_modules/@algolia/requester-node-http/dist/requester-node-http.esm.js:2:9
1: import * as http from 'http';
2: import { Agent } from 'http';
^
3: import * as https from 'https';
4: import { Agent as Agent$1 } from 'https';
Version
@nuxtjs/algolia: v1.4.0
nuxt: v3.0.0
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 25 (1 by maintainers)
Hey @michaelvcolianna
No worries. Please create a separate issue with your reproduction details (ideally some reproduction link on stackblitz) and I will take a look at it 😃
No problem 😉 Algolia is the main engine of one of my applications, so with the development, there will probably be some more ideas
Awesome!
Sorry that it took so long.
If you will have any ideas on improving the module, let me know 😃
Thanks @pi0 for help!
I have tested it and it seems to be working. I have released a new 1.5.0 version with some other updates as well.
@lukaszflorczak could you test whether an issue is there for you when you bump to 1.5.0?
Checking with the reproduction @Baroshem provided, it seems vite is eagerly scanning dynamic import without checking the
process.envguard (tree-shaking after)Probably best solution would be providing
nuxtApp.$algolia.transporter.requesterpolyfill using a server-only nuxt plugin inalgolia.server.tsinstead of hereAn easier solution is mocking the
@algolia/requester-node-httpalias for client-build only.Fixed sandbox: https://stackblitz.com/edit/github-epeint-mjbn5m?file=nuxt.config.ts
I have finally managed to reproduce it. It seems that the following line is causing the issue with Supabase module. Dont really know why because it is a simple registration of the aliases but it may be connected to how Supabase is registering optimizeDeps. I will investigate it further and let you know.
Sorry, I’ve been a bit busy. Today I will try to share with you in some way the project where I have this error.
It should be working now with 1.4.2 verions
Hey @lukaszflorczak
Thanks for raising this issue. I just found a workaround for that. It seems that Vite is managing to correctly serve server packages in dev environment while it breaks for production environment.
I will publish a new version in few minutes so that you could try if it fixes the issue.