#deno #esm #javascript #typescript #v8 #serialization #compact

eszip

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

53 releases (breaking)

new 0.38.2 Mar 31, 2023
0.37.0 Feb 22, 2023
0.31.0 Dec 6, 2022
0.30.0 Nov 10, 2022
0.7.0 Mar 31, 2021

#67 in Parser implementations

Download history 1399/week @ 2022-12-09 1445/week @ 2022-12-16 845/week @ 2022-12-23 943/week @ 2022-12-30 1380/week @ 2023-01-06 1209/week @ 2023-01-13 1206/week @ 2023-01-20 994/week @ 2023-01-27 1092/week @ 2023-02-03 1637/week @ 2023-02-10 1501/week @ 2023-02-17 1156/week @ 2023-02-24 1141/week @ 2023-03-03 1373/week @ 2023-03-10 1158/week @ 2023-03-17 1248/week @ 2023-03-24

5,077 downloads per month
Used in 9 crates (7 directly)

MIT license

145KB
1.5K 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.

https://eszip-viewer.deno.dev/ is a tool for inspecting eszip files.

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

~12–18MB
~385K SLoC