From 33c9c02cd6ef2640caa4c96c9de4e8392c853d50 Mon Sep 17 00:00:00 2001 From: Dan Smilkov Date: Tue, 6 Sep 2016 17:58:53 -0800 Subject: Use http_file instead of new_http_archive for some external dependencies. 1) Use http_file for the following external deps: - Three.js since the github releases are extremely large (>500mb). - numericjs since the compiled js is not checked into the github repo or even bower. It is hosted on the numericjs website. 2) Link the compiled source from ES6 components (e.g. Embedding Projector) into TensorBoard. In other words, new releases of vulcanized tf-tensorboard.html will now include the compiled code for the embedding projector (not visible yet in the UI). 3) Make bower_dependency_sync script generate one more file, dist/bazel-html-imports.html. This file imports the external deps that use http_file (via + + diff --git a/tensorflow/tensorboard/dist/bazel-html-imports.html b/tensorflow/tensorboard/dist/bazel-html-imports.html new file mode 100644 index 0000000000..ef25079142 --- /dev/null +++ b/tensorflow/tensorboard/dist/bazel-html-imports.html @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/tensorflow/tensorboard/dist/index.html b/tensorflow/tensorboard/dist/index.html index 5931a3f2f2..29c800bea1 100644 --- a/tensorflow/tensorboard/dist/index.html +++ b/tensorflow/tensorboard/dist/index.html @@ -22,6 +22,7 @@ limitations under the License. + diff --git a/tensorflow/tensorboard/gulp_tasks/compile.js b/tensorflow/tensorboard/gulp_tasks/compile.js index 501eb6eaee..0f0bdd8f38 100644 --- a/tensorflow/tensorboard/gulp_tasks/compile.js +++ b/tensorflow/tensorboard/gulp_tasks/compile.js @@ -40,51 +40,56 @@ var ES6_COMPONENTS = [{ ] }]; -module.exports = function() { - // Compile all components that are using ES6 modules into a bundle.js - // using browserify. - var entries = ['typings/index.d.ts']; - var deps = {}; - ES6_COMPONENTS.forEach(function(component) { - // Collect all the typescript files across the components. - entries = entries.concat(glob( - 'components/' + component.name + '/**/*.ts', - // Do not include tests or IDE-purposed files. - {ignore: ['**/*_test.ts', '**/deps.d.ts']})); - // Collect the unique external deps across all components using es6 modules. - component.deps.forEach(function(dep) { deps['components/' + dep] = true; }); - }); - deps = Object.keys(deps); - - // Compile, bundle all the typescript files and prepend their deps. - browserify(entries) - .plugin(tsify) - .bundle() - .on('error', function(error) { console.error(error.toString()); }) - .pipe(source('app.js')) - .pipe(gulp.dest('components')) - .on('end', function() { - // Typescript was compiled and bundled. Now we need to prepend - // the external dependencies. - gulp.src(deps.concat(['components/app.js'])) - .pipe(concat('bundle.js')) - .pipe(gulp.dest('components')); +module.exports = function(includeDeps) { + return function() { + // Compile all components that are using ES6 modules into a bundle.js + // using browserify. + var entries = ['typings/index.d.ts']; + var deps = {}; + ES6_COMPONENTS.forEach(function(component) { + // Collect all the typescript files across the components. + entries = entries.concat(glob( + 'components/' + component.name + '/**/*.ts', + // Do not include tests or IDE-purposed files. + {ignore: ['**/*_test.ts', '**/deps.d.ts']})); + // Collect the unique external deps across all components using es6 + // modules. + component.deps.forEach(function(dep) { + deps['components/' + dep] = true; }); + }); + deps = Object.keys(deps); - // Compile components that are using global namespaces producing 1 js file - // for each ts file. - var isComponent = filter([ - 'components/tf-*/**/*.ts', 'components/vz-*/**/*.ts', 'typings/**/*.ts', - 'components/plottable/plottable.d.ts' - // Ignore components that use es6 modules. - ].concat(ES6_COMPONENTS.map(function(component) { - return '!components/' + component.name + '/**/*.ts'; - }))); + // Compile, bundle all the typescript files and prepend their deps. + browserify(entries) + .plugin(tsify) + .bundle() + .on('error', function(error) { console.error(error.toString()); }) + .pipe(source('bundle.js')) + .pipe(gulp.dest('components')) + .on('end', function() { + // Typescript was compiled and bundled. Now we need to prepend + // the external dependencies. + if (includeDeps) { + gulp.src(deps.concat(['components/bundle.js'])) + .pipe(concat('bundle.js')) + .pipe(gulp.dest('components')); + } + }); - return tsProject.src() - .pipe(isComponent) - .pipe(ts(tsProject)) - .js - .pipe(gulp.dest('.')); + // Compile components that are using global namespaces producing 1 js file + // for each ts file. + var isComponent = filter([ + 'components/tf-*/**/*.ts', 'components/vz-*/**/*.ts', 'typings/**/*.ts', + 'components/plottable/plottable.d.ts' + // Ignore components that use es6 modules. + ].concat(ES6_COMPONENTS.map(function(component) { + return '!components/' + component.name + '/**/*.ts'; + }))); -} + return tsProject.src() + .pipe(isComponent) + .pipe(ts(tsProject)) + .js.pipe(gulp.dest('.')); + }; +}; diff --git a/tensorflow/tensorboard/gulp_tasks/vulcanize.js b/tensorflow/tensorboard/gulp_tasks/vulcanize.js index b31392c2c3..42b985f8f6 100644 --- a/tensorflow/tensorboard/gulp_tasks/vulcanize.js +++ b/tensorflow/tensorboard/gulp_tasks/vulcanize.js @@ -63,7 +63,7 @@ module.exports = function(overwrite) { inlineScripts: true, inlineCss: true, stripComments: true, - excludes: getNonTensorBoardComponents(), + excludes: getNonTensorBoardComponents() })) .pipe(header(HEADER_STR)) .pipe(rename('tf-tensorboard.html' + suffix)) diff --git a/tensorflow/tensorboard/gulpfile.js b/tensorflow/tensorboard/gulpfile.js index 4b92152818..96e955f8a8 100644 --- a/tensorflow/tensorboard/gulpfile.js +++ b/tensorflow/tensorboard/gulpfile.js @@ -29,11 +29,12 @@ function getTask(task) { } -gulp.task('compile', getTask('compile')); +gulp.task('compile', getTask('compile')(true)); gulp.task('tslint', getTask('tslint')(true)); // tslint.permissive warns without failing. gulp.task('tslint.permissive', getTask('tslint')(false)); -gulp.task('first-compile', getTask('compile')); +gulp.task('first-compile', getTask('compile')(true)); +gulp.task('compile-without-deps', getTask('compile')(false)); gulp.task('test.onlytest', getTask('test')); // if you don't want to lint, etc gulp.task('test', ['tslint', 'compile'], getTask('test')); @@ -65,9 +66,13 @@ gulp.task('server', ['first-compile'], function() { // TODO(danmane): When testing is nicer, integrate into vulcanize task // gulp vulcanize: Regenerate the tf-tensorboard.html.OPENSOURCE file for pre-release -gulp.task('vulcanize', ['first-compile', 'tslint.permissive'], getTask('vulcanize')(false)); +gulp.task( + 'vulcanize', ['compile-without-deps', 'tslint.permissive'], + getTask('vulcanize')(false)); // gulp regenerate: Regenerate the tf-tensorboard.html for interactive bazel development -gulp.task('regenerate', ['first-compile', 'tslint.permissive'], getTask('vulcanize')(true)); +gulp.task( + 'regenerate', ['compile-without-deps', 'tslint.permissive'], + getTask('vulcanize')(true)); // TODO(danmane): consider making bower install part of default task gulp.task('default', ['watch', 'server']); -- cgit v1.2.3