-
Notifications
You must be signed in to change notification settings - Fork 59
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
Error "createHmac" is not exported by "__vite-browser-external"
when building for production
#1299
Comments
Hi @flexchar yes I know! Can you check the release changelog of the meilisearch-js https://github.com/meilisearch/meilisearch-js/releases/tag/v0.39.0 I will add extra information in this changelog so other people can easily get it :) |
I actually checked the wrong change log and then checked the list of commits. However this still doesn't work - I am getting |
Well, the Going further, maybe you can create a repo reproducing your scenario would be extremely helpful! |
I absolutely agree with you. No tokens are being generated here so it only makes it stranger. I borrowed your movies demo index to build this example. https://github.com/flexchar/meili-issue-1299 I am also getting 9/10 times cors issue when loading the |
Because of this change , I can build my Sveltekit project but on the clientside it totally fails to start with the following error:
This is with the following in my vite.config
|
On Nuxt 3 putting the following on the vite: {
build: {
rollupOptions: {
external: ['crypto'],
},
},
}, |
I am glad to now I'm not the only with this. I wonder if we can completely omit the need for the crypto module since it's unlikely that browser users would ever generate tenant tokens. I am also really curious how to get the Vite working and what does @brunoocasali also have in his config that it works for him and not for us. :) |
+1 Came across the same issue while building a svelte project
|
Hey there, I'm sorry to hear that :/ Here is the playground I had to fix right after upgrading to latest meilisearch-js: I didn't find anything different from what you had in your demo (regarding configuration) @flexchar. PS: About your Cloud issue can you reach us from the internal chat?! |
Yeah, that was the idea when I suggested using the Since I don't have time to go over this issue and I don't want to block you anymore, I'm going to push a new patch version, rolling back the change. |
Maybe we should open it at Vite repo and see if they can help us out? I must admit I don't completely understand where the error message comes from since it contains no back trace. |
Hey, I created a branch to solve this issue: meilisearch/meilisearch-js#1652 and I was able to build and see the app running without any warnings. |
Those are great news! I see you isolated the import only when using the function. That seems great to me, even though the curiosity for why Vite wouldn't work otherwise remains hungry. :) |
Yeah, I don't know why either (that's my first time using vite tbh). But I guess it should have something related to the configuration here: https://github.com/meilisearch/meilisearch-js/pull/1616/files#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0L2 |
Good job fixing it Bruno! It at least unblocks me and bunch of other people. And when I get a free minute, I will dig in to see if I can get it working ✌️ |
1652: Update crypto statement to fix vite issue r=curquiza a=brunoocasali After the introduction of this PR #1616 we had a bunch of issues related to vite configuration on client projects as shown here meilisearch/meilisearch-js-plugins#1299 This PR introduces the rollback needed to fix the consumer's code. If this change is not enough, I will completely reverse the PR 1616. Edit: I was able to solve the issue, by using this branch with this [reproduction repo](https://github.com/flexchar/meili-issue-1299) I could build the project and also run the application without any issue. But this change introduces some breaking changes in the JWT code: Now it is required to use await: `await client.generateTenantToken(..)` instead of just `client.generateTenantToken(..)`. Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
Description
I migrated from Algolia's client to Meilisearch. I am unable to build the project for production using
vite build
.Current behavior
Screenshots or Logs
Environment (please complete the following information): (all latest versions)
(This is a move from here meilisearch/meilisearch-js#1651)
I also end up reviewing the change log from 0.17.0 and came across this change which, if applied on my own very project, lets me successfully build the project.
The change: 7b5b003
However then, in the browser console, I receive
Uncaught TypeError: Failed to resolve module specifier "crypto". Relative references must start with either "/", "./", or "../".
error and it doesn't work.Any ideas?
I will tag @brunoocasali. Perhaps it is something obvious that can be configured by me in Vite config and I just happen to be missing it out. ✌️
The text was updated successfully, but these errors were encountered: