-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: esm.sh
support, add Fresh example
#5
Conversation
esm.sh uses the User-Agent to determine the required target. Let's emulate deno's User-Agent to ensure that we get the same sources that deno receives, and the hashes align.
Ah, looks like Deno preserves the headers in the |
Hey, thanks for contributing so early! I quite naively assumed that esm.sh dependencies would work the same as deno.land 😅 |
I can get We can call fetchurl twice, once for the header and once for the body. A better option would do just one HTTP request. Maybe that would be a custom fetcher perhaps using deno internals for robustness? Maybe getting a patch into nixpkgs' I'll think on it and make another attempt when I'm back at the keyboard. |
Here's hoping that only the directory itself needs the `content-type` header, and deno will infer the other ones from file endings.
I think we're possibly pretty stuck here, if we want to solve this cleanly. 😓
Storing the header data would change the output, so the sha256sum in We could make a special exception for esm.sh since it's so widely used in the Deno ecosystem, and try to assume response types in some cases. I've pushed some changes onto this branch to play around with this, the basic
😅 Edit: I think I'm making progress with a similar strategy of assuming content-type from the file extensions, Fresh still isn't building because of other dependencies (esbuild), but I think I'm getting there. |
in `mkDenoDerivation`
Using nvfetcher to manage the multiple binary prefetch steps more easily
Fresh doesn't keep these deps in the lockfile when we're just running `deno cache **/*.ts --lock-write`, so I ran the build once, and added what failed. Not ideal, but maybe this will finally pass CI.
We have a successful build! 🎉 I hope that if Fresh manages to build with its relative complexity, that it's good enough for 99% of cases. 🤞 |
esm.sh
support, add Fresh example
skypack, crux.land, etc. need the same assumptions. deno.land works without them, but it shouldn't hurt.
This is awesome! You're so fast! I've got some ideas to improve packaging Fresh, but I'll open a separate issue. EDIT: Never mind, looks like #9 addresses them. Cheers! |
Glad it seems to work for you. 😄
Please do open that issue, I'd love to get input to make these builders as useful as possible! I'm looking at the nixpkgs NPM/Rust/Flutter builders for inspiration, in addition to Deno specific stuff like the bin wrappers: nix-deno/nix/hooks/deno-install-hook.sh Lines 13 to 21 in bb2771a
|
esm.sh uses the User-Agent to determine the required target. Let's emulate deno's User-Agent to ensure that we get the same sources that deno receives, and the hashes align.
I'm trying to package an app that uses
fresh
and relies quite heavily on esm.sh.This PR fixes the hash mismatch, but another error pops up that I can't intuit how to resolve. Any ideas?
As a side-note, the timing of this repo couldn't have been better, I was banging my head agains the wall a few days ago trying to get
deno2nix
to work. I really appreciate it, glad to help out in any way possible. 😁