Skip to content
File

Blob: src/workerd/jsg/modules.capnp

1.0 KB
1@0xc8cbb234694939d5;
2 
3using Cxx = import "/capnp/c++.capnp";
4$Cxx.namespace("workerd::jsg");
5 
6struct Bundle {
7 # Group of modules to be loaded together.
8 # Bundles are currently generated during compilation process and linked with the workerd,
9 # but loading bundles from somewhere else will also be possible.
10 modules @0 :List(Module);
11}
12 
13struct Module {
14 # Javascript module with its source code.
15 
16 name @0 :Text;
17 union {
18 src @1 :Data; # JS / TS code
19 wasm @4 :Data; # Wasm module
20 data @5 :Data; # Binary data module
21 json @6 :Text; # Json module
22 }
23 tsDeclaration @3 :Text;
24 
25 type @2 :ModuleType;
26 
27 # Optional compile cache to be used to speed up module loading
28 compileCache @7 :Data;
29}
30 
31 
32enum ModuleType {
33 bundle @0;
34 # Provided by the worker bundle. TODO: rename this to e.g., user?
35 
36 builtin @1;
37 # Provided by the runtime and can be imported by the worker bundle.
38 # Can be overridden by modules in the worker bundle.
39 
40 internal @2;
41 # Provided by runtime but can only imported by builtin modules.
42}