diff options
Diffstat (limited to 'tensorflow/tensorboard/gulp_tasks/compile.js')
-rw-r--r-- | tensorflow/tensorboard/gulp_tasks/compile.js | 93 |
1 files changed, 49 insertions, 44 deletions
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('.')); + }; +}; |