Skip to content

Commit 2061eb7

Browse files
authored
Closes #210: Add minified option (#235)
* Add rollup-plugin-terser option * Do not minify function names * Fix formatting * update README Co-authored-by: Oleksandr Paraska <[email protected]>
1 parent 08b48f2 commit 2061eb7

File tree

4 files changed

+133
-3
lines changed

4 files changed

+133
-3
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ yarn add @openmined/syft.js @tensorflow/tfjs-core
4747
```
4848

4949
If you're not using a package manager, you will be able to include Syft.js within a `<script>` tag.
50-
In this case library classes will be available under `syft` global object.
50+
In this case [library classes](API-REFERENCE.md) will be available under `syft` global object.
5151

5252
```html
5353
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
54-
<script src="https://cdn.jsdelivr.net/npm/@openmined/syft.js@latest/dist/index.js"></script>
54+
<script src="https://cdn.jsdelivr.net/npm/@openmined/syft.js@latest/dist/index.min.js"></script>
5555

5656
<script type="text/javascript">
5757
// Create syft worker

package-lock.json

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

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "A Javascript Syft worker in the browser",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.esm.js",
7-
"browser": "dist/index.js",
7+
"browser": "dist/index.min.js",
8+
"browserFull": "dist/index.js",
89
"files": [
910
"dist/*",
1011
"*.md"
@@ -99,6 +100,7 @@
99100
"rollup": "^2.22.2",
100101
"rollup-plugin-filesize": "^9.0.2",
101102
"rollup-plugin-peer-deps-external": "^2.2.3",
103+
"rollup-plugin-terser": "7.0.2",
102104
"syft-proto": "github:openmined/syft-proto#v0.4.9"
103105
}
104106
}

rollup.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
44
import resolve from '@rollup/plugin-node-resolve';
55
import commonjs from '@rollup/plugin-commonjs';
66
import filesize from 'rollup-plugin-filesize';
7+
import { terser } from 'rollup-plugin-terser';
78

89
import pkg from './package.json';
910

@@ -23,6 +24,14 @@ export default {
2324
file: pkg.browser,
2425
format: 'umd',
2526
...sharedOutput,
27+
// We need `keep_fnames` to not brake tensor deserialization
28+
// See: https://github.com/OpenMined/syft.js/issues/210
29+
plugins: [terser({ keep_fnames: true })],
30+
},
31+
{
32+
file: pkg.browserFull,
33+
format: 'umd',
34+
...sharedOutput,
2635
},
2736
{
2837
file: pkg.main,

0 commit comments

Comments
 (0)