Skip to content

Commit 8e66a7d

Browse files
author
Nikhil Thorat
authored
Add an es6 build, synchronize rollup settings between repos. (#20)
1 parent b00dcd6 commit 8e66a7d

11 files changed

Lines changed: 241 additions & 1515 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
node_modules
2+
dist/
3+
dist-es6/
4+
25
**/*/node_modules
36
**/*/coverage
4-
**/*/dist
57
**/*/.cache
68
**/*/yarn-error.log
9+
10+
.rpt2_cache/

mobilenet/package.json

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
{
22
"name": "@tensorflow-models/mobilenet",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pretrained MobileNet in TensorFlow.js",
55
"main": "dist/index.js",
6-
"unpkg": "dist/bundle.js",
6+
"unpkg": "dist/mobilenet.min.js",
7+
"jsdelivr": "dist/mobilenet.min.js",
8+
"jsnext:main": "dist-es6/index.js",
9+
"module": "dist-es6/index.js",
710
"types": "dist/index.d.ts",
811
"repository": {
912
"type": "git",
1013
"url": "https://github.com/tensorflow/tfjs-models.git"
1114
},
1215
"peerDependencies": {
13-
"@tensorflow/tfjs": "0.10.3"
16+
"@tensorflow/tfjs": "0.11.1"
1417
},
1518
"devDependencies": {
16-
"@tensorflow/tfjs": "0.10.3",
19+
"@tensorflow/tfjs": "0.11.1",
1720
"babel-core": "^6.26.0",
1821
"babel-plugin-transform-runtime": "~6.23.0",
19-
"browserify": "~14.5.0",
20-
"browserify-shim": "~3.8.14",
21-
"tsify": "~3.0.3",
22+
"rimraf": "~2.6.2",
23+
"rollup": "~0.58.2",
24+
"rollup-plugin-node-resolve": "~3.3.0",
25+
"rollup-plugin-typescript2": "~0.13.0",
2226
"tslint": "~5.8.0",
2327
"typescript": "2.7.2",
24-
"uglifyjs": "~2.4.11",
25-
"watchify": "~3.11.0"
28+
"uglify-js": "~3.0.28"
2629
},
2730
"scripts": {
28-
"build": "tsc --sourceMap false && browserify -g browserify-shim --standalone mobilenet index.ts -p [tsify] -o dist/bundle.js",
31+
"build": "rimraf dist dist-es6 && tsc --project tsconfig-es5.json && tsc && rollup -c && uglifyjs dist/mobilenet.js -c -m -o dist/mobilenet.min.js",
2932
"test": "karma start",
3033
"publish-npm": "yarn build && npm publish",
3134
"dev": "npm run watch && cs demos && npm run watch",
3235
"lint": "tslint -p . -t verbose"
3336
},
34-
"browserify-shim": {
35-
"@tensorflow/tfjs": "global:tf"
36-
},
37-
"browserify": {
38-
"global-transform": [
39-
"browserify-shim"
40-
]
41-
},
4237
"license": "Apache-2.0"
4338
}

mobilenet/rollup.config.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright 2018 Google Inc. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licnses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
18+
import node from 'rollup-plugin-node-resolve';
19+
import typescript from 'rollup-plugin-typescript2';
20+
21+
export default {
22+
input: 'index.ts',
23+
plugins: [
24+
typescript(),
25+
node()
26+
],
27+
external: [
28+
'@tensorflow/tfjs'
29+
],
30+
output: {
31+
banner: `// @tensorflow/tfjs-models Copyright ${(new Date).getFullYear()} Google`,
32+
file: 'dist/mobilenet.js',
33+
format: 'umd',
34+
name: 'mobilenet',
35+
globals: {
36+
'@tensorflow/tfjs': 'tf'
37+
}
38+
}
39+
};

mobilenet/tsconfig-es5.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./dist"
6+
}
7+
}

mobilenet/tsconfig.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
3+
"module": "ES2015",
4+
"moduleResolution": "node",
45
"noImplicitAny": true,
56
"sourceMap": true,
67
"removeComments": true,
78
"preserveConstEnums": true,
89
"declaration": true,
910
"target": "es5",
1011
"lib": ["es2015", "dom"],
11-
"outDir": "./dist",
12+
"outDir": "./dist-es6",
1213
"noUnusedLocals": true,
1314
"noImplicitReturns": true,
1415
"noImplicitThis": true,
@@ -20,6 +21,10 @@
2021
"experimentalDecorators": true
2122
},
2223
"include": [
23-
"index.ts", "imagenet_classes.ts"
24+
"./"
25+
],
26+
"exclude": [
27+
"node_modules/",
28+
"dist/"
2429
]
2530
}

0 commit comments

Comments
 (0)