Skip to content

Commit 2b55ad0

Browse files
authored
fixed the package error (#579)
1 parent 59c6ecb commit 2b55ad0

4 files changed

Lines changed: 482 additions & 799 deletions

File tree

speech-commands/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tensorflow-models/speech-commands",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"description": "Speech-command recognizer in TensorFlow.js",
55
"main": "dist/index.js",
66
"unpkg": "dist/speech-commands.min.js",
@@ -22,6 +22,9 @@
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",
2528
"@types/jasmine": "~2.8.8",
2629
"@types/rimraf": "^2.0.2",
2730
"@types/tempfile": "^2.0.0",
@@ -34,9 +37,8 @@
3437
"kissfft-js": "^0.1.8",
3538
"rimraf": "2.6.2",
3639
"rollup": "~2.3.2",
37-
"rollup-plugin-node-resolve": "~3.3.0",
38-
"rollup-plugin-typescript2": "~0.13.0",
39-
"rollup-plugin-uglify": "~3.0.0",
40+
"rollup-plugin-terser": "~5.3.0",
41+
"rollup-plugin-visualizer": "~3.3.2",
4042
"tempfile": "2.0.0",
4143
"ts-node": "~5.0.0",
4244
"tslib": "1.8.0",

speech-commands/rollup.config.js

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2019 Google LLC. All Rights Reserved.
3+
* Copyright 2020 Google LLC. All Rights Reserved.
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
@@ -15,63 +15,67 @@
1515
* =============================================================================
1616
*/
1717

18-
import node from 'rollup-plugin-node-resolve';
19-
import typescript from 'rollup-plugin-typescript2';
20-
import uglify from 'rollup-plugin-uglify';
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';
2122

2223
const PREAMBLE = `/**
23-
* @license
24-
* Copyright ${(new Date).getFullYear()} Google LLC. All Rights Reserved.
25-
* Licensed under the Apache License, Version 2.0 (the "License");
26-
* you may not use this file except in compliance with the License.
27-
* You may obtain a copy of the License at
28-
*
29-
* http://www.apache.org/licenses/LICENSE-2.0
30-
*
31-
* Unless required by applicable law or agreed to in writing, software
32-
* distributed under the License is distributed on an "AS IS" BASIS,
33-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34-
* See the License for the specific language governing permissions and
35-
* limitations under the License.
36-
* =============================================================================
37-
*/`;
24+
* @license
25+
* Copyright ${(new Date).getFullYear()} Google LLC. All Rights Reserved.
26+
* Licensed under the Apache License, Version 2.0 (the "License");
27+
* you may not use this file except in compliance with the License.
28+
* You may obtain a copy of the License at
29+
*
30+
* http://www.apache.org/licenses/LICENSE-2.0
31+
*
32+
* Unless required by applicable law or agreed to in writing, software
33+
* distributed under the License is distributed on an "AS IS" BASIS,
34+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35+
* See the License for the specific language governing permissions and
36+
* limitations under the License.
37+
* =============================================================================
38+
*/`;
3839

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

43-
function config({plugins = [], output = {}}) {
4447
return {
4548
input: 'src/index.ts',
4649
plugins: [
47-
typescript({tsconfigOverride: {compilerOptions: {module: 'ES2015'}}}),
48-
node(), ...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
4960
],
5061
output: {
51-
banner: PREAMBLE,
5262
sourcemap: true,
5363
globals: {'@tensorflow/tfjs': 'tf'},
54-
...output
64+
...output,
5565
},
5666
external: ['@tensorflow/tfjs']
5767
};
5868
}
5969

70+
const packageName = 'speechCommands';
6071
export default [
72+
config({output: {format: 'umd', name: packageName, file: 'dist/speech-commands.js'}}),
6173
config({
62-
output:
63-
{format: 'umd', name: 'speechCommands', file: 'dist/speech-commands.js'}
64-
}),
65-
config({
66-
plugins: [minify()],
67-
output: {
68-
format: 'umd',
69-
name: 'speechCommands',
70-
file: 'dist/speech-commands.min.js'
71-
}
74+
plugins: [terser({output: {preamble: PREAMBLE, comments: false}})],
75+
output: {format: 'umd', name: packageName, file: 'dist/speech-commands.min.js'}
7276
}),
7377
config({
74-
plugins: [minify()],
78+
plugins: [terser({output: {preamble: PREAMBLE, comments: false}})],
7579
output: {format: 'es', file: 'dist/speech-commands.esm.js'}
7680
})
7781
];

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.0';
4+
const version = '0.5.1';
55
export {version};

0 commit comments

Comments
 (0)