Skip to content

support for generating es6 imports and .d.ts files #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.1
7.2.1
41 changes: 41 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generation

To build example output:

```
bazel build generator:protoc-gen-js
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=es6,generate_dts,binary:. protos/test.proto
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=es6,generate_dts,binary:. protos/test2.proto
```

Generates all of:
* `example/test.js`
* `example/test2.js`
* `example/test.d.ts`
* `example/test2.d.ts`

The `*.js` files are generated with ES6-style imports/exports. The `*.d.ts` files have TypeScript definitions for their respective `.js` files. The `test2.*` files demonstrate dependency between generated files.

To regression test Closure output:

```
git checkout origin/main
bazel build generator:protoc-gen-js
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=closure,binary:. protos/test.proto
mv example/test.js example-test.js
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=closure,binary:. protos/test2.proto
mv example/test2.js example-test2.js
rmdir example

git checkout lukfugl/es6
bazel build generator:protoc-gen-js
mv example-test.js example/test.closure-old.js
mv example-test2.js example/test2.closure-old.js
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=closure,binary:. protos/test.proto
mv example/test.js example/test.closure-new.js
protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=closure,binary:. protos/test2.proto
mv example/test2.js example/test2.closure-new.js

diff example/test.closure-* > example/test.closure.diff # empty
diff example/test2.closure-* > example/test2.closure.diff # empty
```
Loading