-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ipfs-http-client breaks Webpack builds #3452
Comments
It also breaks with a different error
|
So we can replicate the issue, what version of webpack is this? |
|
I'm in the same boat, building with ipfs-http-client just spams the console with "',' expected" errors. |
I just experienced this now. Is there any update on how to fix it? I was using |
I've also experienced this issue when deploying a function into AWS Lambda, Webpack errors with the following issue:
I'm somewhat concerned that Is the suggested fix for this to downgrade? |
I have the same problem. Then when I installed a couple different versions (47 and 55), I got "Module "stream" has been externalized for browser compatibility and cannot be accessed in client code." |
@jthomerson There are examples of bundling |
@achingbrain thanks. I probably should've clarified a bit. I'm aware of stream being for node. What I don't understand is why it's being pulled in. I assumed it was a problem with ipfs-http-client itself, especially since I had the same Electron-centric error originally posted in this bug. But the problem may be the bundler itself. I'm basically following this React-based tutorial, but instead of using React, I started the project with Vitesse - so Vue for the framework, Vite for the bundler. If anyone happens to have any ideas on why Vite might be pulling in Stream, I'd be happy to hear them. All I'm doing in the code is this: import { create as ipfsHttpClient } from 'ipfs-http-client'
const client = ipfsHttpClient('https://ipfs.infura.io:5001/api/v0')
const added = await client.add(
file,
{
progress: prog => console.log(`received: ${prog}`),
},
)
const url = `https://ipfs.infura.io/ipfs/${added.path}`
item.value.fileURL = url |
I'm unfamiliar with Vite, but it looks like it uses Rollup under the hood and not webpack so I don't think it's related to this issue. |
This is an additional problem with any bundler that requires esm modules. It looks like ipfs-http-client is requiring electron and electron-fetch for some reason in versions after 47. |
You should be able to work around this by marking I've managed to replicate and work around this in vite using this plugin |
…lient it was caused due to bad imports. see ipfs/js-ipfs#3452
related, since vite is similar to rollup |
js-ipfs is being deprecated in favor of Helia. You can #4336 and read the migration guide. Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterward (see #4336). Unfortunately, this won't be resolved in js-ipfs repos, but Helia should not run into these problems. If you're still on CJS, you will likely be between a rock and a hard place, but I highly recommend updating your package to ESM and using vite/rollup bundling to solve cjs/esm pains. |
With
48.1.2
a server webpack breaks with (error message below). See CI run https://github.com/dappnode/DNP_DAPPMANAGER/pull/516/checks?check_run_id=1563460710#step:3:279webpack.config.js
webpack error
The text was updated successfully, but these errors were encountered: