aboutsummaryrefslogtreecommitdiff
path: root/src/api/bundle_v2.peechy
blob: db83d257b90644b08317c743629a32d734c81039 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
struct Export {
    uint32 part_id;
    StringPointer name;
}


struct JavascriptBundledPart {
    StringPointer code;

    uint32 dependencies_offset;
    uint32 dependencies_length;

    uint32 exports_offset;
    uint32 exports_length;

    uint32 from_module;

    // The ESM export is this id ("$" + number.toString(16))
    uint32 id;
}

struct JavascriptBundledModule {
  // package-relative path including file extension
  StringPointer path;

  uint32 parts_offset;
  uint32 parts_length;

  uint32 exports_offset;
  uint32 exports_length;

  // index into JavascriptBundle.packages
  uint32 package_id;

  // This lets us efficiently compare strings ignoring the extension
  byte path_extname_length;
}

struct JavascriptBundledPackage {
  StringPointer name;
  StringPointer version;
  uint32 hash;

  uint32 modules_offset;
  uint32 modules_length;
}

struct JavascriptBundle {
  // These are sorted alphabetically so you can do binary search
  JavascriptBundledModule[] modules;
  JavascriptBundledPackage[] packages;
  
  // This is ASCII-encoded so you can send it directly over HTTP
  byte[] etag;

  uint32 generated_at;

  byte[] import_from_name;

  // This is what StringPointer refers to 
  byte[] manifest_string;
}

message JavascriptBundleContainer {
  uint32 bundle_format_version = 1;

  // These go first so if we change JavaScriptBundle we can still read these
  LoadedRouteConfig routes = 3;
  LoadedFramework framework = 2;

  JavascriptBundle bundle = 4;

  // Don't technically need to store this, but it may be helpful as a sanity check
  uint32 code_length = 5;
}