parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.38k stars 2.27k forks source link

Failed to resolve 'ipfs-car/pack' #8226

Closed fawazahmed0 closed 2 years ago

fawazahmed0 commented 2 years ago

🐛 bug report

Parcel build fails with web3.storage package

🎛 Configuration (.babelrc, package.json, cli command)

Package.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "build": "parcel build src/index.html"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "parcel": "^2.6.1"
  },
  "dependencies": {
    "web3.storage": "^4.2.0"
  }
}

cli command: npm run build

🤔 Expected Behavior

Should build the web app

😯 Current Behavior

Build fails

# npm run build

> test@1.0.0 build
> parcel build src/index.html

🚨 Build failed.

@parcel/core: Failed to resolve 'ipfs-car/pack' from './node_modules/web3.storage/src/lib.js'

  /test/node_modules/web3.storage/src/lib.js:18:22
    17 | import pRetry from 'p-retry'
  > 18 | import { pack } from 'ipfs-car/pack'
  >    |                      ^^^^^^^^^^^^^^^
    19 | import { parseLinkHeader } from '@web3-storage/parse-link-header'
    20 | import { unpackStream } from 'ipfs-car/unpack'

💁 Possible Solution

import { Web3Storage } from 'web3.storage/dist/bundle.esm.min'

🔦 Context

I am trying to import web3.storage package, which provides 1TB+ storage for free

💻 Code Sample

Code Repository

🌍 Your Environment

Software Version(s)
Parcel 2.6.1
Node 18.4.0
npm/Yarn 8.12.1
Operating System Ubuntu 20.04.4 LTS
devongovett commented 2 years ago

This appears to rely on the exports field in package.json, which is not yet supported by Parcel. Duplicate of #4155.

https://github.com/web3-storage/ipfs-car/blob/1ee839c26e9a3b30ebc07a6d6475c2637dbd44d9/package.json#L36

fawazahmed0 commented 2 years ago

For now, I am using esm bundle version

import { Web3Storage } from 'web3.storage/dist/bundle.esm.min'

It seems to build fine for me.