You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| full | 18.5kb | [dist][dist-full] | `require("protobufjs")` | All features. Works with everything.
78
78
| light | 15.5kb | [dist/light][dist-light] | `require("protobufjs/light")` | All features except tokenizer, parser and bundled common types. Works with JSON definitions, pure reflection and static code.
79
79
| minimal | 6.0kb+ | [dist/minimal][dist-minimal] | `require("protobufjs/minimal")` | Just enough to run static code. No reflection.
80
80
81
81
In case of doubt you can just use the full library.
To achieve the same with static code generated by [pbjs](https://github.com/dcodeIO/protobuf.js#command-line), there is the [pbts](https://github.com/dcodeIO/protobuf.js#generating-typescript-definitions-from-static-modules) command line utility to generate type definitions from static code as well.
309
+
To achieve the same with static code generated by [pbjs](#command-line), there is the [pbts](#generating-typescript-definitions-from-static-modules) command line utility to generate type definitions from static code as well.
306
310
307
311
Let's say you generated your static code to `bundle.js` and its type definitions to `bundle.d.ts`, then you can do:
308
312
@@ -358,13 +362,15 @@ Consolidates imports and converts between file formats.
358
362
default Default wrapper supporting both CommonJS and AMD
359
363
commonjs CommonJS wrapper
360
364
amd AMD wrapper
361
-
es6 ES6 wrapper
365
+
es6 ES6 wrapper (implies --es6)
362
366
363
367
-r, --root Specifies an alternative protobuf.roots name.
364
368
365
369
-l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:
will generate static code for definitions within `file1.proto` and `file2.proto` to a CommonJS module `compiled.js`, which then can be used with just the [minimal library][dist-minimal].
419
+
will generate static code for definitions within `file1.proto` and `file2.proto` to a CommonJS module `compiled.js`, which then can be used with just the [minimal library](#distributions).
414
420
415
421
**ProTip!** Documenting your .proto files with `/** ... */`-blocks or (trailing) `/// ...` lines translates to generated static code.
416
422
@@ -421,16 +427,18 @@ Likewise, the `pbts` command line utility can be used to generate TypeScript def
421
427
```
422
428
Generates TypeScript definitions from annotated JavaScript files.
423
429
424
-
-n, --name Wraps everything in a module of the specified name.
425
-
426
430
-o, --out Saves to a file instead of writing to stdout.
427
431
428
-
-m, --main Whether building the main library without any imports.
429
-
430
432
-g, --global Name of the global object in browser environments, if any.
431
433
432
434
--no-comments Does not output any JSDoc comments.
433
435
436
+
Internal flags:
437
+
438
+
-n, --name Wraps everything in a module of the specified name.
439
+
440
+
-m, --main Whether building the main library without any imports.
While using .proto files directly requires the [full library][dist-full] respectively pure reflection/JSON the [light library][dist-light], pretty much all code but the relatively short descriptors is shared.
466
+
While using .proto files directly requires the [full library](#distributions) respectively pure reflection/JSON the [light library](#distributions), pretty much all code but the relatively short descriptors is shared.
459
467
460
-
Static code, on the other hand, requires just the [minimal library][dist-minimal], but generates additional, albeit editable, source code without any reflection features.
468
+
Static code, on the other hand, requires just the [minimal library](#distributions), but generates additional, albeit editable, source code without any reflection features.
461
469
462
470
There is no significant difference performance-wise as the code generated statically is pretty much the same as generated at runtime and both are largely interchangeable as seen in the previous section.
463
471
@@ -590,11 +598,17 @@ $> npm run types
590
598
591
599
By default, protobuf.js integrates into your browserify build-process without requiring any optional modules. Hence:
592
600
593
-
* If you need int64 support, explicitly require the `long` module somewhere in your project. It will be excluded otherwise.
594
-
* If you have any special requirements, there is [the bundler](https://github.com/dcodeIO/protobuf.js/blob/master/scripts/bundle.js) as a reference.
601
+
* If you need int64 support, explicitly require the `long` module somewhere in your project as it will be excluded otherwise. This assumes that a global `require` function is present that protobuf.js can call to obtain the long module.
* If you have any special requirements, there is [the bundler](https://github.com/dcodeIO/protobuf.js/blob/master/scripts/bundle.js) for reference.
0 commit comments