1 Star 0 Fork 13

skymysky/TensorFlowjs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rollup.config.js 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
Yannick Assogba 提交于 2018-07-12 04:37 +08:00 . ship sourcemaps in npm bundle (#506)
/**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import node from 'rollup-plugin-node-resolve';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import uglify from 'rollup-plugin-uglify';
const copyright =
`// @tensorflow/tfjs Copyright ${(new Date).getFullYear()} Google`;
function minify() {
return uglify({
output: {
preamble: copyright,
}
});
}
function config({plugins = [], output = {}, external = []}) {
return {
input: 'src/index.ts',
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'ES2015',
}
}
}),
node(),
// Polyfill require() from dependencies.
commonjs({
ignore: ['crypto'],
include: 'node_modules/**',
namedExports: {
'./node_modules/seedrandom/index.js': ['alea'],
'./src/data/compiled_api.js': ['tensorflow'],
'./node_modules/protobufjs/minimal.js': ['roots', 'Reader', 'util']
},
}),
json(),
// We need babel to compile the compiled_api.js generated proto file from
// es6 to es5.
babel(),
...plugins,
],
output: {
banner: copyright,
sourcemap: true,
...output,
},
external: [
'crypto',
...external,
],
onwarn: warning => {
let {code} = warning;
if (code === 'CIRCULAR_DEPENDENCY' || code === 'CIRCULAR' ||
code === 'THIS_IS_UNDEFINED') {
return;
}
console.warn('WARNING: ', warning.toString());
}
};
}
export default [
config({
output: {
format: 'umd',
name: 'tf',
extend: true,
file: 'dist/tf.js',
}
}),
config({
plugins: [minify()],
output: {
format: 'umd',
name: 'tf',
extend: true,
file: 'dist/tf.min.js',
}
}),
config({
plugins: [minify()],
output: {
format: 'es',
file: 'dist/tf.esm.js',
globals: {
'@tensorflow/tfjs-core': 'tf',
'@tensorflow/tfjs-layers': 'tf',
'@tensorflow/tfjs-converter': 'tf'
}
},
external: [
'@tensorflow/tfjs-core',
'@tensorflow/tfjs-layers',
'@tensorflow/tfjs-converter',
]
})
];
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/skymysky/TensorFlowjs.git
git@gitee.com:skymysky/TensorFlowjs.git
skymysky
TensorFlowjs
TensorFlowjs
master

搜索帮助