Skip to content

Commit 62f4f9c

Browse files
authored
Fix speech command npm error (#595)
* fix sec vulnerability for bodypix * fix speech command minimized build error
1 parent 3fb270b commit 62f4f9c

File tree

4 files changed

+111
-354
lines changed

4 files changed

+111
-354
lines changed

speech-commands/package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorflow-models/speech-commands",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "Speech-command recognizer in TensorFlow.js",
55
"main": "dist/index.js",
66
"unpkg": "dist/speech-commands.min.js",
@@ -22,9 +22,6 @@
2222
"@tensorflow/tfjs-data": "^3.0.0",
2323
"@tensorflow/tfjs-layers": "^3.0.0",
2424
"@tensorflow/tfjs-node": "^3.0.0",
25-
"@rollup/plugin-commonjs": "^11.0.2",
26-
"@rollup/plugin-node-resolve": "^7.1.1",
27-
"@rollup/plugin-typescript": "^3.0.0",
2825
"@types/jasmine": "~2.8.8",
2926
"@types/rimraf": "^2.0.2",
3027
"@types/tempfile": "^2.0.0",
@@ -36,9 +33,10 @@
3633
"jasmine-core": "^3.2.1",
3734
"kissfft-js": "^0.1.8",
3835
"rimraf": "2.6.2",
39-
"rollup": "~2.3.2",
40-
"rollup-plugin-terser": "~5.3.0",
41-
"rollup-plugin-visualizer": "~3.3.2",
36+
"rollup": "~0.58.2",
37+
"rollup-plugin-node-resolve": "~3.3.0",
38+
"rollup-plugin-typescript2": "~0.13.0",
39+
"rollup-plugin-uglify": "~3.0.0",
4240
"tempfile": "2.0.0",
4341
"ts-node": "~5.0.0",
4442
"tslib": "1.8.0",

speech-commands/rollup.config.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
* limitations under the License.
1515
* =============================================================================
1616
*/
17-
18-
import resolve from '@rollup/plugin-node-resolve';
19-
import typescript from '@rollup/plugin-typescript';
20-
import {terser} from 'rollup-plugin-terser';
21-
import commonjs from '@rollup/plugin-commonjs';
17+
import node from 'rollup-plugin-node-resolve';
18+
import typescript from 'rollup-plugin-typescript2';
19+
import uglify from 'rollup-plugin-uglify';
2220

2321
const PREAMBLE = `/**
2422
* @license
@@ -37,45 +35,43 @@ const PREAMBLE = `/**
3735
* =============================================================================
3836
*/`;
3937

40-
function config({ plugins = [], output = {}, tsCompilerOptions = {} }) {
41-
const defaultTsOptions = {
42-
include: ['src/**/*.ts'],
43-
module: 'ES2015',
44-
};
45-
const tsoptions = Object.assign({}, defaultTsOptions, tsCompilerOptions);
38+
function minify() {
39+
return uglify({ output: { preamble: PREAMBLE } });
40+
}
4641

42+
function config({ plugins = [], output = {} }) {
4743
return {
4844
input: 'src/index.ts',
4945
plugins: [
50-
typescript(tsoptions),
51-
resolve(),
52-
commonjs({
53-
ignore: ['crypto', 'node-fetch', 'util'],
54-
include: 'node_modules/**',
55-
namedExports: {
56-
'./node_modules/seedrandom/index.js': ['alea'],
57-
},
58-
}),
59-
...plugins
46+
typescript({ tsconfigOverride: { compilerOptions: { module: 'ES2015' } } }),
47+
node(), ...plugins
6048
],
6149
output: {
62-
sourcemap: true,
63-
globals: {'@tensorflow/tfjs': 'tf'},
64-
...output,
50+
banner: PREAMBLE,
51+
globals: {
52+
'@tensorflow/tfjs-core': 'tf',
53+
'@tensorflow/tfjs-layers': 'tf',
54+
'@tensorflow/tfjs-data': 'tf',
55+
},
56+
...output
6557
},
66-
external: ['@tensorflow/tfjs']
58+
external: [
59+
'@tensorflow/tfjs-core',
60+
'@tensorflow/tfjs-layers',
61+
'@tensorflow/tfjs-data',
62+
]
6763
};
6864
}
6965

7066
const packageName = 'speechCommands';
7167
export default [
7268
config({output: {format: 'umd', name: packageName, file: 'dist/speech-commands.js'}}),
7369
config({
74-
plugins: [terser({output: {preamble: PREAMBLE, comments: false}})],
70+
plugins: [minify()],
7571
output: {format: 'umd', name: packageName, file: 'dist/speech-commands.min.js'}
7672
}),
7773
config({
78-
plugins: [terser({output: {preamble: PREAMBLE, comments: false}})],
74+
plugins: [minify()],
7975
output: {format: 'es', file: 'dist/speech-commands.esm.js'}
8076
})
8177
];

speech-commands/src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @license See the LICENSE file. */
22

33
// This code is auto-generated, do not modify this file!
4-
const version = '0.5.1';
4+
const version = '0.5.2';
55
export {version};

0 commit comments

Comments
 (0)