Skip to content
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

Module "crypto" has been externalized for browser compatibility on v0.39 upgrade #1649

Closed
brunoocasali opened this issue May 6, 2024 · 1 comment

Comments

@brunoocasali
Copy link
Member

Issue:

While upgrading to v0.39.0 you may see this error:

[plugin:vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by ".../meilisearch-js-plugins/node_modules/meilisearch/dist/bundles/meilisearch.esm.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

It means you're probably using the Vue 3 and Vite like our instant-meilisearch playground.

Solution:

To fix this warning and to be able to build your app just add this to the config file:

export default defineConfig({
  plugins: [vue()],
  build: {
    rollupOptions: {
      external: ['crypto'], // this is the important part
    },
  },
})

Otherwise, you'll face errors like Module "crypto" has been externalized for browser compatibility.

Original error: https://github.com/meilisearch/meilisearch-js-plugins/actions/runs/8970098117/job/24632854404?pr=1294

@brunoocasali
Copy link
Member Author

That was my attempt to fix the error, and it works meilisearch/meilisearch-js-plugins#1294.

If you think this is a mistake, here is the original PR #1616 that introduced this new requirement. We may want to revert it if the workaround I provided is not correct or brings too many drawbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant