Skip to content

Commit

Permalink
Provide prebuilt browser versions of the static runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 13, 2016
1 parent e3e77d0 commit a54fbc9
Show file tree
Hide file tree
Showing 12 changed files with 2,103 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -340,9 +340,9 @@ protobuf.load("bundle.json", function(err, root) {

While .proto and JSON files require the full library (about 20kb gzipped), pretty much all code but the relatively short descriptors is shared.

Static code, on the other hand, requires just the runtime library (final size TBA), but generates relatively large code bases without any reflection features.
Static code, on the other hand, requires just the runtime library (about 5kb gzipped), but generates relatively large code bases without any reflection features.

There is no difference performance-wise as the code that is generated statically is the same generated at runtime.
When `new Function` is supported (and it usually is), there is no difference performance-wise as the code generated statically is the same generated at runtime.

### Generating TypeScript definitions from static modules

Expand Down
33 changes: 33 additions & 0 deletions dist/runtime/README.md
@@ -0,0 +1,33 @@
This folder contains prebuilt browser versions of [protobuf.js](https://github.com/dcodeIO/protobuf.js)'s runtime for statically generated code. When sending pull requests, it is not required to update these.

**NOTE:** The static code runtime includes just the bare minimum required to work with statically generated modules - and *nothing else*. Where applicable, it can be used as a drop-in replacement for the full library as it has the same general structure.

Prebuilt files are in source control to enable pain-free frontend respectively CDN usage:

CDN usage
---------

Development:
```
<script src="//cdn.rawgit.com/dcodeIO/protobuf.js/6.1.0/dist/runtime/protobuf.js"></script>
```

Production:
```
<script src="//cdn.rawgit.com/dcodeIO/protobuf.js/6.1.0/dist/runtime/protobuf.min.js"></script>
```

**NOTE:** Remember to replace the version tag with the exact [release](https://github.com/dcodeIO/protobuf.js/releases) your project depends upon.

Frontend usage
--------------

Development:
```
<script src="node_modules/protobufjs/dist/runtime/protobuf.js"></script>
```

Production:
```
<script src="node_modules/protobufjs/dist/runtime/protobuf.min.js"></script>
```

0 comments on commit a54fbc9

Please sign in to comment.