Skip to content

Commit d31590b

Browse files
committed
Notes on descriptors vs static modules [ci skip]
1 parent 3783af7 commit d31590b

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,13 @@ protobuf.load("bundle.json", function(err, root) {
336336
});
337337
```
338338

339-
#### Generating TypeScript definitions for static modules
339+
### Descriptors vs. static modules
340+
341+
While .proto and JSON files require the full library (about 20kb gzipped), pretty much all code but the relatively short descriptors is shared.
342+
343+
Static code, on the other hand, requires just the runtime library (final size TBA), but generates relatively large code bases without any reflection features.
344+
345+
### Generating TypeScript definitions from static modules
340346

341347
Likewise, the `pbts` command line utility can be used to generate TypeScript definitions from `pbjs`-generated static modules.
342348

cli/pbts.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ var protobuf = require("..");
1616
exports.main = function(args) {
1717
var argv = minimist(args.slice(2), {
1818
alias: {
19+
name: "n",
1920
out : "o"
2021
},
21-
string: [ "out" ]
22+
string: [ "name", "out" ]
2223
});
2324

2425
var files = argv._;
@@ -65,7 +66,7 @@ exports.main = function(args) {
6566
fs.unlinkSync(path.join(dir, "types.d.ts"));
6667

6768
var header = [
68-
"// pbts " + process.argv.slice(2).join(' '),
69+
"// $> pbts " + process.argv.slice(2).join(' '),
6970
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
7071
""
7172
];

types/protobuf.js.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// pbts --name protobufjs --out types/protobuf.js.d.ts ./src
2-
// Generated Tue, 13 Dec 2016 12:42:40 UTC
1+
// $> pbts --name protobufjs --out types/protobuf.js.d.ts ./src
2+
// Generated Tue, 13 Dec 2016 12:45:34 UTC
33

44
declare module "protobufjs" {
55

0 commit comments

Comments
 (0)