-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Deno should support gzipped and (or) git repo dependencies fetch #3550
Comments
Gzip encoding is certainly something we should support. git repo fetch is much more questionable since it's not a browser standard. |
@ry But it's so convenient, git project does not need pack to gzip, or release anymore, just add a mod.ts in the git repo root directory. Deno just need to clone it and done just like golang. |
for the gzip file it should be great we can call the file we want : |
deno fetch will extract that gzipped mod file into cache folder, so you don't need special syntax like |
The logic of deno is : don't make |
But deno is also web compatible, es modules do not like that special syntax.
yes you can, if you have std.gz, just do And if you direct import a file inside a gzipped file
|
I think it's easier with my solution to specify which file to use when importing it avoids making unnecessary requests that make errors. Deno will actually upload the gzip file to the cache but with the syntax
See even put several libraries in the same gzip and access to each of them with yours script |
yours and mine solution are both need to cache whole gzip uncompressed content, the only diffrence is mine is standard es modules syntax |
The two solutions have a lot in common, however with your solution this requires either a special configuration of the server or making unnecessary requests. For the example of the std lib you would need an additional mod.ts to re-export all mod.ts from the subdirectories or make one gzip by subdirectory. In addition my solution would allow the developer for example to provide a gzip of a library with which they are sure it works and make in their script a: |
@ is alreay indicates version in deno, so I think # is another good choice in your solution. if you are trying fetch a vanila(a gzipped file w/o any code, or even contains malwares) gzipped file, deno should deny to fetch(actually deny to cache it after fetch, decompress and parse) it |
Yes it can be another symbol For security reasons it may be necessary to add a command to Deno: |
@CGQAQ @IllusionPerdu that could compress files transparently on the server that supports it - and GitHub does, see: $ curl -sI https://raw.githubusercontent.com/rsp/deno-clipboard/master/mod.ts \
-H 'Accept-Encoding: gzip' | egrep 'Encoding|Length'
Content-Encoding: gzip
Content-Length: 801
Vary: Authorization,Accept-Encoding vs: $ curl -sI https://raw.githubusercontent.com/rsp/deno-clipboard/master/mod.ts \
-H 'Accept-Encoding: deflate' | egrep 'Encoding|Length'
Content-Length: 2117
Vary: Authorization,Accept-Encoding GitHub seems to use gzip even when asked to use encoding with a name that only contains "gzip": $ curl -sI https://raw.githubusercontent.com/rsp/deno-clipboard/master/mod.ts -H 'Accept-Encoding: NOTgzipButMatches' | egrep 'Encoding|Length'
Content-Encoding: gzip
Content-Length: 801
Vary: Authorization,Accept-Encoding but it uses the gzip nonetheless, and it will send compressed files when deno requests them with $ nc -l 3345 & deno run <(echo 'import {} from "http://localhost:3345"')
[1] 67702
Download http://localhost:3345/
GET / HTTP/1.1
user-agent: Deno/0.25.0
accept: */*
accept-encoding: gzip
host: localhost:3345 So, since Deno already uses Now, if you want Deno to be able to use dependencies in compressed tarballs (.tar.gz, .tzg, .tar.bz2, .tbz etc.) then I'm not sure it would be worth it because you would need to download the entire project even to use a single file. The same for git repos. Cloning a repo takes much more time than fetching a single or even multiple files, and you need to clone the entire repo even if you then want to use a single or few files. Using HTTP and importing individual files gives you something like a file-level tree shaking, i.e. you download only the files that are actually needed. With a convention of using For all download performance optimizations that can be done transparently without changing the import syntax, see: Using files that are explicitly gzipped individually, something like local Using git repos in imports is something that looks nice (cute?) but in practice there are few issues:
The only upside that I see right now is being able to use dependencies in private repos using SSH but this can already be done using submodules. To sum it up. Deno already supports gzip downloads, cloning entire repos over SSH doesn't seem as the most efficient way to get individual files that are already available via HTTP, getting files from tarballs may be interesting for things like having compressed dependencies or all files bundled, like distributing two files:
and having import { main } from './main.tar.gz#main.ts';
main(); Or maybe even running it directly with Seems quite nice for the distribution of applications, actually. Now, if it only treated |
Yes, I did. I did mean package many files in one tarball |
Yes i think also the tarball (or zip file) |
My opinion... When fetching remote modules, Deno should support both gzip and brotli encoding. They are the two most common forms of encoding. As far as grouping multiple modules together, I think further enhancements to bundling are the best solution to that, where both the |
Can deno bundle arg resolve this problem? Not the gzip issue but multiple files. |
@fakoua I am not sure what you mean... |
He probably meant that deno should provide a bundle feature to create a gzipped bundle file that contains multiple ts/js modules |
He specifically said "not the gzip" issue though... so the bundle feature already does that. |
Oh! Didn't see that, sorry :) |
Deno supports downloading with HTTP gzip and brotli compression thanks to #3597. As noted previously, archiving multiple files together is orthogonal to the question of compression, so I think it might be clearest to close this issue and open a new one focused on downloading archives (or other alternatives to |
FWIK, Deno currently fetch dependencies only support download ts/js file(s) individually, it's not a good idea for middle or even large project dependencies fetch(hundreds of or even thounds of dependencies).
So I think it's a good idea to support gzipped file through
deno fetch https://foo.gz
which contains the mod.ts file in the root and (or) git repo throughdeno fetch https://foo.git
just like golanggo get
The text was updated successfully, but these errors were encountered: