#deno #esm #javascript #typescript #zip

eszip

A utility that can download JavaScript and TypeScript module graphs and store them locally in a special zip file

34 releases (20 breaking)

Uses new Rust 2021

0.21.0 Jun 21, 2022
0.19.0 Apr 8, 2022
0.18.0 Mar 21, 2022
0.14.1 Nov 3, 2021
0.7.0 Mar 31, 2021

#3 in #deno

Download history 1825/week @ 2022-03-09 1921/week @ 2022-03-16 1753/week @ 2022-03-23 1373/week @ 2022-03-30 1255/week @ 2022-04-06 1633/week @ 2022-04-13 1647/week @ 2022-04-20 1416/week @ 2022-04-27 1499/week @ 2022-05-04 2117/week @ 2022-05-11 1338/week @ 2022-05-18 1433/week @ 2022-05-25 1262/week @ 2022-06-01 1146/week @ 2022-06-08 1182/week @ 2022-06-15 1050/week @ 2022-06-22

4,801 downloads per month
Used in 3 crates (2 directly)

MIT license

125KB
1K SLoC

eszip

The eszip format lets you losslessly serialize an ECMAScript module graph (represented by deno_graph::ModuleGraph) into a single compact file.

The eszip file format is designed to be compact and streaming capable. This allows for efficient loading of large ECMAScript module graphs.

Examples

Creating an eszip

cargo run --example eszip_builder https://deno.land/std/http/file_server.ts file_server.eszip2

Viewing the contents of an eszip

cargo run --example eszip_viewer file_server.eszip2

Loading the eszip into V8

cargo run --example eszip_load file_server.eszip2 https://deno.land/std/http/file_server.ts

File format

The file format looks as follows:

Eszip:
| Magic (8) | Header size (4) | Header (n) | Header hash (32) | Sources size (4) | Sources (n) | SourceMaps size (4) | SourceMaps (n) |

Header:
( | Specifier size (4) | Specifier (n) | Entry type (1) | Entry (n) | )*

Entry (redirect):
| Specifier size (4) | Specifier (n) |

Entry (module):
| Source offset (4) | Source size (4) | SourceMap offset (4) | SourceMap size (4) | Module type (1) |

Sources:
( | Source (n) | Hash (32) | )*

SourceMaps:
( | SourceMap (n) | Hash (32) | )*

There is one optimization for empty source / source map entries. If both the offset and size are set to 0, no entry and no hash is present in the data sections for that module.

Development

When opening a PR make sure to rebuild Wasm by running:

deno task build

Dependencies

~19–27MB
~609K SLoC