ts-ucan icon indicating copy to clipboard operation
ts-ucan copied to clipboard

Library seems to confuse skypack CDN

Open Gozala opened this issue 4 years ago • 6 comments

I was trying to use this library in observable snippet and run into issue, it seems that something is confusing skypack CDN resulting in broken library. Here is the link to an example https://observablehq.com/@protocol/ucan-skypack-problem

Gozala avatar Nov 15 '21 20:11 Gozala

Some progress on this: It's somewhat hard to get a stacktrace in observable. Running this in the browser console reproduces the issue:

UCAN = await import("https://cdn.skypack.dev/ucans")
UCAN.publicKeyBytesToDid(new Uint8Array([1, 2, 3]), "rsa")

matheus23 avatar Nov 16 '21 09:11 matheus23

Skypack transforms an import of uint8arrays into

import require$$0 from "/-/[email protected]/dist=es2019,mode=imports/optimized/uint8arrays.js";

And they transform the source uint8arrays module (dist/esm/src/index.js) into this:

export {compare} from "./uint8arrays/compare.js";
export {concat} from "./uint8arrays/concat.js";
export {equals} from "./uint8arrays/equals.js";
export {fromString} from "./uint8arrays/from-string.js";
export {toString} from "./uint8arrays/to-string.js";
export {xor} from "./uint8arrays/xor.js";
import "./common/bases-af280048.js";
import "/-/[email protected]/dist=es2019,mode=imports/optimized/multiformats/basics.js";
export default null;

I have no idea why it's export default null. The source file exports some stuff.

Not sure what we can do about this. This seems like an issue with skypack. I've submitted an issue on their repository.

matheus23 avatar Nov 16 '21 10:11 matheus23

We could make it easier for skypack by also bundling ESM, but that's just my hypothesis at this point.

matheus23 avatar Nov 16 '21 10:11 matheus23

Yeah sadly we also had not so great experience with skypack things working on one version and stopping in the other. In our case it was one of the dependencies that had issues, but sadly I don’t know of a good way to identify the problems

Gozala avatar Nov 19 '21 18:11 Gozala

From context, is this a #wontfix?

expede avatar Nov 30 '21 19:11 expede

Maybe this could be re-framed to make it possible to load this lib on observable (and other ESM native runtimes) ?

I might also give this a go if I find some time to do so

Gozala avatar Nov 30 '21 22:11 Gozala