@bufbuild/protoc-gen-es 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,38 +1,11 @@
1
1
  # @bufbuild/protoc-gen-es
2
2
 
3
- The code generator for Protocol Buffers for ECMAScript. For example, the
4
- following definition:
5
-
6
- ```protobuf
7
- message Person {
8
- string name = 1;
9
- int32 id = 2; // Unique ID number for this person.
10
- string email = 3;
11
- }
12
- ```
13
-
14
- Is compiled to an ECMAScript class that can be used like this:
15
-
16
- ```typescript
17
- let pete = new Person({
18
- name: "pete",
19
- id: 123
20
- });
21
-
22
- let bytes = pete.toBinary();
23
- pete = Person.fromBinary(bytes);
24
- pete = Person.fromJsonString('{"name": "pete", "id": 123}');
25
- ```
26
-
27
- Learn more about the project at [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
28
-
3
+ The code generator plugin for Protocol Buffers for ECMAScript. Learn more about the project at [github.com/bufbuild/protobuf-es](https://github.com/bufbuild/protobuf-es).
29
4
 
30
5
  ## Installation
31
6
 
32
- `protoc-gen-es` is a code generator plugin for Protocol Buffer compilers,
33
- like [buf](https://github.com/bufbuild/buf) and [protoc](https://github.com/protocolbuffers/protobuf/releases).
34
- It generates base types - messages and enumerations - from your Protocol Buffer
35
- schema. The generated code requires the runtime library [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/protobuf).
7
+ `protoc-gen-es` generates base types - messages and enumerations - from your Protocol Buffer
8
+ schema. The generated code requires the runtime library [@bufbuild/protobuf](https://www.npmjs.com/package/@bufbuild/protobuf). It is compatible with Protocol Buffer compilers like [buf](https://github.com/bufbuild/buf) and [protoc](https://github.com/protocolbuffers/protobuf/releases).
36
9
 
37
10
  To install the plugin and the runtime library, run:
38
11
 
@@ -121,14 +94,29 @@ Multiple values can be given by separating them with `+`, for example
121
94
  `target=js+dts`.
122
95
 
123
96
  By default, we generate JavaScript and TypeScript declaration files, which
124
- produces the smallest code size. If you prefer to generate TypeScript, use
125
- `target=ts`.
97
+ produces the smallest code size and is the most compatible with various
98
+ bundler configurations. If you prefer to generate TypeScript, use `target=ts`.
99
+
100
+ ### `import_extension=.js`
101
+
102
+ By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
103
+ (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
104
+ uses a `.js` file extensions in import paths, even in TypeScript files.
105
+
106
+ This is unintuitive, but necessary for [ECMAScript modules in Node.js](https://www.typescriptlang.org/docs/handbook/esm-node.html).
107
+ Unfortunately, not all bundlers and tools have caught up yet, and Deno
108
+ requires `.ts`. With this plugin option, you can replace `.js` extensions
109
+ in import paths with the given value. For example, set
110
+
111
+ - `import_extension=none` to remove the `.js` extension
112
+ - `import_extension=.ts` to replace the `.js` extension with `.ts`
113
+
126
114
 
127
115
  ### `keep_empty_files=true`
128
116
 
129
- By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
130
- (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
131
- omit empty files from the plugin output. This option disables pruning of
132
- empty files, to allow for smooth interoperation with Bazel and similar
117
+ By default, [protoc-gen-es](https://www.npmjs.com/package/@bufbuild/protoc-gen-es)
118
+ (and all other plugins based on [@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
119
+ omit empty files from the plugin output. This option disables pruning of
120
+ empty files, to allow for smooth interoperation with Bazel and similar
133
121
  tooling that requires all output files to be declared ahead of time.
134
122
  Unless you use Bazel, it is very unlikely that you need this option.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Protocol Buffers code generator for ECMAScript",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  },
21
21
  "preferUnplugged": true,
22
22
  "dependencies": {
23
- "@bufbuild/protoplugin": "0.3.0"
23
+ "@bufbuild/protoplugin": "0.5.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bufbuild/protobuf": "0.3.0"
26
+ "@bufbuild/protobuf": "0.5.0"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@bufbuild/protobuf": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bufbuild/protoc-gen-es",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Protocol Buffers code generator for ECMAScript",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  },
21
21
  "preferUnplugged": true,
22
22
  "dependencies": {
23
- "@bufbuild/protoplugin": "0.3.0"
23
+ "@bufbuild/protoplugin": "0.5.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bufbuild/protobuf": "0.3.0"
26
+ "@bufbuild/protobuf": "0.5.0"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "@bufbuild/protobuf": {