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

Why won't it skypack #27

Open
olizilla opened this issue Jun 15, 2021 · 5 comments
Open

Why won't it skypack #27

olizilla opened this issue Jun 15, 2021 · 5 comments
Labels

Comments

@olizilla
Copy link
Contributor

trying to use skypack like:

<!DOCTYPE html>
<head>
  <meta charset="utf-8" />
</head>
<pre id="out"></pre>
<script type="module">
  import { NFTStorage } from 'https://cdn.skypack.dev/nft.storage'
  import { packToBlob } from 'https://cdn.skypack.dev/ipfs-car/pack/blob'

  const endpoint = 'https://api.nft.storage' // the default
  const token =
    new URLSearchParams(window.location.search).get('key') || 'API_KEY' // your API key from https://nft.storage/manage

  function log(msg) {
    msg = JSON.stringify(msg, null, 2)
    document.getElementById('out').innerHTML += `${msg}\n`
  }

  async function main() {
    const store = new NFTStorage({ endpoint, token })
    const data = 'Hello nft.storage!'

    // locally chunk'n'hash the data to get the CID and pack the blocks in to a CAR
    const { root, car } = await packToBlob({
      input: [new TextEncoder().encode(data)],
    })
    const expectedCid = root.toString()
    console.log({ expectedCid })

    // send the CAR to nft.storage, the returned CID will match the one we created above.
    const cid = await store.storeCar(car)

    // verify the service is storing the CID we expect
    const cidsMatch = expectedCid === cid
    log({ data, cid, expectedCid, cidsMatch })

    // check that the CID is pinned
    const status = await store.status(cid)
    log(status)
  }
  main()
</script>

does not work. You get a

Uncaught TypeError: null has no properties
    <anonymous> https://cdn.skypack.dev/-/uint8arrays@v2.1.3-MNVirG8yMHFVvhSeyUgN/dist=es2020,mode=imports/unoptimized/to-string.js:4
to-string.js:4:23

from:

https://cdn.skypack.dev/-/uint8arrays@v2.1.3-MNVirG8yMHFVvhSeyUgN/dist=es2020,mode=imports/unoptimized/to-string.js

but there is no obvious reason why it should pull in version 2.1.3 when there is a 2.1.5 version of unit8arrays that does not have the problem. the older version uses TextEncoder from web-encoding achingbrain/uint8arrays@v2.1.3...v2.1.5 that fails to bundle. The newere 2.1.5 doesn't. WHY IS SKYPACK USING THE OLDER BAD ONE?

olizilla added a commit to nftstorage/nft.storage that referenced this issue Jun 15, 2021
as skypack is not work, see: web3-storage/ipfs-car#27

License: MIT
Signed-off-by: Oli Evans <oli@tableflip.io>
@vasco-santos
Copy link
Member

So, I can see that skypack gets a bunch of uint8arrays and somehow one of our dependencies use the 2.1.3

image

this is related to skypackjs/skypack-cdn#159

@vasco-santos
Copy link
Member

@olizilla I could discover that is multicodec that apparently is pulling the old uint8arrays, even though I have no clue of the reason behind this... It is pulled from unixfs-importer

Please check https://codepen.io/vascosantos/pen/mdWZmWq?editors=0011

image

As we can see, it only gets 2.1.3...

@vasco-santos
Copy link
Member

vasco-santos commented Jun 25, 2021

The multicodec PR fixed the problem mentioned on the Original Post, but now we have another issue...

Uncaught TypeError: Cannot destructure property 'sha256' of 'require$$1' as it is null.
    at ipfs-unixfs-importer.js:18

This is in the unixfs-importer now: https://codepen.io/vascosantos/pen/LYWwgPP?editors=0011

@vasco-santos
Copy link
Member

Some research happened on: https://github.com/vasco-santos/cjs-esm-skypack-build-rep

And root issue updated: skypackjs/skypack-cdn#171

To unblock this, we will need to either bundle ipfs-unixfs on publish, or make it an ESM citizen

@dchoi27 dchoi27 added the status/blocked Unable to be worked further until needs are met label Aug 5, 2021
@atopal
Copy link

atopal commented Aug 16, 2021

related: web3-storage/web3.storage#220

@atopal atopal added P1 and removed status/blocked Unable to be worked further until needs are met labels Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants