[Vite 4] - meilisearch.esm.js:2:19: ERROR: Could not resolve "crypto"
candidosales opened this issue · comments
Description
Upgrade the Vite from v3.2.4 to v4.0.0. Perhaps we have to upgrade to Rollup 3. Vite 4 uses Rollup 3: https://vitejs.dev/blog/announcing-vite4.html
Expected behavior
Build the SvelteKit/Svelte correctly.
Current behavior
See the logs.
Screenshots or Logs
> Using @sveltejs/adapter-vercel
✘ [ERROR] Could not resolve "crypto"
node_modules/meilisearch/dist/bundles/meilisearch.esm.js:2:19:
2 │ import crypto from 'crypto';
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "stream"
node_modules/node-fetch/lib/index.mjs:1:19:
1 │ import Stream from 'stream';
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "http"
node_modules/node-fetch/lib/index.mjs:2:17:
2 │ import http from 'http';
╵ ~~~~~~
The package "http" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "url"
node_modules/node-fetch/lib/index.mjs:3:16:
3 │ import Url from 'url';
╵ ~~~~~
The package "url" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "https"
node_modules/node-fetch/lib/index.mjs:5:18:
5 │ import https from 'https';
╵ ~~~~~~~
The package "https" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "zlib"
node_modules/node-fetch/lib/index.mjs:6:17:
6 │ import zlib from 'zlib';
╵ ~~~~~~
The package "zlib" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
error during build:
Error: Build failed with 6 errors:
node_modules/meilisearch/dist/bundles/meilisearch.esm.js:2:19: ERROR: Could not resolve "crypto"
node_modules/node-fetch/lib/index.mjs:1:19: ERROR: Could not resolve "stream"
node_modules/node-fetch/lib/index.mjs:2:17: ERROR: Could not resolve "http"
node_modules/node-fetch/lib/index.mjs:3:16: ERROR: Could not resolve "url"
node_modules/node-fetch/lib/index.mjs:5:18: ERROR: Could not resolve "https"
...
at failureErrorWithLog (/Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:1591:15)
at /Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:1047:28
at /Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:992:67
at buildResponseToResult (/Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:1045:7)
at /Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:1157:14
at responseCallbacks.<computed> (/Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:694:9)
at handleIncomingPacket (/Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:749:9)
at Socket.readFromStdout (/Users/candidosales/Documents/Projects/geleia-turismo/node_modules/esbuild/lib/main.js:670:7)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
Environment (please complete the following information):
- OS: MacOS Ventura - Version 13.0.1 (22A400)
- Meilisearch version: v.0.29.0
- meilisearch-js version: v0.29.1 and v0.30.0
Hey @candidosales, for some reason vite 4 now decided to not use the browser
build of the package
Line 21 in b1ed904
but the module build
Line 20 in b1ed904
If you find any information on that change, I'd be very interested. Maybe I need to update the builds on my side.
node_modules/meilisearch/dist/bundles/meilisearch.esm.js:2:19: ERROR: Could not resolve "crypto"
@bidoubiwa I upgraded my project with SvelteKit 1.0, and the build was fixed.
I'm going to close this issue. Thanks! :)