Permalink
Browse files

Notes on descriptors vs static modules [ci skip]

  • Loading branch information...
dcodeIO committed Dec 13, 2016
1 parent 3783af7 commit d31590b82d8bafe6657bf877d403f01a034ab4ba
Showing with 12 additions and 5 deletions.
  1. +7 −1 README.md
  2. +3 −2 cli/pbts.js
  3. +2 −2 types/protobuf.js.d.ts
@@ -336,7 +336,13 @@ protobuf.load("bundle.json", function(err, root) {
});
```
#### Generating TypeScript definitions for static modules
### Descriptors vs. static modules
While .proto and JSON files require the full library (about 20kb gzipped), pretty much all code but the relatively short descriptors is shared.
Static code, on the other hand, requires just the runtime library (final size TBA), but generates relatively large code bases without any reflection features.
### Generating TypeScript definitions from static modules
Likewise, the `pbts` command line utility can be used to generate TypeScript definitions from `pbjs`-generated static modules.
@@ -16,9 +16,10 @@ var protobuf = require("..");
exports.main = function(args) {
var argv = minimist(args.slice(2), {
alias: {
name: "n",
out : "o"
},
string: [ "out" ]
string: [ "name", "out" ]
});
var files = argv._;
@@ -65,7 +66,7 @@ exports.main = function(args) {
fs.unlinkSync(path.join(dir, "types.d.ts"));
var header = [
"// pbts " + process.argv.slice(2).join(' '),
"// $> pbts " + process.argv.slice(2).join(' '),
"// Generated " + (new Date()).toUTCString().replace(/GMT/, "UTC"),
""
];
@@ -1,5 +1,5 @@
// pbts --name protobufjs --out types/protobuf.js.d.ts ./src
// Generated Tue, 13 Dec 2016 12:42:40 UTC
// $> pbts --name protobufjs --out types/protobuf.js.d.ts ./src
// Generated Tue, 13 Dec 2016 12:45:34 UTC
declare module "protobufjs" {

0 comments on commit d31590b

Please sign in to comment.