Skip to content

Commit

Permalink
Notes on descriptors vs static modules [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 13, 2016
1 parent 3783af7 commit d31590b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions cli/pbts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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._;
Expand Down Expand Up @@ -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"),
""
];
Expand Down
4 changes: 2 additions & 2 deletions types/protobuf.js.d.ts
Original file line number Diff line number Diff line change
@@ -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" {

Expand Down

0 comments on commit d31590b

Please sign in to comment.