Skip to content

Commit 0ae6675

Browse files
committed
Be nice to AMD, allow reconfiguration of Reader/Writer interface
1 parent 4885b82 commit 0ae6675

10 files changed

+254
-126
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ protobuf.js [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [
1414

1515
Features
1616
--------
17-
* Rapid [runtime code generation](#performance)
17+
* Lightning fast through [runtime code generation](#performance)
1818
* Exhaustive [browser support](#compatibility)
1919
* Managed [TypeScript support](#usage-with-typescript)
20-
* Elaborate [documentation](#documentation)
20+
* Elaborate [API documentation](#documentation)
2121
* Convenient [CLI utilities](#command-line)
2222
* Seamless [browserify integration](#browserify-integration)
2323

@@ -294,13 +294,15 @@ The `pbjs` command line utility can be used to bundle and translate between .pro
294294
```
295295
Consolidates imports and converts between file formats.
296296
297-
-t, --target Specifies the target format. [json, proto2, proto3]
297+
-t, --target Specifies the target format. [json, proto2, proto3, static]
298298
Also accepts a path to require a custom target.
299299
300300
-p, --path Adds a directory to the include path.
301301
302302
-o, --out Saves to a file instead of writing to stdout.
303303
304+
-w, --wrap Specifies an alternative wrapper for the static target.
305+
304306
usage: pbjs [options] file1.proto file2.json ...
305307
```
306308

@@ -356,7 +358,7 @@ $> npm run types
356358

357359
### Browserify integration
358360

359-
protobuf.js integrates seamlessly into your browserify build-process. There are a few optional tweaks, though:
361+
protobuf.js integrates nicely into your browserify build-process. There are a few possible tweaks, though:
360362

361363
* If performance is a concern or IE8 support is required, you should make sure to exclude the browserified `buffer` module and let protobuf.js do its thing with Uint8Array/Array instead.
362364
* If you do not need int64 support, you can exclude the `long` module.

dist/protobuf.js

+111-58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/protobuf.min.js.gz

97 Bytes
Binary file not shown.

dist/protobuf.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,16 @@ protobuf.inherits = require("./inherits");
5555
protobuf.types = require("./types");
5656
protobuf.common = require("./common");
5757
protobuf.util = util;
58+
59+
// Be nice to AMD
60+
/* eslint-disable no-undef */
61+
if (typeof define === 'function' && define.amd)
62+
define(["long"], function(Long) {
63+
if (Long) {
64+
protobuf.util.Long = Long;
65+
protobuf.Reader.configure();
66+
protobuf.Writer.configure();
67+
}
68+
return protobuf;
69+
});
70+
/* eslint-enable no-undef */

0 commit comments

Comments
 (0)