Skip to content

Commit

Permalink
Other: long, @types/long and @types/node are just dependencies, see #753
Browse files Browse the repository at this point in the history


It's impossible anyway to get this right for everyone, so here's the intended setup and everything else is re-configuration.
  • Loading branch information
dcodeIO committed Apr 8, 2017
1 parent acea4d7 commit 57f1da6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 49 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,9 @@ var buffer = AwesomeMessage.encode(message).finish();
...
```

**Note:** When using [long.js](https://github.com/dcodeIO/long.js), make sure to add [@types/long](https://www.npmjs.com/package/@types/long) to your project's dependencies. Likewise, when building for node, make sure to add [@types/node](https://www.npmjs.com/package/@types/node). Alternatively, if you are not using one of these, there are two stubs available that can be referenced instead of the respective full type definition:
**Note** that the npm package depends on [@types/node](https://www.npmjs.com/package/@types/node) because of `Buffer` and [@types/long](https://www.npmjs.com/package/@types/long) because of `Long`.

If you are not building for node and/or not using long.js and want to exclude their full type definitions manually for whatever reason, there are two stubs available that can be referenced instead of the respective full type definition:

```ts
/// <reference path="./node_modules/protobufjs/stub-long.d.ts" />
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protobufjs",
"version": "6.7.2",
"version": "6.7.3",
"versionScheme": "~",
"description": "Protocol Buffers for JavaScript (& TypeScript).",
"author": "Daniel Wirtz <[email protected]>",
Expand Down Expand Up @@ -44,6 +44,7 @@
"release": "npm run make && npm run changelog"
},
"dependencies": {
"long": "^3.2.0",
"@protobufjs/aspromise": "^1.1.1",
"@protobufjs/base64": "^1.1.1",
"@protobufjs/codegen": "^1.0.8",
Expand All @@ -53,14 +54,11 @@
"@protobufjs/inquire": "^1.1.0",
"@protobufjs/path": "^1.1.2",
"@protobufjs/pool": "^1.1.0",
"@protobufjs/utf8": "^1.1.0"
},
"optionalDependencies": {
"long": "^3.2.0"
"@protobufjs/utf8": "^1.1.0",
"@types/long": "^3.0.31",
"@types/node": "7.0.12"
},
"devDependencies": {
"@types/long": "^3.0.31",
"@types/node": "7.0.12",
"benchmark": "^2.1.4",
"browserify": "^14.3.0",
"browserify-wrap": "^1.0.2",
Expand Down
40 changes: 0 additions & 40 deletions tests/data/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $root.Package = (function() {
* @property {Object.<string,string>} [bin] Package bin.
* @property {Object.<string,string>} [scripts] Package scripts.
* @property {Object.<string,string>} [dependencies] Package dependencies.
* @property {Object.<string,string>} [optionalDependencies] Package optionalDependencies.
* @property {Object.<string,string>} [devDependencies] Package devDependencies.
* @property {string} [types] Package types.
* @property {Array.<string>} [cliDependencies] Package cliDependencies.
Expand All @@ -46,7 +45,6 @@ $root.Package = (function() {
this.bin = {};
this.scripts = {};
this.dependencies = {};
this.optionalDependencies = {};
this.devDependencies = {};
this.cliDependencies = [];
if (properties)
Expand Down Expand Up @@ -139,12 +137,6 @@ $root.Package = (function() {
*/
Package.prototype.dependencies = $util.emptyObject;

/**
* Package optionalDependencies.
* @type {Object.<string,string>}
*/
Package.prototype.optionalDependencies = $util.emptyObject;

/**
* Package devDependencies.
* @type {Object.<string,string>}
Expand Down Expand Up @@ -211,9 +203,6 @@ $root.Package = (function() {
if (message.dependencies != null && message.hasOwnProperty("dependencies"))
for (var keys = Object.keys(message.dependencies), i = 0; i < keys.length; ++i)
writer.uint32(/* id 13, wireType 2 =*/106).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.dependencies[keys[i]]).ldelim();
if (message.optionalDependencies != null && message.hasOwnProperty("optionalDependencies"))
for (var keys = Object.keys(message.optionalDependencies), i = 0; i < keys.length; ++i)
writer.uint32(/* id 14, wireType 2 =*/114).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.optionalDependencies[keys[i]]).ldelim();
if (message.devDependencies != null && message.hasOwnProperty("devDependencies"))
for (var keys = Object.keys(message.devDependencies), i = 0; i < keys.length; ++i)
writer.uint32(/* id 15, wireType 2 =*/122).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.devDependencies[keys[i]]).ldelim();
Expand Down Expand Up @@ -311,14 +300,6 @@ $root.Package = (function() {
reader.pos++;
message.dependencies[key] = reader.string();
break;
case 14:
reader.skip().pos++;
if (message.optionalDependencies === $util.emptyObject)
message.optionalDependencies = {};
key = reader.string();
reader.pos++;
message.optionalDependencies[key] = reader.string();
break;
case 15:
reader.skip().pos++;
if (message.devDependencies === $util.emptyObject)
Expand Down Expand Up @@ -427,14 +408,6 @@ $root.Package = (function() {
if (!$util.isString(message.dependencies[key[i]]))
return "dependencies: string{k:string} expected";
}
if (message.optionalDependencies != null && message.hasOwnProperty("optionalDependencies")) {
if (!$util.isObject(message.optionalDependencies))
return "optionalDependencies: object expected";
var key = Object.keys(message.optionalDependencies);
for (var i = 0; i < key.length; ++i)
if (!$util.isString(message.optionalDependencies[key[i]]))
return "optionalDependencies: string{k:string} expected";
}
if (message.devDependencies != null && message.hasOwnProperty("devDependencies")) {
if (!$util.isObject(message.devDependencies))
return "devDependencies: object expected";
Expand Down Expand Up @@ -516,13 +489,6 @@ $root.Package = (function() {
for (var keys = Object.keys(object.dependencies), i = 0; i < keys.length; ++i)
message.dependencies[keys[i]] = String(object.dependencies[keys[i]]);
}
if (object.optionalDependencies) {
if (typeof object.optionalDependencies !== "object")
throw TypeError(".Package.optionalDependencies: object expected");
message.optionalDependencies = {};
for (var keys = Object.keys(object.optionalDependencies), i = 0; i < keys.length; ++i)
message.optionalDependencies[keys[i]] = String(object.optionalDependencies[keys[i]]);
}
if (object.devDependencies) {
if (typeof object.devDependencies !== "object")
throw TypeError(".Package.devDependencies: object expected");
Expand Down Expand Up @@ -569,7 +535,6 @@ $root.Package = (function() {
object.bin = {};
object.scripts = {};
object.dependencies = {};
object.optionalDependencies = {};
object.devDependencies = {};
}
if (options.defaults) {
Expand Down Expand Up @@ -624,11 +589,6 @@ $root.Package = (function() {
for (var j = 0; j < keys2.length; ++j)
object.dependencies[keys2[j]] = message.dependencies[keys2[j]];
}
if (message.optionalDependencies && (keys2 = Object.keys(message.optionalDependencies)).length) {
object.optionalDependencies = {};
for (var j = 0; j < keys2.length; ++j)
object.optionalDependencies[keys2[j]] = message.optionalDependencies[keys2[j]];
}
if (message.devDependencies && (keys2 = Object.keys(message.devDependencies)).length) {
object.devDependencies = {};
for (var j = 0; j < keys2.length; ++j)
Expand Down
2 changes: 1 addition & 1 deletion tests/data/package.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ message Package {
map<string, string> bin = 11;
map<string, string> scripts = 12;
map<string, string> dependencies = 13;
map<string, string> optionalDependencies = 14;
// map<string, string> optionalDependencies = 14;
map<string, string> devDependencies = 15;
// map<string, bool> browser = 16;
string types = 17;
Expand Down

0 comments on commit 57f1da6

Please sign in to comment.