module.exports = function makeDartTree() { var sourceTree = mergeTrees([getSourceTree(), getHtmlSourcesTree()]); sourceTree = fixDartFolderLayout(sourceTree); var mergedResult = mergeTrees([sourceTree, getTemplatedPubspecsTree(), getDocsTree()]); // Move the tree under the 'dart' folder. return stew.mv(mergedResult, 'dart'); };
module.exports = function makeDartTree(destinationPath) { var sourceTree = mergeTrees([getSourceTree(), getHtmlSourcesTree()]); sourceTree = fixDartFolderLayout(sourceTree); var dartTree = mergeTrees([sourceTree, getTemplatedPubspecsTree(), getDocsTree()]); // TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate! // ENOENT error is thrown while doing fs.readdirSync on inputRoot // in the meantime, we just do noop mv to create a new tree dartTree = stew.mv(dartTree, ''); return destCopy(dartTree, destinationPath); };
module.exports = function makeDartTree() { // Transpile everything in 'modules'... var modulesTree = new Funnel('modules', { include: ['**/*.js', '**/*.ts', '**/*.dart'], // .dart file available means don't translate. exclude: ['rtts_assert/**/*'], // ... except for the rtts_asserts (don't apply to Dart). destDir: '/' // Remove the 'modules' prefix. }); // Transpile to dart. var dartTree = ts2dart.transpile(modulesTree); // Move around files to match Dart's layout expectations. dartTree = stew.rename(dartTree, function(relativePath) { // If a file matches the `pattern`, insert the given `insertion` as the second path part. var replacements = [ {pattern: /^benchmarks\/test\//, insertion: ''}, {pattern: /^benchmarks\//, insertion: 'web'}, {pattern: /^benchmarks_external\/test\//, insertion: ''}, {pattern: /^benchmarks_external\//, insertion: 'web'}, {pattern: /^example.?\//, insertion: 'web/'}, {pattern: /^example.?\/test\//, insertion: ''}, {pattern: /^[^\/]*\/test\//, insertion: ''}, {pattern: /^./, insertion: 'lib'}, // catch all. ]; for (var i = 0; i < replacements.length; i++) { var repl = replacements[i]; if (relativePath.match(repl.pattern)) { var parts = relativePath.split('/'); parts.splice(1, 0, repl.insertion); return path.join.apply(path, parts); } } throw new Error('Failed to match any path: ' + relativePath); }); // Move the tree under the 'dart' folder. return stew.mv(dartTree, 'dart'); };
module.exports = function makeBrowserTree(options, destinationPath) { const modules = options.projects; const noTypeChecks = options.noTypeChecks; const generateEs6 = options.generateEs6; const sourceMaps = options.sourceMaps; const useBundles = options.useBundles; if (modules.angular2) { var angular2Tree = new Funnel('modules/angular2', { include: ['**/**'], exclude: [ // Exclude ES6 polyfill typings when tsc target=ES6 'typings/es6-*/**', ], destDir: '/angular2/' }); } if (modules.benchmarks) { var benchmarksTree = new Funnel( 'modules/benchmarks', {include: ['**/**'], exclude: ['e2e_test/**'], destDir: '/benchmarks/'}); } if (modules.benchmarks_external) { var benchmarksExternalTree = new Funnel( 'modules/benchmarks_external', {include: ['**/**'], exclude: ['e2e_test/**'], destDir: '/benchmarks_external/'}); } if (modules.payload_tests) { var payloadTestsTree = new Funnel( 'modules/payload_tests', {include: ['**/ts/**'], exclude: ['e2e_test/**'], destDir: '/payload_tests/'}); } if (modules.playground) { var playgroundTree = new Funnel( 'modules/playground', {include: ['**/**'], exclude: ['e2e_test/**'], destDir: '/playground/'}); } if (modules.benchpress) { var benchpressTree = new Funnel( 'modules/benchpress', {include: ['**/**'], exclude: ['e2e_test/**'], destDir: '/benchpress/'}); } let externalTypings = new Funnel('node_modules', {include: ['rxjs/**/*.d.ts', 'zone.js/**/*.d.ts']}); var modulesTree = mergeTrees([ angular2Tree, benchmarksTree, benchmarksExternalTree, payloadTestsTree, playgroundTree, benchpressTree, externalTypings, ]); var es6PolyfillTypings = new Funnel('modules', {include: ['angular2/typings/es6-*/**'], destDir: '/'}); var es5ModulesTree = mergeTrees([modulesTree, es6PolyfillTypings]); var scriptPathPatternReplacement = { match: '@@PATH', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts.splice(0, parts.length - 1).join('/'); } }; var scriptFilePatternReplacement = { match: '@@FILENAME', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts[parts.length - 1].replace('html', 'js'); } }; var useBundlesPatternReplacement = { match: '@@USE_BUNDLES', replacement: function(replacement, relativePath) { return useBundles; } }; // Check that imports do not break barrel boundaries modulesTree = checkImports(modulesTree); modulesTree = replace(modulesTree, { files: ['playground*/**/*.js'], patterns: [{match: /\$SCRIPTS\$/, replacement: jsReplace('SCRIPTS')}] }); let ambientTypings = [ 'angular2/typings/hammerjs/hammerjs.d.ts', 'angular2/typings/node/node.d.ts', 'node_modules/zone.js/dist/zone.js.d.ts', 'angular2/manual_typings/globals.d.ts', 'angular2/typings/es6-collections/es6-collections.d.ts', 'angular2/typings/es6-promise/es6-promise.d.ts' ]; // Use TypeScript to transpile the *.ts files to ES5 var es5Tree = compileWithTypescript(es5ModulesTree, { declaration: false, emitDecoratorMetadata: true, experimentalDecorators: true, module: 'commonjs', moduleResolution: 'classic', noEmitOnError: !noTypeChecks, rootDir: './', rootFilePaths: ambientTypings, inlineSourceMap: sourceMaps, inlineSources: sourceMaps, target: 'es5' }); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/es6-shim/es6-shim.js', 'node_modules/zone.js/dist/zone.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/base64-js/lib/b64.js', 'node_modules/reflect-metadata/Reflect.js' ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); // Get scripts for each benchmark or example let servingTrees = kServedPaths.reduce(getServedFunnels, []); function getServedFunnels(funnels, destDir) { let options = {srcDir: '/', destDir: destDir}; funnels.push(new Funnel(vendorScriptsTree, options)); if (destDir.indexOf('benchmarks') > -1) { funnels.push(new Funnel(vendorScripts_benchmark, options)); } if (destDir.indexOf('benchmarks_external') > -1) { funnels.push(new Funnel(vendorScripts_benchmarks_external, options)); } return funnels; } if (modules.benchmarks || modules.benchmarks_external || modules.playground) { var assetsTree = new Funnel( modulesTree, {include: ['**/*'], exclude: ['**/*.{html,ts,dart}'], destDir: '/'}); } var htmlTree = new Funnel(modulesTree, { include: ['*/src/**/*.html', '**/playground/**/*.html', '**/payload_tests/**/ts/**/*.html'], destDir: '/' }); if (modules.playground) { htmlTree = replace(htmlTree, { files: ['playground*/**/*.html'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}, scriptPathPatternReplacement, scriptFilePatternReplacement, useBundlesPatternReplacement ] }); } if (modules.benchmarks) { htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}, scriptPathPatternReplacement, scriptFilePatternReplacement, useBundlesPatternReplacement ] }); } if (modules.benchmarks_external) { htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}, scriptPathPatternReplacement, scriptFilePatternReplacement, useBundlesPatternReplacement ] }); } if (modules.playground) { // We need to replace the regular angular bundle with the web-worker bundle // for web-worker e2e tests. htmlTree = replace(htmlTree, { files: ['playground*/**/web_workers/**/*.html'], patterns: [{match: '/bundle/angular2.dev.js', replacement: '/bundle/web_worker/ui.dev.js'}] }); } if (modules.benchmarks || modules.benchmarks_external) { var scripts = mergeTrees(servingTrees); } if (modules.benchmarks_external) { var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/polymer.html', 'bower_components/polymer/polymer-micro.html', 'bower_components/polymer/polymer-mini.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); var reactFiles = new Funnel('.', {files: ['node_modules/react/dist/react.min.js']}); var react = stew.mv(flatten(reactFiles), 'benchmarks_external/src/tree/react'); } if (modules.benchmarks || modules.benchmarks_external || modules.playground) { htmlTree = mergeTrees([htmlTree, scripts, polymer, react]); } // this is needed only for creating a bundle // typescript resolves dependencies automatically if (modules.bundle_deps) { var nodeModules = new Funnel( 'node_modules', {include: ['rxjs/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'}); } if (generateEs6) { // Use TypeScript to transpile the *.ts files to ES6 var es6Tree = compileWithTypescript(modulesTree, { declaration: false, emitDecoratorMetadata: true, experimentalDecorators: true, noEmitOnError: false, rootDir: './', rootFilePaths: [ 'angular2/typings/zone.js/zone.js.d.ts', 'angular2/typings/hammerjs/hammerjs.d.ts', 'angular2/typings/node/node.d.ts', ], inlineSourceMap: sourceMaps, inlineSources: sourceMaps, target: 'es6' }); es6Tree = stew.mv(mergeTrees([es6Tree, htmlTree, assetsTree, nodeModules]), '/es6'); } es5Tree = stew.mv(mergeTrees([es5Tree, htmlTree, assetsTree, nodeModules]), '/es5'); var mergedTree = mergeTrees([es6Tree, es5Tree]); return destCopy(mergedTree, destinationPath); };
module.exports = function makeBrowserTree(options, destinationPath) { var modulesTree = new Funnel( 'modules', {include: ['**/**'], exclude: ['**/*.cjs', 'benchmarks/e2e_test/**'], destDir: '/'}); // Use Traceur to transpile *.js sources to ES6 var traceurTree = transpileWithTraceur(modulesTree, { destExtension: '.js', destSourceMapExtension: '.map', traceurOptions: { sourceMaps: true, annotations: true, // parse annotations types: true, // parse types script: false, // parse as a module memberVariables: true, // parse class fields modules: 'instantiate', // typeAssertionModule: 'rtts_assert/rtts_assert', // typeAssertions: options.typeAssertions, outputLanguage: 'es6' } }); // Use TypeScript to transpile the *.ts files to ES6 // We don't care about errors: we let the TypeScript compilation to ES5 // in node_tree.ts do the type-checking. var typescriptTree = compileWithTypescript(modulesTree, { allowNonTsExtensions: false, declaration: true, emitDecoratorMetadata: true, mapRoot: '', // force sourcemaps to use relative path noEmitOnError: false, // temporarily ignore errors, we type-check only via cjs build rootDir: '.', sourceMap: true, sourceRoot: '.', target: 'ES6' }); var es6Tree = mergeTrees([traceurTree, typescriptTree]); // Call Traceur again to lower the ES6 build tree to ES5 var es5Tree = transpileWithTraceur(es6Tree, { destExtension: '.js', destSourceMapExtension: '.js.map', traceurOptions: {modules: 'instantiate', sourceMaps: true} }); // Now we add a few more files to the es6 tree that Traceur should not see ['angular2', 'rtts_assert'].forEach(function(destDir) { var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: destDir}); es6Tree = mergeTrees([es6Tree, extras]); }); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/systemjs/lib/extension-register.js', 'node_modules/systemjs/lib/extension-cjs.js', 'node_modules/rx/dist/rx.js', 'node_modules/reflect-metadata/Reflect.js', 'tools/build/snippets/runtime_paths.js', path.relative(projectRootDir, TRACEUR_RUNTIME_PATH) ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); // Get scripts for each benchmark or example let servingTrees = kServedPaths.reduce(getServedFunnels, []); function getServedFunnels(funnels, destDir) { let options = { srcDir: '/', destDir: destDir }; funnels.push(new Funnel(vendorScriptsTree, options)); if (destDir.indexOf('benchmarks') > -1) { funnels.push(new Funnel(vendorScripts_benchmark, options)); } if (destDir.indexOf('benchmarks_external') > -1) { funnels.push(new Funnel(vendorScripts_benchmarks_external, options)); } return funnels; } var scriptPathPatternReplacement = { match: '@@FILENAME_NO_EXT', replacement: function(replacement, relativePath) { return relativePath.replace(/\.\w+$/, ''); } }; var htmlTree = new Funnel(modulesTree, {include: ['*/src/**/*.html'], destDir: '/'}); htmlTree = replace(htmlTree, { files: ['examples*/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}, scriptPathPatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}, scriptPathPatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}, scriptPathPatternReplacement ] }); var assetsTree = new Funnel(modulesTree, {include: ['**/*'], exclude: ['**/*.{html,ts,dart}'], destDir: '/'}); var scripts = mergeTrees(servingTrees); var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/lib/polymer.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); var reactFiles = new Funnel('.', {files: ['node_modules/react/dist/react.min.js']}); var react = stew.mv(flatten(reactFiles), 'benchmarks_external/src/tree/react'); htmlTree = mergeTrees([htmlTree, scripts, polymer, react]); es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree]); var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]); return destCopy(mergedTree, destinationPath); };
module.exports = function makeBrowserTree(options, destinationPath) { var modulesTree = new Funnel('modules', { include: ['**/**'], exclude: [ '**/*.cjs', 'benchmarks/e2e_test/**', 'angular1_router/**', // Exclude ES6 polyfill typings when tsc target=ES6 'angular2/typings/es6-*/**', ], destDir: '/' }); var clientModules = new Funnel( 'node_modules', {include: ['@reactivex/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'}); var es5ModulesTree = new Funnel('modules', { include: ['**/**'], exclude: ['**/*.cjs', 'angular1_router/**', 'benchmarks/e2e_test/**'], destDir: '/' }); var scriptPathPatternReplacement = { match: '@@PATH', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts.splice(0, parts.length - 1).join('/'); } }; var scriptFilePatternReplacement = { match: '@@FILENAME', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts[parts.length - 1].replace('html', 'js'); } }; modulesTree = replace(modulesTree, { files: ["playground*/**/*.js"], patterns: [{match: /\$SCRIPTS\$/, replacement: jsReplace('SCRIPTS')}] }); // Use TypeScript to transpile the *.ts files to ES6 var es6Tree = compileWithTypescript(modulesTree, { declaration: false, emitDecoratorMetadata: true, experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path noEmitOnError: false, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'], sourceMap: true, sourceRoot: '.', target: 'es6' }); // Use TypeScript to transpile the *.ts files to ES5 var typescriptOptions = { declaration: true, stripInternal: true, emitDecoratorMetadata: true, experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path module: 'commonjs', moduleResolution: 'classic', noEmitOnError: true, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals.d.ts'], sourceMap: true, sourceRoot: '.', target: 'es5' }; var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions); // Now we add a few more files to the es6 tree that the es5 tree should not see var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: 'angular2'}); es6Tree = mergeTrees([es6Tree, extras]); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/es6-shim/es6-shim.js', 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/base64-js/lib/b64.js', 'node_modules/reflect-metadata/Reflect.js' ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); // Get scripts for each benchmark or example let servingTrees = kServedPaths.reduce(getServedFunnels, []); function getServedFunnels(funnels, destDir) { let options = {srcDir: '/', destDir: destDir}; funnels.push(new Funnel(vendorScriptsTree, options)); if (destDir.indexOf('benchmarks') > -1) { funnels.push(new Funnel(vendorScripts_benchmark, options)); } if (destDir.indexOf('benchmarks_external') > -1) { funnels.push(new Funnel(vendorScripts_benchmarks_external, options)); } return funnels; } var htmlTree = new Funnel( modulesTree, {include: ['*/src/**/*.html', '**/playground/**/*.html'], destDir: '/'}); htmlTree = replace(htmlTree, { files: ['playground*/**/*.html'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); // We need to replace the regular angular bundle with the web-worker bundle // for web-worker e2e tests. htmlTree = replace(htmlTree, { files: ['playground*/**/web_workers/**/*.html'], patterns: [{match: "/bundle/angular2.dev.js", replacement: "/bundle/web_worker/ui.dev.js"}] }); var assetsTree = new Funnel(modulesTree, {include: ['**/*'], exclude: ['**/*.{html,ts,dart}'], destDir: '/'}); var scripts = mergeTrees(servingTrees); var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/lib/polymer.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); var reactFiles = new Funnel('.', {files: ['node_modules/react/dist/react.min.js']}); var react = stew.mv(flatten(reactFiles), 'benchmarks_external/src/tree/react'); htmlTree = mergeTrees([htmlTree, scripts, polymer, react]); var typingsTree = new Funnel( 'modules', {include: ['angular2/typings/**/*.d.ts', 'angular2/manual_typings/*.d.ts'], destDir: '/'}); // Add a line to the end of our top-level .d.ts file. // This HACK for transitive typings is a workaround for // https://github.com/Microsoft/TypeScript/issues/5097 // // This allows users to get our top-level dependencies like es6-shim.d.ts // to appear when they compile against angular2. // // This carries the risk that the user brings their own copy of that file // (or any other symbols exported here) and they will get a compiler error // because of the duplicate definitions. // TODO(alexeagle): remove this when typescript releases a fix es5Tree = replace(es5Tree, { files: ['angular2/angular2.d.ts'], patterns: [{match: /$/, replacement: 'import "./manual_typings/globals.d.ts";\n'}] }); es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree, clientModules, typingsTree]); es6Tree = mergeTrees([es6Tree, htmlTree, assetsTree, clientModules, typingsTree]); var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]); return destCopy(mergedTree, destinationPath); };
module.exports = function makeNodeTree(destinationPath) { // list of npm packages that this build will create var outputPackages = ['angular2', 'benchpress', 'rtts_assert']; var modulesTree = new Funnel('modules', { include: ['angular2/**', 'benchpress/**', 'rtts_assert/**', '**/e2e_test/**'], exclude: [ // the following code and tests are not compatible with CJS/node environment 'angular2/test/core/zone/**', 'angular2/test/test_lib/fake_async_spec.js' ] }); var nodeTree = transpileWithTraceur(modulesTree, { destExtension: '.js', destSourceMapExtension: '.map', traceurOptions: { sourceMaps: true, annotations: true, // parse annotations types: true, // parse types script: false, // parse as a module memberVariables: true, // parse class fields typeAssertionModule: 'rtts_assert/rtts_assert', // Don't use type assertions since this is partly transpiled by typescript typeAssertions: false, modules: 'commonjs' } }); // Transform all tests to make them runnable in node nodeTree = replace(nodeTree, { files: ['**/test/**/*_spec.js'], patterns: [ { // Override the default DOM adapter with Parse5 for all tests match: /"use strict";/, replacement: "'use strict'; var parse5Adapter = require('angular2/src/dom/parse5_adapter'); " + "parse5Adapter.Parse5DomAdapter.makeCurrent();" }, { // Append main() to all tests since all of our tests are wrapped in exported main fn match: /$/g, replacement: "\r\n main();" } ] }); // Now we add the LICENSE file into all the folders that will become npm packages outputPackages.forEach(function(destDir) { var license = new Funnel('.', {files: ['LICENSE'], destDir: destDir}); nodeTree = mergeTrees([nodeTree, license]); }); // Get all docs and related assets and prepare them for js build var docs = new Funnel(modulesTree, {include: ['**/*.md', '**/*.png'], exclude: ['**/*.dart.md']}); docs = stew.rename(docs, 'README.js.md', 'README.md'); // Generate shared package.json info var BASE_PACKAGE_JSON = require(path.join(projectRootDir, 'package.json')); var COMMON_PACKAGE_JSON = { version: BASE_PACKAGE_JSON.version, homepage: BASE_PACKAGE_JSON.homepage, bugs: BASE_PACKAGE_JSON.bugs, license: BASE_PACKAGE_JSON.license, contributors: BASE_PACKAGE_JSON.contributors, dependencies: BASE_PACKAGE_JSON.dependencies, devDependencies: { "yargs": BASE_PACKAGE_JSON.devDependencies['yargs'], "gulp-sourcemaps": BASE_PACKAGE_JSON.devDependencies['gulp-sourcemaps'], "gulp-traceur": BASE_PACKAGE_JSON.devDependencies['gulp-traceur'], "gulp": BASE_PACKAGE_JSON.devDependencies['gulp'], "gulp-rename": BASE_PACKAGE_JSON.devDependencies['gulp-rename'], "through2": BASE_PACKAGE_JSON.devDependencies['through2'] } }; // Add a .template extension since renderLodashTemplate strips one extension var packageJsons = stew.rename(new Funnel(modulesTree, {include: ['**/package.json']}), '.json', '.json.template'); packageJsons = renderLodashTemplate( packageJsons, {files: ["**/**"], context: {'packageJson': COMMON_PACKAGE_JSON}}); // HACK: workaround for Traceur behavior. // It expects all transpiled modules to contain this marker. // TODO: remove this when we no longer use traceur var traceurCompatibleTsModulesTree = replace(modulesTree, { files: ['**/*.ts'], patterns: [{ // Empty replacement needed so that replaceWithPath gets triggered... match: /$/g, replacement: "" }], replaceWithPath: function(path, content) { if (!path.endsWith('.d.ts')) { content += '\r\nexport var __esModule = true;\n'; } return content; } }); // TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate! // ENOENT error is thrown while doing fs.readdirSync on inputRoot // in the meantime, we just do noop mv to create a new tree traceurCompatibleTsModulesTree = stew.mv(traceurCompatibleTsModulesTree, ''); var typescriptTree = compileWithTypescript(traceurCompatibleTsModulesTree, { allowNonTsExtensions: false, emitDecoratorMetadata: true, declaration: true, mapRoot: '', /* force sourcemaps to use relative path */ module: 'commonjs', noEmitOnError: true, rootDir: '.', rootFilePaths: ['angular2/traceur-runtime.d.ts', 'angular2/globals.d.ts'], sourceMap: true, sourceRoot: '.', target: 'ES5' }); nodeTree = mergeTrees([nodeTree, typescriptTree, docs, packageJsons]); // TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate! // ENOENT error is thrown while doing fs.readdirSync on inputRoot // in the meantime, we just do noop mv to create a new tree nodeTree = stew.mv(nodeTree, ''); return destCopy(nodeTree, destinationPath); };
module.exports = function makeBrowserTree(options, destinationPath) { var modulesTree = new Funnel( 'modules', {include: ['**/**'], exclude: ['**/*.cjs', 'benchmarks/e2e_test/**'], destDir: '/'}); // Use Traceur to transpile *.js sources to ES6 var traceurTree = transpileWithTraceur(modulesTree, { destExtension: '.es6', destSourceMapExtension: '.map', traceurOptions: { sourceMaps: true, annotations: true, // parse annotations types: true, // parse types script: false, // parse as a module memberVariables: true, // parse class fields modules: 'instantiate', // typeAssertionModule: 'rtts_assert/rtts_assert', // typeAssertions: options.typeAssertions, outputLanguage: 'es6' } }); // Use TypeScript to transpile the *.ts files to ES6 // We don't care about errors: we let the TypeScript compilation to ES5 // in node_tree.ts do the type-checking. var typescriptTree = compileWithTypescript(modulesTree, { allowNonTsExtensions: false, declaration: true, emitDecoratorMetadata: true, mapRoot: '', // force sourcemaps to use relative path noEmitOnError: false, // temporarily ignore errors, we type-check only via cjs build rootDir: '.', sourceMap: true, sourceRoot: '.', target: 'ES6' }); typescriptTree = stew.rename(typescriptTree, '.js', '.es6'); var es6Tree = mergeTrees([traceurTree, typescriptTree]); // TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate! // ENOENT error is thrown while doing fs.readdirSync on inputRoot // in the meantime, we just do noop mv to create a new tree es6Tree = stew.mv(es6Tree, ''); // Call Traceur again to lower the ES6 build tree to ES5 var es5Tree = transpileWithTraceur(es6Tree, { destExtension: '.js', destSourceMapExtension: '.js.map', traceurOptions: {modules: 'instantiate', sourceMaps: true} }); // Now we add a few more files to the es6 tree that Traceur should not see ['angular2', 'rtts_assert'].forEach(function(destDir) { var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: destDir}); es6Tree = mergeTrees([es6Tree, extras]); }); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', 'node_modules/zone.js/zone.js', 'node_modules/zone.js/long-stack-trace-zone.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/systemjs/lib/extension-register.js', 'node_modules/systemjs/lib/extension-cjs.js', 'node_modules/rx/dist/rx.js', 'node_modules/reflect-metadata/Reflect.js', 'tools/build/snippets/runtime_paths.js', path.relative(projectRootDir, TRACEUR_RUNTIME_PATH) ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); var servingTrees = []; function copyVendorScriptsTo(destDir) { servingTrees.push(new Funnel(vendorScriptsTree, {srcDir: '/', destDir: destDir})); if (destDir.indexOf('benchmarks') > -1) { servingTrees.push(new Funnel(vendorScripts_benchmark, {srcDir: '/', destDir: destDir})); } if (destDir.indexOf('benchmarks_external') > -1) { servingTrees.push( new Funnel(vendorScripts_benchmarks_external, {srcDir: '/', destDir: destDir})); } } function writeScriptsForPath(relativePath, result) { copyVendorScriptsTo(path.dirname(relativePath)); return result.replace('@@FILENAME_NO_EXT', relativePath.replace(/\.\w+$/, '')); } var htmlTree = new Funnel(modulesTree, {include: ['*/src/**/*.html'], destDir: '/'}); htmlTree = replace(htmlTree, { files: ['examples*/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}], replaceWithPath: writeScriptsForPath }); htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}], replaceWithPath: writeScriptsForPath }); htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}], replaceWithPath: writeScriptsForPath }); // Copy all vendor scripts into all examples and benchmarks ['benchmarks/src', 'benchmarks_external/src', 'examples/src/benchpress'].forEach( copyVendorScriptsTo); var scripts = mergeTrees(servingTrees, {overwrite: true}); var css = new Funnel(modulesTree, {include: ["**/*.css"]}); var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/lib/polymer.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); var reactFiles = new Funnel('.', {files: ['node_modules/react/dist/react.min.js']}); var react = stew.mv(flatten(reactFiles), 'benchmarks_external/src/tree/react'); htmlTree = mergeTrees([htmlTree, scripts, polymer, css, react]); es5Tree = mergeTrees([es5Tree, htmlTree]); var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]); // TODO(iminar): tree differ seems to have issues with trees created by mergeTrees, investigate! // ENOENT error is thrown while doing fs.readdirSync on inputRoot // in the meantime, we just do noop mv to create a new tree mergedTree = stew.mv(mergedTree, ''); return destCopy(mergedTree, destinationPath); };
module.exports = function makeBrowserTree(options, destinationPath) { var modulesTree = new Funnel('modules', { include: ['**/**'], exclude: [ '**/*.cjs', 'benchmarks/e2e_test/**', 'angular1_router/**', // Exclude ES6 polyfill typings when tsc target=ES6 'angular2/typings/es6-*/**', ], destDir: '/' }); var clientModules = new Funnel( 'node_modules', {include: ['@reactivex/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'}); var es5ModulesTree = new Funnel('modules', { include: ['**/**'], exclude: ['**/*.cjs', 'angular1_router/**', 'benchmarks/e2e_test/**'], destDir: '/' }); var scriptPathPatternReplacement = { match: '@@PATH', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts.splice(0, parts.length - 1).join('/'); } }; var scriptFilePatternReplacement = { match: '@@FILENAME', replacement: function(replacement, relativePath) { var parts = relativePath.replace(/\\/g, '/').split('/'); return parts[parts.length - 1].replace('html', 'js'); } }; modulesTree = replace(modulesTree, { files: ["playground*/**/*.js"], patterns: [{match: /\$SCRIPTS\$/, replacement: jsReplace('SCRIPTS')}] }); // Use TypeScript to transpile the *.ts files to ES6 var es6Tree = compileWithTypescript(modulesTree, { declaration: false, emitDecoratorMetadata: true, experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path noEmitOnError: false, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'], sourceMap: true, sourceRoot: '.', target: 'es6' }); // Use TypeScript to transpile the *.ts files to ES5 var typescriptOptions = { declaration: false, emitDecoratorMetadata: true, experimentalDecorators: true, mapRoot: '', // force sourcemaps to use relative path module: 'commonjs', moduleResolution: 'classic', noEmitOnError: true, rootDir: '.', rootFilePaths: ['angular2/manual_typings/globals.d.ts'], sourceMap: true, sourceRoot: '.', target: 'es5' }; var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/es6-shim/es6-shim.js', 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/base64-js/lib/b64.js', 'node_modules/reflect-metadata/Reflect.js' ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); // Get scripts for each benchmark or example let servingTrees = kServedPaths.reduce(getServedFunnels, []); function getServedFunnels(funnels, destDir) { let options = {srcDir: '/', destDir: destDir}; funnels.push(new Funnel(vendorScriptsTree, options)); if (destDir.indexOf('benchmarks') > -1) { funnels.push(new Funnel(vendorScripts_benchmark, options)); } if (destDir.indexOf('benchmarks_external') > -1) { funnels.push(new Funnel(vendorScripts_benchmarks_external, options)); } return funnels; } var htmlTree = new Funnel( modulesTree, {include: ['*/src/**/*.html', '**/playground/**/*.html'], destDir: '/'}); htmlTree = replace(htmlTree, { files: ['playground*/**/*.html'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [ {match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}, scriptPathPatternReplacement, scriptFilePatternReplacement ] }); // We need to replace the regular angular bundle with the web-worker bundle // for web-worker e2e tests. htmlTree = replace(htmlTree, { files: ['playground*/**/web_workers/**/*.html'], patterns: [{match: "/bundle/angular2.dev.js", replacement: "/bundle/web_worker/ui.dev.js"}] }); var assetsTree = new Funnel(modulesTree, {include: ['**/*'], exclude: ['**/*.{html,ts,dart}'], destDir: '/'}); var scripts = mergeTrees(servingTrees); var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/polymer.html', 'bower_components/polymer/polymer-micro.html', 'bower_components/polymer/polymer-mini.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); var reactFiles = new Funnel('.', {files: ['node_modules/react/dist/react.min.js']}); var react = stew.mv(flatten(reactFiles), 'benchmarks_external/src/tree/react'); htmlTree = mergeTrees([htmlTree, scripts, polymer, react]); es5Tree = mergeTrees([es5Tree, htmlTree, assetsTree, clientModules]); es6Tree = mergeTrees([es6Tree, htmlTree, assetsTree, clientModules]); var mergedTree = mergeTrees([stew.mv(es6Tree, '/es6'), stew.mv(es5Tree, '/es5')]); return destCopy(mergedTree, destinationPath); };
module.exports = function makeBrowserTree(options) { var modulesTree = new Funnel( 'modules', {include: ['**/**'], exclude: ['**/*.cjs', 'benchmarks/e2e_test/**'], destDir: '/'}); // Use Traceur to transpile original sources to ES6 var es6Tree = new TraceurCompiler(modulesTree, '.es6', '.map', { sourceMaps: true, annotations: true, // parse annotations types: true, // parse types script: false, // parse as a module memberVariables: true, // parse class fields modules: 'instantiate', typeAssertionModule: 'rtts_assert/rtts_assert', typeAssertions: options.typeAssertions, outputLanguage: 'es6' }); // Call Traceur again to lower the ES6 build tree to ES5 var es5Tree = new TraceurCompiler(es6Tree, '.js', '.js.map', {modules: 'instantiate', sourceMaps: true}); // Now we add a few more files to the es6 tree that Traceur should not see ['angular2', 'rtts_assert'].forEach(function(destDir) { var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: destDir}); es6Tree = mergeTrees([es6Tree, extras]); }); var vendorScriptsTree = flatten(new Funnel('.', { files: [ 'node_modules/es6-module-loader/dist/es6-module-loader-sans-promises.src.js', 'node_modules/zone.js/zone.js', 'node_modules/zone.js/long-stack-trace-zone.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/systemjs/lib/extension-register.js', 'node_modules/systemjs/lib/extension-cjs.js', 'node_modules/rx/dist/rx.all.js', 'tools/build/snippets/runtime_paths.js', path.relative(projectRootDir, TraceurCompiler.RUNTIME_PATH) ] })); var vendorScripts_benchmark = new Funnel('tools/build/snippets', {files: ['url_params_to_form.js'], destDir: '/'}); var vendorScripts_benchmarks_external = new Funnel('node_modules/angular', {files: ['angular.js'], destDir: '/'}); var servingTrees = []; function copyVendorScriptsTo(destDir) { servingTrees.push(new Funnel(vendorScriptsTree, {srcDir: '/', destDir: destDir})); if (destDir.indexOf('benchmarks') > -1) { servingTrees.push(new Funnel(vendorScripts_benchmark, {srcDir: '/', destDir: destDir})); } if (destDir.indexOf('benchmarks_external') > -1) { servingTrees.push( new Funnel(vendorScripts_benchmarks_external, {srcDir: '/', destDir: destDir})); } } function writeScriptsForPath(relativePath, result) { copyVendorScriptsTo(path.dirname(relativePath)); return result.replace('@@FILENAME_NO_EXT', relativePath.replace(/\.\w+$/, '')); } var htmlTree = new Funnel(modulesTree, {include: ['*/src/**/*.html'], destDir: '/'}); htmlTree = replace(htmlTree, { files: ['examples*/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS')}], replaceWithPath: writeScriptsForPath }); htmlTree = replace(htmlTree, { files: ['benchmarks/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks')}], replaceWithPath: writeScriptsForPath }); htmlTree = replace(htmlTree, { files: ['benchmarks_external/**'], patterns: [{match: /\$SCRIPTS\$/, replacement: htmlReplace('SCRIPTS_benchmarks_external')}], replaceWithPath: writeScriptsForPath }); // Copy all vendor scripts into all examples and benchmarks ['benchmarks/src', 'benchmarks_external/src', 'examples/src/benchpress'].forEach( copyVendorScriptsTo); var scripts = mergeTrees(servingTrees, {overwrite: true}); var css = new Funnel(modulesTree, {include: ["**/*.css"]}); var polymerFiles = new Funnel('.', { files: [ 'bower_components/polymer/lib/polymer.html', 'tools/build/snippets/url_params_to_form.js' ] }); var polymer = stew.mv(flatten(polymerFiles), 'benchmarks_external/src/tree/polymer'); htmlTree = mergeTrees([htmlTree, scripts, polymer, css]); es5Tree = mergeTrees([es5Tree, htmlTree]); return mergeTrees([ stew.mv(es6Tree, 'js/' + options.name + '/es6'), stew.mv(es5Tree, 'js/' + options.name + '/es5') ]); };