From 40e5207d4e0c3d9808a2bdd6dc38842b053777fb Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 4 Dec 2015 21:50:14 -0800 Subject: [PATCH 1/2] chore(release): v0.0.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b3f361c5f0b8..f4a074d89486 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-cli", - "version": "0.0.14", + "version": "0.0.15", "description": "", "main": "lib/cli/index.js", "trackingCode": "UA-8594346-19", From 563e6e2cd2c72604caff59be50ac0bfe7e02404e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 10 Dec 2015 03:13:50 -0800 Subject: [PATCH 2/2] feat: update to angular2@2.0.0-alpha.52 and typescript@1.7.3 --- addon/ng2/blueprints/ng2/files/package.json | 7 +++- lib/broccoli/broccoli-typescript.js | 39 ++++++++++++++++++--- lib/broccoli/broccoli-typescript.js.map | 2 +- lib/broccoli/diffing-broccoli-plugin.js | 17 ++++++--- lib/broccoli/diffing-broccoli-plugin.js.map | 2 +- lib/broccoli/tree-differ.js | 2 +- package.json | 2 +- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/addon/ng2/blueprints/ng2/files/package.json b/addon/ng2/blueprints/ng2/files/package.json index f4514e2ae2f4..2583a12ead48 100644 --- a/addon/ng2/blueprints/ng2/files/package.json +++ b/addon/ng2/blueprints/ng2/files/package.json @@ -3,8 +3,13 @@ "version": "0.0.0", "license": "Apache-2.0", "dependencies": { + "angular2": "2.0.0-alpha.52", + "es6-promise": "^3.0.2", + "es6-shim": "^0.33.3", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-alpha.14", "systemjs": "0.19.4", - "angular2": "2.0.0-alpha.48" + "zone.js": "0.5.8" }, "devDependencies": { "angular-cli": "0.0.*", diff --git a/lib/broccoli/broccoli-typescript.js b/lib/broccoli/broccoli-typescript.js index 72ff491a85f2..dab2d6dc0958 100644 --- a/lib/broccoli/broccoli-typescript.js +++ b/lib/broccoli/broccoli-typescript.js @@ -32,9 +32,10 @@ var DiffingTSCompiler = (function () { else { this.rootFilePaths = []; } - // in tsc 1.7.x this api was renamed to parseJsonConfigFileContent // the conversion is a bit awkward, see https://github.com/Microsoft/TypeScript/issues/5276 - this.tsOpts = ts.parseConfigFile({ compilerOptions: options, files: [] }, null, null).options; + // in 1.8 use convertCompilerOptionsFromJson + this.tsOpts = + ts.parseJsonConfigFileContent({ compilerOptions: options, files: [] }, null, null).options; // TODO: the above turns rootDir set to './' into an empty string - looks like a tsc bug // check back when we upgrade to 1.7.x if (this.tsOpts.rootDir === '') { @@ -84,7 +85,7 @@ var DiffingTSCompiler = (function () { output.outputFiles.forEach(function (o) { var destDirPath = path.dirname(o.name); fse.mkdirsSync(destDirPath); - fs.writeFileSync(o.name, o.text, FS_OPTS); + fs.writeFileSync(o.name, _this.fixSourceMapSources(o.text), FS_OPTS); }); } }); @@ -119,10 +120,11 @@ var DiffingTSCompiler = (function () { } }; DiffingTSCompiler.prototype.doFullBuild = function () { + var _this = this; var program = this.tsService.getProgram(); var emitResult = program.emit(undefined, function (absoluteFilePath, fileContent) { fse.mkdirsSync(path.dirname(absoluteFilePath)); - fs.writeFileSync(absoluteFilePath, fileContent, FS_OPTS); + fs.writeFileSync(absoluteFilePath, _this.fixSourceMapSources(fileContent), FS_OPTS); }); if (emitResult.emitSkipped) { var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); @@ -147,6 +149,33 @@ var DiffingTSCompiler = (function () { } } }; + /** + * There is a bug in TypeScript 1.6, where the sourceRoot and inlineSourceMap properties + * are exclusive. This means that the sources property always contains relative paths + * (e.g, ../../../../angular2/src/di/injector.ts). + * + * Here, we normalize the sources property and remove the ../../../ + * + * This issue is fixed in https://github.com/Microsoft/TypeScript/pull/5620. + * Once we switch to TypeScript 1.8, we can remove this method. + */ + DiffingTSCompiler.prototype.fixSourceMapSources = function (content) { + try { + var marker = "//# sourceMappingURL=data:application/json;base64,"; + var index = content.indexOf(marker); + if (index == -1) + return content; + var base = content.substring(0, index + marker.length); + var sourceMapBit = new Buffer(content.substring(index + marker.length), 'base64').toString("utf8"); + var sourceMaps = JSON.parse(sourceMapBit); + var source = sourceMaps.sources[0]; + sourceMaps.sources = [source.substring(source.lastIndexOf("../") + 3)]; + return "" + base + new Buffer(JSON.stringify(sourceMaps)).toString('base64'); + } + catch (e) { + return content; + } + }; DiffingTSCompiler.prototype.removeOutputFor = function (tsFilePath) { var absoluteJsFilePath = path.join(this.cachePath, tsFilePath.replace(/\.ts$/, '.js')); var absoluteMapFilePath = path.join(this.cachePath, tsFilePath.replace(/.ts$/, '.js.map')); @@ -200,7 +229,7 @@ var CustomLanguageServiceHost = (function () { tsFilePath.match(/^node_modules/)) { absoluteTsFilePath = path.resolve(tsFilePath); } - else if (tsFilePath.match(/^@reactivex/)) { + else if (tsFilePath.match(/^rxjs/)) { absoluteTsFilePath = path.resolve('node_modules', tsFilePath); } else { diff --git a/lib/broccoli/broccoli-typescript.js.map b/lib/broccoli/broccoli-typescript.js.map index 5b80d1514e4a..dd501914e71f 100644 --- a/lib/broccoli/broccoli-typescript.js.map +++ b/lib/broccoli/broccoli-typescript.js.map @@ -1 +1 @@ -{"version":3,"sources":["broccoli/broccoli-typescript.ts"],"names":["DiffingTSCompiler","DiffingTSCompiler.constructor","DiffingTSCompiler.rebuild","DiffingTSCompiler.collectErrors","DiffingTSCompiler.doFullBuild","DiffingTSCompiler.removeOutputFor","CustomLanguageServiceHost","CustomLanguageServiceHost.constructor","CustomLanguageServiceHost.getScriptFileNames","CustomLanguageServiceHost.getScriptVersion","CustomLanguageServiceHost.getScriptSnapshot","CustomLanguageServiceHost.getCurrentDirectory","CustomLanguageServiceHost.getCompilationSettings","CustomLanguageServiceHost.getDefaultLibFileName"],"mappings":"AAAA,kDAAkD;AAElD,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAC1B,IAAO,GAAG,WAAW,UAAU,CAAC,CAA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A,sBAAsBA,EAAEA,UAAUA,CAACA,CAACA;YAEhDA,KAAIA,CAACA,aAAaA,CAACA,MAAMA,CAACA,KAAIA,CAACA,aAAaA,CAACA,OAAOA,CAACA,UAAUA,CAACA,EAAEA,CAACA,CAACA,CAACA;YACrEA,KAAIA,CAACA,YAAYA,CAACA,UAAUA,CAACA,GAAGA,IAAIA,CAACA;YACrCA,KAAIA,CAACA,eAAeA,CAACA,UAAUA,CAACA,CAACA;QACnCA,CAACA,CAACA,CAACA;QAEHA,EAAEA,CAACA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;YAClBA,IAAIA,CAACA,QAAQA,GAAGA,KAAKA,CAACA;YACtBA,IAAIA,CAACA,WAAWA,EAAEA,CAACA;QACrBA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACNA,WAAWA,CAACA,OAAOA,CAACA,UAACA,UAAUA;gBAC7BA,IAAIA,MAAMA,GAAGA,KAAIA,CAACA,SAASA,CAACA,aAAaA,CAACA,UAAUA,CAACA,CAACA;gBAEtDA,EAAEA,CAACA,CAACA,MAAMA,CAACA,WAAWA,CAACA,CAACA,CAACA;oBACvBA,IAAIA,UAAUA,GAAGA,KAAIA,CAACA,aAAaA,CAACA,UAAUA,CAACA,CAACA;oBAChDA,EAAEA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA;wBACfA,eAAeA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA;wBACjCA,aAAaA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA;oBACjCA,CAACA;gBACHA,CAACA;gBAACA,IAAIA,CAACA,CAACA;oBACNA,MAAMA,CAACA,WAAWA,CAACA,OAAOA,CAACA,UAAAA,CAACA;wBAC1BA,IAAIA,WAAWA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA;wBACvCA,GAAGA,CAACA,UAAUA,CAACA,WAAWA,CAACA,CAACA;wBAC5BA,EAAEA,CAACA,aAAaA,CAAC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,CAACA,cAAcA,CAACA,UAAUA,CAACA,EAAEA,CAACA,YAAYA,CAACA,kBAAkBA,EAAEA,OAAOA,CAACA,CAACA,CAACA;IACpFA,CAACA;IAGDJ,uDAAmBA,GAAnBA,cAAgCK,MAAMA,CAACA,IAAIA,CAACA,gBAAgBA,CAACA,CAACA,CAACA;IAE/DL,0DAAsBA,GAAtBA,cAA+CM,MAAMA,CAACA,IAAIA,CAACA,eAAeA,CAACA,CAACA,CAACA;IAE7EN,yDAAqBA,GAArBA,UAAsBA,OAA2BA;QAC/CO,uFAAuFA;QACvFA,MAAMA,CAACA,IAAIA,CAACA,kBAAkBA,CAACA;IACjCA,CAACA;IACHP,gCAACA;AAADA,CArEA,AAqECA,IAAA;AAGD;kBAAe,2CAAiB,CAAC,iBAAiB,CAAC,CAAC","file":"broccoli/broccoli-typescript.js","sourcesContent":["/// \n\nimport fs = require('fs');\nimport fse = require('fs-extra');\nimport path = require('path');\nimport * as ts from 'typescript';\nimport {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';\n\n\ntype FileRegistry = ts.Map<{version: number}>;\n\nconst FS_OPTS = {\n encoding: 'utf-8'\n};\n\n\n/**\n * Broccoli plugin that implements incremental Typescript compiler.\n *\n * It instantiates a typescript compiler instance that keeps all the state about the project and\n * can re-emit only the files that actually changed.\n *\n * Limitations: only files that map directly to the changed source file via naming conventions are\n * re-emitted. This primarily affects code that uses `const enum`s, because changing the enum value\n * requires global emit, which can affect many files.\n */\nclass DiffingTSCompiler implements DiffingBroccoliPlugin {\n private tsOpts: ts.CompilerOptions;\n private fileRegistry: FileRegistry = Object.create(null);\n private rootFilePaths: string[];\n private tsServiceHost: ts.LanguageServiceHost;\n private tsService: ts.LanguageService;\n private firstRun: boolean = true;\n private previousRunFailed: boolean = false;\n\n static includeExtensions = ['.ts'];\n static excludeExtensions = ['.d.ts'];\n\n constructor(public inputPath: string, public cachePath: string, public options) {\n if (options.rootFilePaths) {\n this.rootFilePaths = options.rootFilePaths.splice(0);\n delete options.rootFilePaths;\n } else {\n this.rootFilePaths = [];\n }\n\n // in tsc 1.7.x this api was renamed to parseJsonConfigFileContent\n // the conversion is a bit awkward, see https://github.com/Microsoft/TypeScript/issues/5276\n this.tsOpts = ts.parseConfigFile({compilerOptions: options, files: []}, null, null).options;\n\n // TODO: the above turns rootDir set to './' into an empty string - looks like a tsc bug\n // check back when we upgrade to 1.7.x\n if (this.tsOpts.rootDir === '') {\n this.tsOpts.rootDir = './';\n }\n this.tsOpts.outDir = this.cachePath;\n\n this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths,\n this.fileRegistry, this.inputPath);\n this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry());\n }\n\n\n rebuild(treeDiff: DiffResult) {\n let pathsToEmit = [];\n let pathsWithErrors = [];\n let errorMessages = [];\n\n treeDiff.addedPaths.concat(treeDiff.changedPaths)\n .forEach((tsFilePath) => {\n if (!this.fileRegistry[tsFilePath]) {\n this.fileRegistry[tsFilePath] = {version: 0};\n this.rootFilePaths.push(tsFilePath);\n } else {\n this.fileRegistry[tsFilePath].version++;\n }\n\n pathsToEmit.push(tsFilePath);\n });\n\n treeDiff.removedPaths.forEach((tsFilePath) => {\n console.log('removing outputs for', tsFilePath);\n\n this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1);\n this.fileRegistry[tsFilePath] = null;\n this.removeOutputFor(tsFilePath);\n });\n\n if (this.firstRun) {\n this.firstRun = false;\n this.doFullBuild();\n } else {\n pathsToEmit.forEach((tsFilePath) => {\n let output = this.tsService.getEmitOutput(tsFilePath);\n\n if (output.emitSkipped) {\n let errorFound = this.collectErrors(tsFilePath);\n if (errorFound) {\n pathsWithErrors.push(tsFilePath);\n errorMessages.push(errorFound);\n }\n } else {\n output.outputFiles.forEach(o => {\n let destDirPath = path.dirname(o.name);\n fse.mkdirsSync(destDirPath);\n fs.writeFileSync(o.name, o.text, FS_OPTS);\n });\n }\n });\n\n if (pathsWithErrors.length) {\n this.previousRunFailed = true;\n var error =\n new Error('Typescript found the following errors:\\n' + errorMessages.join('\\n'));\n error['showStack'] = false;\n throw error;\n } else if (this.previousRunFailed) {\n this.doFullBuild();\n }\n }\n }\n\n\n private collectErrors(tsFilePath): String {\n let allDiagnostics = this.tsService.getCompilerOptionsDiagnostics()\n .concat(this.tsService.getSyntacticDiagnostics(tsFilePath))\n .concat(this.tsService.getSemanticDiagnostics(tsFilePath));\n let errors = [];\n\n allDiagnostics.forEach(diagnostic => {\n let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\");\n if (diagnostic.file) {\n let {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n errors.push(` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);\n } else {\n errors.push(` Error: ${message}`);\n }\n });\n\n if (errors.length) {\n return errors.join('\\n');\n }\n }\n\n\n private doFullBuild() {\n let program = this.tsService.getProgram();\n let emitResult = program.emit(undefined, function(absoluteFilePath, fileContent) {\n fse.mkdirsSync(path.dirname(absoluteFilePath));\n fs.writeFileSync(absoluteFilePath, fileContent, FS_OPTS);\n });\n\n if (emitResult.emitSkipped) {\n let allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);\n let errorMessages = [];\n\n allDiagnostics.forEach(diagnostic => {\n var pos = '';\n if (diagnostic.file) {\n var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n pos = `${diagnostic.file.fileName} (${line + 1}, ${character + 1}): `\n }\n var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n errorMessages.push(` ${pos}${message}`);\n });\n\n if (errorMessages.length) {\n this.previousRunFailed = true;\n var error =\n new Error('Typescript found the following errors:\\n' + errorMessages.join('\\n'));\n error['showStack'] = false;\n throw error;\n } else {\n this.previousRunFailed = false;\n }\n }\n }\n\n\n private removeOutputFor(tsFilePath: string) {\n let absoluteJsFilePath = path.join(this.cachePath, tsFilePath.replace(/\\.ts$/, '.js'));\n let absoluteMapFilePath = path.join(this.cachePath, tsFilePath.replace(/.ts$/, '.js.map'));\n let absoluteDtsFilePath = path.join(this.cachePath, tsFilePath.replace(/\\.ts$/, '.d.ts'));\n\n if (fs.existsSync(absoluteJsFilePath)) {\n fs.unlinkSync(absoluteJsFilePath);\n fs.unlinkSync(absoluteMapFilePath);\n fs.unlinkSync(absoluteDtsFilePath);\n }\n }\n}\n\n\nclass CustomLanguageServiceHost implements ts.LanguageServiceHost {\n private currentDirectory: string;\n private defaultLibFilePath: string;\n\n\n constructor(private compilerOptions: ts.CompilerOptions, private fileNames: string[],\n private fileRegistry: FileRegistry, private treeInputPath: string) {\n this.currentDirectory = process.cwd();\n this.defaultLibFilePath = ts.getDefaultLibFilePath(compilerOptions).replace(/\\\\/g, '/');\n }\n\n\n getScriptFileNames(): string[] { return this.fileNames; }\n\n\n getScriptVersion(fileName: string): string {\n return this.fileRegistry[fileName] && this.fileRegistry[fileName].version.toString();\n }\n\n\n /**\n * This method is called quite a bit to lookup 3 kinds of paths:\n * 1/ files in the fileRegistry\n * - these are the files in our project that we are watching for changes\n * - in the future we could add caching for these files and invalidate the cache when\n * the file is changed lazily during lookup\n * 2/ .d.ts and library files not in the fileRegistry\n * - these are not our files, they come from tsd or typescript itself\n * - these files change only rarely but since we need them very rarely, it's not worth the\n * cache invalidation hassle to cache them\n * 3/ bogus paths that typescript compiler tries to lookup during import resolution\n * - these paths are tricky to cache since files come and go and paths that was bogus in the\n * past might not be bogus later\n *\n * In the initial experiments the impact of this caching was insignificant (single digit %) and\n * not worth the potential issues with stale cache records.\n */\n getScriptSnapshot(tsFilePath: string): ts.IScriptSnapshot {\n let absoluteTsFilePath;\n\n if (tsFilePath == this.defaultLibFilePath || path.isAbsolute(tsFilePath)) {\n absoluteTsFilePath = tsFilePath;\n } else if (this.compilerOptions.moduleResolution === ts.ModuleResolutionKind.NodeJs &&\n tsFilePath.match(/^node_modules/)) {\n absoluteTsFilePath = path.resolve(tsFilePath);\n } else if (tsFilePath.match(/^@reactivex/)) {\n absoluteTsFilePath = path.resolve('node_modules', tsFilePath);\n } else {\n absoluteTsFilePath = path.join(this.treeInputPath, tsFilePath);\n }\n\n\n if (!fs.existsSync(absoluteTsFilePath)) {\n // TypeScript seems to request lots of bogus paths during import path lookup and resolution,\n // so we we just return undefined when the path is not correct.\n return undefined;\n }\n return ts.ScriptSnapshot.fromString(fs.readFileSync(absoluteTsFilePath, FS_OPTS));\n }\n\n\n getCurrentDirectory(): string { return this.currentDirectory; }\n\n getCompilationSettings(): ts.CompilerOptions { return this.compilerOptions; }\n\n getDefaultLibFileName(options: ts.CompilerOptions): string {\n // ignore options argument, options should not change during the lifetime of the plugin\n return this.defaultLibFilePath;\n }\n}\n\n\nexport default wrapDiffingPlugin(DiffingTSCompiler);\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["broccoli/broccoli-typescript.ts"],"names":["DiffingTSCompiler","DiffingTSCompiler.constructor","DiffingTSCompiler.rebuild","DiffingTSCompiler.collectErrors","DiffingTSCompiler.doFullBuild","DiffingTSCompiler.fixSourceMapSources","DiffingTSCompiler.removeOutputFor","CustomLanguageServiceHost","CustomLanguageServiceHost.constructor","CustomLanguageServiceHost.getScriptFileNames","CustomLanguageServiceHost.getScriptVersion","CustomLanguageServiceHost.getScriptSnapshot","CustomLanguageServiceHost.getCurrentDirectory","CustomLanguageServiceHost.getCompilationSettings","CustomLanguageServiceHost.getDefaultLibFileName"],"mappings":"AAAA,kDAAkD;AAElD,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAC1B,IAAO,GAAG,WAAW,UAAU,CAAC,CAAC;AACjC,IAAO,IAAI,WAAW,MAAM,CAAC,CAAC;AAC9B,IAAY,EAAE,WAAM,YAAY,CAAC,CAAA;AACjC,wCAAmE,2BAA2B,CAAC,CAAA;AAK/F,IAAM,OAAO,GAAG;IACd,QAAQ,EAAE,OAAO;CAClB,CAAC;AAGF;;;;;;;;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A,UAAUA,CAACA,GAAGA,IAAIA,CAACA;YACrCA,KAAIA,CAACA,eAAeA,CAACA,UAAUA,CAACA,CAACA;QACnCA,CAACA,CAACA,CAACA;QAEHA,EAAEA,CAACA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA,CAACA;YAClBA,IAAIA,CAACA,QAAQA,GAAGA,KAAKA,CAACA;YACtBA,IAAIA,CAACA,WAAWA,EAAEA,CAACA;QACrBA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACNA,WAAWA,CAACA,OAAOA,CAACA,UAACA,UAAUA;gBAC7BA,IAAIA,MAAMA,GAAGA,KAAIA,CAACA,SAASA,CAACA,aAAaA,CAACA,UAAUA,CAACA,CAACA;gBAEtDA,EAAEA,CAACA,CAACA,MAAMA,CAACA,WAAWA,CAACA,CAACA,CAACA;oBACvBA,IAAIA,UAAUA,GAAGA,KAAIA,CAACA,aAAaA,CAACA,UAAUA,CAACA,CAACA;oBAChDA,EAAEA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA;wBACfA,eAAeA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA;wBACjCA,aAAaA,CAACA,IAAIA,CAACA,UAAUA,CAACA,CAACA;oBACjCA,CAACA;gBACHA,CAACA;gBAACA,IAAIA,CAACA,CAACA;oBACNA,MAAMA,CAACA,WAAWA,CAACA,OAAOA,CAACA,UAAAA,CAACA;wBAC1BA,IAAIA,WAAWA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA;wBACvCA,GAAGA,CAACA,UAAUA,CAACA,WAAWA,CAACA,CAACA;wBAC5BA,EAAEA,CAACA,aAAaA,CAACA,CAACA,CAACA,IAAIA,EAAEA,KAAIA,CAACA,mBAAmBA,CAACA,CAACA,CAACA,IAAIA,CAACA,EAAEA,OAAOA,CAACA,CAACA;oBACtEA,CAACA,CAACA,CAACA;gBACLA,CAACA;YACHA,CAACA,CAACA,CAACA;YAEHA,EAAEA,CAACA,CA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A,CAACA,CAACA,CAACA;IAE/DL,0DAAsBA,GAAtBA,cAA+CM,MAAMA,CAACA,IAAIA,CAACA,eAAeA,CAACA,CAACA,CAACA;IAE7EN,yDAAqBA,GAArBA,UAAsBA,OAA2BA;QAC/CO,uFAAuFA;QACvFA,MAAMA,CAACA,IAAIA,CAACA,kBAAkBA,CAACA;IACjCA,CAACA;IACHP,gCAACA;AAADA,CArEA,AAqECA,IAAA;AAGD;kBAAe,2CAAiB,CAAC,iBAAiB,CAAC,CAAC","file":"broccoli/broccoli-typescript.js","sourcesContent":["/// \n\nimport fs = require('fs');\nimport fse = require('fs-extra');\nimport path = require('path');\nimport * as ts from 'typescript';\nimport {wrapDiffingPlugin, DiffingBroccoliPlugin, DiffResult} from './diffing-broccoli-plugin';\n\n\ntype FileRegistry = ts.Map<{version: number}>;\n\nconst FS_OPTS = {\n encoding: 'utf-8'\n};\n\n\n/**\n * Broccoli plugin that implements incremental Typescript compiler.\n *\n * It instantiates a typescript compiler instance that keeps all the state about the project and\n * can re-emit only the files that actually changed.\n *\n * Limitations: only files that map directly to the changed source file via naming conventions are\n * re-emitted. This primarily affects code that uses `const enum`s, because changing the enum value\n * requires global emit, which can affect many files.\n */\nclass DiffingTSCompiler implements DiffingBroccoliPlugin {\n private tsOpts: ts.CompilerOptions;\n private fileRegistry: FileRegistry = Object.create(null);\n private rootFilePaths: string[];\n private tsServiceHost: ts.LanguageServiceHost;\n private tsService: ts.LanguageService;\n private firstRun: boolean = true;\n private previousRunFailed: boolean = false;\n\n static includeExtensions = ['.ts'];\n static excludeExtensions = ['.d.ts'];\n\n constructor(public inputPath: string, public cachePath: string, public options) {\n if (options.rootFilePaths) {\n this.rootFilePaths = options.rootFilePaths.splice(0);\n delete options.rootFilePaths;\n } else {\n this.rootFilePaths = [];\n }\n\n // the conversion is a bit awkward, see https://github.com/Microsoft/TypeScript/issues/5276\n // in 1.8 use convertCompilerOptionsFromJson\n this.tsOpts =\n ts.parseJsonConfigFileContent({compilerOptions: options, files: []}, null, null).options;\n\n // TODO: the above turns rootDir set to './' into an empty string - looks like a tsc bug\n // check back when we upgrade to 1.7.x\n if (this.tsOpts.rootDir === '') {\n this.tsOpts.rootDir = './';\n }\n this.tsOpts.outDir = this.cachePath;\n\n this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths,\n this.fileRegistry, this.inputPath);\n this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry());\n }\n\n\n rebuild(treeDiff: DiffResult) {\n let pathsToEmit = [];\n let pathsWithErrors = [];\n let errorMessages = [];\n\n treeDiff.addedPaths.concat(treeDiff.changedPaths)\n .forEach((tsFilePath) => {\n if (!this.fileRegistry[tsFilePath]) {\n this.fileRegistry[tsFilePath] = {version: 0};\n this.rootFilePaths.push(tsFilePath);\n } else {\n this.fileRegistry[tsFilePath].version++;\n }\n\n pathsToEmit.push(tsFilePath);\n });\n\n treeDiff.removedPaths.forEach((tsFilePath) => {\n console.log('removing outputs for', tsFilePath);\n\n this.rootFilePaths.splice(this.rootFilePaths.indexOf(tsFilePath), 1);\n this.fileRegistry[tsFilePath] = null;\n this.removeOutputFor(tsFilePath);\n });\n\n if (this.firstRun) {\n this.firstRun = false;\n this.doFullBuild();\n } else {\n pathsToEmit.forEach((tsFilePath) => {\n let output = this.tsService.getEmitOutput(tsFilePath);\n\n if (output.emitSkipped) {\n let errorFound = this.collectErrors(tsFilePath);\n if (errorFound) {\n pathsWithErrors.push(tsFilePath);\n errorMessages.push(errorFound);\n }\n } else {\n output.outputFiles.forEach(o => {\n let destDirPath = path.dirname(o.name);\n fse.mkdirsSync(destDirPath);\n fs.writeFileSync(o.name, this.fixSourceMapSources(o.text), FS_OPTS);\n });\n }\n });\n\n if (pathsWithErrors.length) {\n this.previousRunFailed = true;\n var error =\n new Error('Typescript found the following errors:\\n' + errorMessages.join('\\n'));\n error['showStack'] = false;\n throw error;\n } else if (this.previousRunFailed) {\n this.doFullBuild();\n }\n }\n }\n\n\n private collectErrors(tsFilePath): String {\n let allDiagnostics = this.tsService.getCompilerOptionsDiagnostics()\n .concat(this.tsService.getSyntacticDiagnostics(tsFilePath))\n .concat(this.tsService.getSemanticDiagnostics(tsFilePath));\n let errors = [];\n\n allDiagnostics.forEach(diagnostic => {\n let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, \"\\n\");\n if (diagnostic.file) {\n let {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n errors.push(` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);\n } else {\n errors.push(` Error: ${message}`);\n }\n });\n\n if (errors.length) {\n return errors.join('\\n');\n }\n }\n\n\n private doFullBuild() {\n let program = this.tsService.getProgram();\n let emitResult = program.emit(undefined, (absoluteFilePath, fileContent) => {\n fse.mkdirsSync(path.dirname(absoluteFilePath));\n fs.writeFileSync(absoluteFilePath, this.fixSourceMapSources(fileContent), FS_OPTS);\n });\n\n if (emitResult.emitSkipped) {\n let allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);\n let errorMessages = [];\n\n allDiagnostics.forEach(diagnostic => {\n var pos = '';\n if (diagnostic.file) {\n var {line, character} = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);\n pos = `${diagnostic.file.fileName} (${line + 1}, ${character + 1}): `\n }\n var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n errorMessages.push(` ${pos}${message}`);\n });\n\n if (errorMessages.length) {\n this.previousRunFailed = true;\n var error =\n new Error('Typescript found the following errors:\\n' + errorMessages.join('\\n'));\n error['showStack'] = false;\n throw error;\n } else {\n this.previousRunFailed = false;\n }\n }\n }\n\n /**\n * There is a bug in TypeScript 1.6, where the sourceRoot and inlineSourceMap properties\n * are exclusive. This means that the sources property always contains relative paths\n * (e.g, ../../../../angular2/src/di/injector.ts).\n *\n * Here, we normalize the sources property and remove the ../../../\n *\n * This issue is fixed in https://github.com/Microsoft/TypeScript/pull/5620.\n * Once we switch to TypeScript 1.8, we can remove this method.\n */\n private fixSourceMapSources(content: string): string {\n try {\n const marker = \"//# sourceMappingURL=data:application/json;base64,\";\n const index = content.indexOf(marker);\n if (index == -1) return content;\n\n const base = content.substring(0, index + marker.length);\n const sourceMapBit =\n new Buffer(content.substring(index + marker.length), 'base64').toString(\"utf8\");\n const sourceMaps = JSON.parse(sourceMapBit);\n const source = sourceMaps.sources[0];\n sourceMaps.sources = [source.substring(source.lastIndexOf(\"../\") + 3)];\n return `${base}${new Buffer(JSON.stringify(sourceMaps)).toString('base64')}`;\n } catch (e) {\n return content;\n }\n }\n\n private removeOutputFor(tsFilePath: string) {\n let absoluteJsFilePath = path.join(this.cachePath, tsFilePath.replace(/\\.ts$/, '.js'));\n let absoluteMapFilePath = path.join(this.cachePath, tsFilePath.replace(/.ts$/, '.js.map'));\n let absoluteDtsFilePath = path.join(this.cachePath, tsFilePath.replace(/\\.ts$/, '.d.ts'));\n\n if (fs.existsSync(absoluteJsFilePath)) {\n fs.unlinkSync(absoluteJsFilePath);\n fs.unlinkSync(absoluteMapFilePath);\n fs.unlinkSync(absoluteDtsFilePath);\n }\n }\n}\n\n\nclass CustomLanguageServiceHost implements ts.LanguageServiceHost {\n private currentDirectory: string;\n private defaultLibFilePath: string;\n\n\n constructor(private compilerOptions: ts.CompilerOptions, private fileNames: string[],\n private fileRegistry: FileRegistry, private treeInputPath: string) {\n this.currentDirectory = process.cwd();\n this.defaultLibFilePath = ts.getDefaultLibFilePath(compilerOptions).replace(/\\\\/g, '/');\n }\n\n\n getScriptFileNames(): string[] { return this.fileNames; }\n\n\n getScriptVersion(fileName: string): string {\n return this.fileRegistry[fileName] && this.fileRegistry[fileName].version.toString();\n }\n\n\n /**\n * This method is called quite a bit to lookup 3 kinds of paths:\n * 1/ files in the fileRegistry\n * - these are the files in our project that we are watching for changes\n * - in the future we could add caching for these files and invalidate the cache when\n * the file is changed lazily during lookup\n * 2/ .d.ts and library files not in the fileRegistry\n * - these are not our files, they come from tsd or typescript itself\n * - these files change only rarely but since we need them very rarely, it's not worth the\n * cache invalidation hassle to cache them\n * 3/ bogus paths that typescript compiler tries to lookup during import resolution\n * - these paths are tricky to cache since files come and go and paths that was bogus in the\n * past might not be bogus later\n *\n * In the initial experiments the impact of this caching was insignificant (single digit %) and\n * not worth the potential issues with stale cache records.\n */\n getScriptSnapshot(tsFilePath: string): ts.IScriptSnapshot {\n let absoluteTsFilePath;\n\n if (tsFilePath == this.defaultLibFilePath || path.isAbsolute(tsFilePath)) {\n absoluteTsFilePath = tsFilePath;\n } else if (this.compilerOptions.moduleResolution === ts.ModuleResolutionKind.NodeJs &&\n tsFilePath.match(/^node_modules/)) {\n absoluteTsFilePath = path.resolve(tsFilePath);\n } else if (tsFilePath.match(/^rxjs/)) {\n absoluteTsFilePath = path.resolve('node_modules', tsFilePath);\n } else {\n absoluteTsFilePath = path.join(this.treeInputPath, tsFilePath);\n }\n\n\n if (!fs.existsSync(absoluteTsFilePath)) {\n // TypeScript seems to request lots of bogus paths during import path lookup and resolution,\n // so we we just return undefined when the path is not correct.\n return undefined;\n }\n return ts.ScriptSnapshot.fromString(fs.readFileSync(absoluteTsFilePath, FS_OPTS));\n }\n\n\n getCurrentDirectory(): string { return this.currentDirectory; }\n\n getCompilationSettings(): ts.CompilerOptions { return this.compilerOptions; }\n\n getDefaultLibFileName(options: ts.CompilerOptions): string {\n // ignore options argument, options should not change during the lifetime of the plugin\n return this.defaultLibFilePath;\n }\n}\n\n\nexport default wrapDiffingPlugin(DiffingTSCompiler);\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/broccoli/diffing-broccoli-plugin.js b/lib/broccoli/diffing-broccoli-plugin.js index b658c79313cc..9c0e2a234cbf 100644 --- a/lib/broccoli/diffing-broccoli-plugin.js +++ b/lib/broccoli/diffing-broccoli-plugin.js @@ -14,7 +14,7 @@ exports.DiffResult = tree_differ_2.DiffResult; * an instance of BroccoliTree. * * @param pluginClass - * @returns {DiffingPlugin} + * @returns {DiffingBroccoliPlugin} */ function wrapDiffingPlugin(pluginClass) { return function () { return new DiffingPluginWrapper(pluginClass, arguments); }; @@ -132,17 +132,24 @@ var DiffingPluginWrapper = (function () { DiffingPluginWrapper.prototype.stabilizeTrees = function (trees) { // Prevent extensions to prevent array from being mutated from the outside. // For-loop used to avoid re-allocating a new array. + var stableTrees = []; for (var i = 0; i < trees.length; ++i) { - trees[i] = this.stabilizeTree(trees[i]); + // ignore null/undefined input tries in order to support conditional build pipelines + if (trees[i]) { + stableTrees.push(this.stabilizeTree(trees[i])); + } + } + if (stableTrees.length === 0) { + throw new Error('No input trees provided!'); } - return Object.freeze(trees); + return Object.freeze(stableTrees); }; DiffingPluginWrapper.prototype.stabilizeTree = function (tree) { // Ignore all DiffingPlugins as they are already stable, for others we don't know for sure // so we need to stabilize them. // Since it's not safe to use instanceof operator in node, we are checking the constructor.name. // - // New-styler/rebuild trees should always be stable. + // New-style/rebuild trees should always be stable. var isNewStyleTree = !!(tree['newStyleTree'] || typeof tree.rebuild === 'function' || tree['isReadAPICompatTree'] || tree.constructor['name'] === 'Funnel'); return isNewStyleTree ? tree : broccoli_tree_stabilizer_1.default(tree); @@ -150,4 +157,4 @@ var DiffingPluginWrapper = (function () { return DiffingPluginWrapper; })(); -//# sourceMappingURL=../broccoli/diffing-broccoli-plugin.js.map \ No newline at end of file +//# sourceMappingURL=diffing-broccoli-plugin.js.map diff --git a/lib/broccoli/diffing-broccoli-plugin.js.map b/lib/broccoli/diffing-broccoli-plugin.js.map index 6a5cd347140d..0e7a516ff629 100644 --- a/lib/broccoli/diffing-broccoli-plugin.js.map +++ b/lib/broccoli/diffing-broccoli-plugin.js.map @@ -1 +1 @@ -{"version":3,"sources":["broccoli/diffing-broccoli-plugin.ts"],"names":["wrapDiffingPlugin","DiffingPluginWrapper","DiffingPluginWrapper.constructor","DiffingPluginWrapper.getDiffResult","DiffingPluginWrapper.maybeStoreDiffResult","DiffingPluginWrapper.rebuild","DiffingPluginWrapper.cleanup","DiffingPluginWrapper.relinkOutputAndCachePaths","DiffingPluginWrapper.init","DiffingPluginWrapper.stabilizeTrees","DiffingPluginWrapper.stabilizeTree"],"mappings":"AAAA,sCAAsC;AACtC,0DAA0D;AAC1D,kDAAkD;AAElD,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAG1B,4BAAqC,eAAe,CAAC,CAAA;AACrD,yCAA0B,4BAA4B,CAAC,CAAA;AACvD,IAAI,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAG/C,4BAAyB,eAAe,CAAC;AAAjC,8CAAiC;AAGzC;;;;;;;;GAQG;AACH,2BAAkC,WAAW;IAC3CA,MAAMA,CAACA,cAAa,MAAM,CAAC,IAAI,oBAAoB,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAACA;AACjFA,CAACA;AAFe,yBAAiB,oBAEhC,CAAA;AAaD;IAiBEC,8BAAoBA,WAAWA,EAAUA,sBAAsBA;QAA3CC,gBAAWA,GAAXA,WAAWA,CAAAA;QAAUA,2BAAsBA,GAAtBA,sBAAsBA,CAAAA;QAhB/DA,eAAUA,GAAeA,IAAIA,CAACA;QAC9BA,gBAAWA,GAAiBA,IAAIA,CAACA;QACjCA,gBAAWA,GAAGA,KAAKA,CAACA;QACpBA,kBAAaA,GAA0BA,IAAIA,CAACA;QAC5CA,cAASA,GAAGA,IAAIA,CAACA;QACjBA,eAAUA,GAAGA,IAAIA,CAACA;QAClBA,gBAAWA,GAAGA,IAAIA,CAACA;QAEnBA,4CAA4CA;QAC5CA,cAASA,GAAGA,IAAIA,CAACA;QACjBA,eAAUA,GAAGA,IAAIA,CAACA;QAClBA,cAASA,GAAGA,IAAIA,CAACA;QACjBA,eAAUA,GAAGA,IAAIA,CAACA;QAEVA,eAAUA,GAAeA,IAAIA,CAACA;QAGpCA,EAAEA,CAACA,CAACA,KAAKA,CAACA,OAAOA,CAACA,sBAAsBA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;YAC7CA,IAAIA,CAACA,UA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IA,GAAGA,kCAAaA,CAACA,IAAIA,CAACA,CAACA;IACrDA,CAACA;IACHT,2BAACA;AAADA,CA7IA,AA6ICA,IAAA","file":"broccoli/diffing-broccoli-plugin.js","sourcesContent":["/// \n/// \n/// \n\nimport fs = require('fs');\nimport fse = require('fs-extra');\nimport path = require('path');\nimport {TreeDiffer, DiffResult} from './tree-differ';\nimport stabilizeTree from './broccoli-tree-stabilizer';\nlet symlinkOrCopy = require('symlink-or-copy');\n\n\nexport {DiffResult} from './tree-differ';\n\n\n/**\n * Makes writing diffing plugins easy.\n *\n * Factory method that takes a class that implements the DiffingBroccoliPlugin interface and returns\n * an instance of BroccoliTree.\n *\n * @param pluginClass\n * @returns {DiffingPlugin}\n */\nexport function wrapDiffingPlugin(pluginClass): DiffingPluginWrapperFactory {\n return function() { return new DiffingPluginWrapper(pluginClass, arguments); };\n}\n\n\nexport interface DiffingBroccoliPlugin {\n rebuild(diff: (DiffResult | DiffResult[])): (Promise| DiffResult | void);\n cleanup ? () : void;\n}\n\n\ntype DiffingPluginWrapperFactory = (inputTrees: (BroccoliTree | BroccoliTree[]), options?) =>\n BroccoliTree;\n\n\nclass DiffingPluginWrapper implements BroccoliTree {\n treeDiffer: TreeDiffer = null;\n treeDiffers: TreeDiffer[] = null;\n initialized = false;\n wrappedPlugin: DiffingBroccoliPlugin = null;\n inputTree = null;\n inputTrees = null;\n description = null;\n\n // props monkey-patched by broccoli builder:\n inputPath = null;\n inputPaths = null;\n cachePath = null;\n outputPath = null;\n\n private diffResult: DiffResult = null;\n\n constructor(private pluginClass, private wrappedPluginArguments) {\n if (Array.isArray(wrappedPluginArguments[0])) {\n this.inputTrees = this.stabilizeTrees(wrappedPluginArguments[0]);\n } else {\n this.inputTree = this.stabilizeTree(wrappedPluginArguments[0]);\n }\n\n this.description = this.pluginClass.name;\n }\n\n private getDiffResult(): (DiffResult | DiffResult[]) {\n let returnOrCalculateDiffResult = (tree, index) => {\n // returnOrCalculateDiffResult will do one of two things:\n //\n // If `this.diffResult` is null, calculate a DiffResult using TreeDiffer\n // for the input tree.\n //\n // Otherwise, `this.diffResult` was produced from the output of the\n // inputTree's rebuild() method, and can be used without being checked.\n // Set `this.diffResult` to null and return the previously stored value.\n let diffResult = tree.diffResult;\n if (diffResult) return diffResult;\n let differ = index === false ? this.treeDiffer : this.treeDiffers[index];\n return differ.diffTree();\n };\n\n if (this.inputTrees) {\n return this.inputTrees.map(returnOrCalculateDiffResult);\n } else if (this.inputTree) {\n return returnOrCalculateDiffResult(this.inputTree, false);\n } else {\n throw new Error(\"Missing TreeDiffer\");\n }\n }\n\n private maybeStoreDiffResult(value: (DiffResult | void)) {\n if (!(value instanceof DiffResult)) value = null;\n this.diffResult = (value);\n }\n\n rebuild(): (Promise| void) {\n try {\n let firstRun = !this.initialized;\n this.init();\n\n let diffResult = this.getDiffResult();\n\n let result = this.wrappedPlugin.rebuild(diffResult);\n\n if (result) {\n let resultPromise = >(result);\n if (resultPromise.then) {\n // rebuild() -> Promise<>\n return resultPromise.then((result: (DiffResult | void)) => {\n this.maybeStoreDiffResult(result);\n this.relinkOutputAndCachePaths();\n });\n }\n }\n\n this.maybeStoreDiffResult(<(DiffResult | void)>(result));\n this.relinkOutputAndCachePaths();\n } catch (e) {\n e.message = `[${this.description}]: ${e.message}`;\n throw e;\n }\n }\n\n\n cleanup() {\n if (this.wrappedPlugin && this.wrappedPlugin.cleanup) {\n this.wrappedPlugin.cleanup();\n }\n }\n\n\n private relinkOutputAndCachePaths() {\n // just symlink the cache and output tree\n fs.rmdirSync(this.outputPath);\n symlinkOrCopy.sync(this.cachePath, this.outputPath);\n }\n\n\n private init() {\n if (!this.initialized) {\n let includeExtensions = this.pluginClass.includeExtensions || [];\n let excludeExtensions = this.pluginClass.excludeExtensions || [];\n let description = this.description;\n this.initialized = true;\n if (this.inputPaths) {\n this.treeDiffers =\n this.inputPaths.map((inputPath) => new TreeDiffer(\n description, inputPath, includeExtensions, excludeExtensions));\n } else if (this.inputPath) {\n this.treeDiffer =\n new TreeDiffer(description, this.inputPath, includeExtensions, excludeExtensions);\n }\n this.wrappedPlugin = new this.pluginClass(this.inputPaths || this.inputPath, this.cachePath,\n this.wrappedPluginArguments[1]);\n }\n }\n\n\n private stabilizeTrees(trees: BroccoliTree[]) {\n // Prevent extensions to prevent array from being mutated from the outside.\n // For-loop used to avoid re-allocating a new array.\n for (let i = 0; i < trees.length; ++i) {\n trees[i] = this.stabilizeTree(trees[i]);\n }\n return Object.freeze(trees);\n }\n\n\n private stabilizeTree(tree: BroccoliTree) {\n // Ignore all DiffingPlugins as they are already stable, for others we don't know for sure\n // so we need to stabilize them.\n // Since it's not safe to use instanceof operator in node, we are checking the constructor.name.\n //\n // New-styler/rebuild trees should always be stable.\n let isNewStyleTree = !!(tree['newStyleTree'] || typeof tree.rebuild === 'function' ||\n tree['isReadAPICompatTree'] || tree.constructor['name'] === 'Funnel');\n\n return isNewStyleTree ? tree : stabilizeTree(tree);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["broccoli/diffing-broccoli-plugin.ts"],"names":["wrapDiffingPlugin","DiffingPluginWrapper","DiffingPluginWrapper.constructor","DiffingPluginWrapper.getDiffResult","DiffingPluginWrapper.maybeStoreDiffResult","DiffingPluginWrapper.rebuild","DiffingPluginWrapper.cleanup","DiffingPluginWrapper.relinkOutputAndCachePaths","DiffingPluginWrapper.init","DiffingPluginWrapper.stabilizeTrees","DiffingPluginWrapper.stabilizeTree"],"mappings":"AAAA,sCAAsC;AACtC,0DAA0D;AAC1D,kDAAkD;AAElD,IAAO,EAAE,WAAW,IAAI,CAAC,CAAC;AAG1B,4BAAqC,eAAe,CAAC,CAAA;AACrD,yCAA0B,4BAA4B,CAAC,CAAA;AACvD,IAAI,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAG/C,4BAAyB,eAAe,CAAC;AAAjC,8CAAiC;AAGzC;;;;;;;;GAQG;AACH,2BAAkC,WAAW;IAC3CA,MAAMA,CA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oli/diffing-broccoli-plugin.js","sourcesContent":["/// \n/// \n/// \n\nimport fs = require('fs');\nimport fse = require('fs-extra');\nimport path = require('path');\nimport {TreeDiffer, DiffResult} from './tree-differ';\nimport stabilizeTree from './broccoli-tree-stabilizer';\nlet symlinkOrCopy = require('symlink-or-copy');\n\n\nexport {DiffResult} from './tree-differ';\n\n\n/**\n * Makes writing diffing plugins easy.\n *\n * Factory method that takes a class that implements the DiffingBroccoliPlugin interface and returns\n * an instance of BroccoliTree.\n *\n * @param pluginClass\n * @returns {DiffingBroccoliPlugin}\n */\nexport function wrapDiffingPlugin(pluginClass): DiffingPluginWrapperFactory {\n return function() { return new DiffingPluginWrapper(pluginClass, arguments); };\n}\n\n\nexport interface DiffingBroccoliPlugin {\n rebuild(diff: (DiffResult | DiffResult[])): (Promise| DiffResult | void);\n cleanup ? () : void;\n}\n\n\ntype DiffingPluginWrapperFactory = (inputTrees: (BroccoliTree | BroccoliTree[]), options?) =>\n BroccoliTree;\n\n\nclass DiffingPluginWrapper implements BroccoliTree {\n treeDiffer: TreeDiffer = null;\n treeDiffers: TreeDiffer[] = null;\n initialized = false;\n wrappedPlugin: DiffingBroccoliPlugin = null;\n inputTree = null;\n inputTrees = null;\n description = null;\n\n // props monkey-patched by broccoli builder:\n inputPath = null;\n inputPaths = null;\n cachePath = null;\n outputPath = null;\n\n private diffResult: DiffResult = null;\n\n constructor(private pluginClass, private wrappedPluginArguments) {\n if (Array.isArray(wrappedPluginArguments[0])) {\n this.inputTrees = this.stabilizeTrees(wrappedPluginArguments[0]);\n } else {\n this.inputTree = this.stabilizeTree(wrappedPluginArguments[0]);\n }\n\n this.description = this.pluginClass.name;\n }\n\n private getDiffResult(): (DiffResult | DiffResult[]) {\n let returnOrCalculateDiffResult = (tree, index) => {\n // returnOrCalculateDiffResult will do one of two things:\n //\n // If `this.diffResult` is null, calculate a DiffResult using TreeDiffer\n // for the input tree.\n //\n // Otherwise, `this.diffResult` was produced from the output of the\n // inputTree's rebuild() method, and can be used without being checked.\n // Set `this.diffResult` to null and return the previously stored value.\n let diffResult = tree.diffResult;\n if (diffResult) return diffResult;\n let differ = index === false ? this.treeDiffer : this.treeDiffers[index];\n return differ.diffTree();\n };\n\n if (this.inputTrees) {\n return this.inputTrees.map(returnOrCalculateDiffResult);\n } else if (this.inputTree) {\n return returnOrCalculateDiffResult(this.inputTree, false);\n } else {\n throw new Error(\"Missing TreeDiffer\");\n }\n }\n\n private maybeStoreDiffResult(value: (DiffResult | void)) {\n if (!(value instanceof DiffResult)) value = null;\n this.diffResult = (value);\n }\n\n rebuild(): (Promise| void) {\n try {\n let firstRun = !this.initialized;\n this.init();\n\n let diffResult = this.getDiffResult();\n\n let result = this.wrappedPlugin.rebuild(diffResult);\n\n if (result) {\n let resultPromise = >(result);\n if (resultPromise.then) {\n // rebuild() -> Promise<>\n return resultPromise.then((result: (DiffResult | void)) => {\n this.maybeStoreDiffResult(result);\n this.relinkOutputAndCachePaths();\n });\n }\n }\n\n this.maybeStoreDiffResult(<(DiffResult | void)>(result));\n this.relinkOutputAndCachePaths();\n } catch (e) {\n e.message = `[${this.description}]: ${e.message}`;\n throw e;\n }\n }\n\n\n cleanup() {\n if (this.wrappedPlugin && this.wrappedPlugin.cleanup) {\n this.wrappedPlugin.cleanup();\n }\n }\n\n\n private relinkOutputAndCachePaths() {\n // just symlink the cache and output tree\n fs.rmdirSync(this.outputPath);\n symlinkOrCopy.sync(this.cachePath, this.outputPath);\n }\n\n\n private init() {\n if (!this.initialized) {\n let includeExtensions = this.pluginClass.includeExtensions || [];\n let excludeExtensions = this.pluginClass.excludeExtensions || [];\n let description = this.description;\n this.initialized = true;\n if (this.inputPaths) {\n this.treeDiffers =\n this.inputPaths.map((inputPath) => new TreeDiffer(\n description, inputPath, includeExtensions, excludeExtensions));\n } else if (this.inputPath) {\n this.treeDiffer =\n new TreeDiffer(description, this.inputPath, includeExtensions, excludeExtensions);\n }\n this.wrappedPlugin = new this.pluginClass(this.inputPaths || this.inputPath, this.cachePath,\n this.wrappedPluginArguments[1]);\n }\n }\n\n\n private stabilizeTrees(trees: BroccoliTree[]) {\n // Prevent extensions to prevent array from being mutated from the outside.\n // For-loop used to avoid re-allocating a new array.\n var stableTrees = [];\n for (let i = 0; i < trees.length; ++i) {\n // ignore null/undefined input tries in order to support conditional build pipelines\n if (trees[i]) {\n stableTrees.push(this.stabilizeTree(trees[i]));\n }\n }\n\n if (stableTrees.length === 0) {\n throw new Error('No input trees provided!');\n }\n\n return Object.freeze(stableTrees);\n }\n\n\n private stabilizeTree(tree: BroccoliTree) {\n // Ignore all DiffingPlugins as they are already stable, for others we don't know for sure\n // so we need to stabilize them.\n // Since it's not safe to use instanceof operator in node, we are checking the constructor.name.\n //\n // New-style/rebuild trees should always be stable.\n let isNewStyleTree = !!(tree['newStyleTree'] || typeof tree.rebuild === 'function' ||\n tree['isReadAPICompatTree'] || tree.constructor['name'] === 'Funnel');\n\n return isNewStyleTree ? tree : stabilizeTree(tree);\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/lib/broccoli/tree-differ.js b/lib/broccoli/tree-differ.js index 03289a04da60..4f909e7aa7db 100644 --- a/lib/broccoli/tree-differ.js +++ b/lib/broccoli/tree-differ.js @@ -159,4 +159,4 @@ var FileStatus; FileStatus[FileStatus["Changed"] = 2] = "Changed"; })(FileStatus || (FileStatus = {})); -//# sourceMappingURL=../broccoli/tree-differ.js.map \ No newline at end of file +//# sourceMappingURL=tree-differ.js.map diff --git a/package.json b/package.json index f4a074d89486..cba5f02c80a8 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "resolve": "^1.0.0", "silent-error": "^1.0.0", "symlink-or-copy": "^1.0.1", - "typescript": "~1.6.2" + "typescript": "~1.7.3" }, "ember-addon": { "paths": [