index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. GLOBAL_DEFS_FOR_TERSER,
  5. GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
  6. constructorParametersDownlevelTransform
  7. } from "./chunk-73XDHERB.js";
  8. import {
  9. DEFAULT_ERROR_CODE,
  10. EmitFlags,
  11. NgCompiler,
  12. NgCompilerHost,
  13. NgtscProgram,
  14. PatchedProgramIncrementalBuildStrategy,
  15. SOURCE,
  16. TsCreateProgramDriver,
  17. UNKNOWN_ERROR_CODE,
  18. calcProjectFileAndBasePath,
  19. createCompilerHost,
  20. createProgram,
  21. defaultGatherDiagnostics,
  22. exitCodeFromResult,
  23. formatDiagnostics,
  24. freshCompilationTicket,
  25. incrementalFromStateTicket,
  26. isTsDiagnostic,
  27. performCompilation,
  28. readConfiguration,
  29. untagAllTsFiles
  30. } from "./chunk-QBQKEXLX.js";
  31. import {
  32. OptimizeFor
  33. } from "./chunk-FYJ5FZGI.js";
  34. import "./chunk-4NU6EGYK.js";
  35. import "./chunk-JCLVSACV.js";
  36. import "./chunk-7RPZKH3B.js";
  37. import {
  38. ActivePerfRecorder,
  39. PerfPhase
  40. } from "./chunk-URH5LEAG.js";
  41. import {
  42. ConsoleLogger,
  43. LogLevel
  44. } from "./chunk-CF2CT7RQ.js";
  45. import {
  46. LogicalFileSystem,
  47. LogicalProjectPath,
  48. NgtscCompilerHost,
  49. NodeJSFileSystem,
  50. absoluteFrom,
  51. absoluteFromSourceFile,
  52. basename,
  53. dirname,
  54. getFileSystem,
  55. getSourceFileOrError,
  56. isLocalRelativePath,
  57. isRoot,
  58. isRooted,
  59. join,
  60. relative,
  61. relativeFrom,
  62. resolve,
  63. setFileSystem,
  64. toRelativeImport
  65. } from "./chunk-K2U2VZ7S.js";
  66. import "./chunk-SRFZMXHZ.js";
  67. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/version.mjs
  68. import { Version } from "@angular/compiler";
  69. var VERSION = new Version("16.0.4");
  70. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/tsc_plugin.mjs
  71. var NgTscPlugin = class {
  72. get compiler() {
  73. if (this._compiler === null) {
  74. throw new Error("Lifecycle error: setupCompilation() must be called first.");
  75. }
  76. return this._compiler;
  77. }
  78. constructor(ngOptions) {
  79. this.ngOptions = ngOptions;
  80. this.name = "ngtsc";
  81. this.options = null;
  82. this.host = null;
  83. this._compiler = null;
  84. setFileSystem(new NodeJSFileSystem());
  85. }
  86. wrapHost(host, inputFiles, options) {
  87. this.options = { ...this.ngOptions, ...options };
  88. this.host = NgCompilerHost.wrap(host, inputFiles, this.options, null);
  89. return this.host;
  90. }
  91. setupCompilation(program, oldProgram) {
  92. var _a;
  93. const perfRecorder = ActivePerfRecorder.zeroedToNow();
  94. if (this.host === null || this.options === null) {
  95. throw new Error("Lifecycle error: setupCompilation() before wrapHost().");
  96. }
  97. this.host.postProgramCreationCleanup();
  98. untagAllTsFiles(program);
  99. const programDriver = new TsCreateProgramDriver(program, this.host, this.options, this.host.shimExtensionPrefixes);
  100. const strategy = new PatchedProgramIncrementalBuildStrategy();
  101. const oldState = oldProgram !== void 0 ? strategy.getIncrementalState(oldProgram) : null;
  102. let ticket;
  103. const modifiedResourceFiles = /* @__PURE__ */ new Set();
  104. if (this.host.getModifiedResourceFiles !== void 0) {
  105. for (const resourceFile of (_a = this.host.getModifiedResourceFiles()) != null ? _a : []) {
  106. modifiedResourceFiles.add(resolve(resourceFile));
  107. }
  108. }
  109. if (oldProgram === void 0 || oldState === null) {
  110. ticket = freshCompilationTicket(
  111. program,
  112. this.options,
  113. strategy,
  114. programDriver,
  115. perfRecorder,
  116. false,
  117. false
  118. );
  119. } else {
  120. strategy.toNextBuildStrategy().getIncrementalState(oldProgram);
  121. ticket = incrementalFromStateTicket(oldProgram, oldState, program, this.options, strategy, programDriver, modifiedResourceFiles, perfRecorder, false, false);
  122. }
  123. this._compiler = NgCompiler.fromTicket(ticket, this.host);
  124. return {
  125. ignoreForDiagnostics: this._compiler.ignoreForDiagnostics,
  126. ignoreForEmit: this._compiler.ignoreForEmit
  127. };
  128. }
  129. getDiagnostics(file) {
  130. if (file === void 0) {
  131. return this.compiler.getDiagnostics();
  132. }
  133. return this.compiler.getDiagnosticsForFile(file, OptimizeFor.WholeProgram);
  134. }
  135. getOptionDiagnostics() {
  136. return this.compiler.getOptionDiagnostics();
  137. }
  138. getNextProgram() {
  139. return this.compiler.getCurrentProgram();
  140. }
  141. createTransformers() {
  142. this.compiler.perfRecorder.phase(PerfPhase.TypeScriptEmit);
  143. return this.compiler.prepareEmit().transformers;
  144. }
  145. };
  146. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/index.mjs
  147. setFileSystem(new NodeJSFileSystem());
  148. export {
  149. ConsoleLogger,
  150. DEFAULT_ERROR_CODE,
  151. EmitFlags,
  152. GLOBAL_DEFS_FOR_TERSER,
  153. GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
  154. LogLevel,
  155. LogicalFileSystem,
  156. LogicalProjectPath,
  157. NgTscPlugin,
  158. NgtscCompilerHost,
  159. NgtscProgram,
  160. NodeJSFileSystem,
  161. OptimizeFor,
  162. SOURCE,
  163. UNKNOWN_ERROR_CODE,
  164. VERSION,
  165. absoluteFrom,
  166. absoluteFromSourceFile,
  167. basename,
  168. calcProjectFileAndBasePath,
  169. constructorParametersDownlevelTransform,
  170. createCompilerHost,
  171. createProgram,
  172. defaultGatherDiagnostics,
  173. dirname,
  174. exitCodeFromResult,
  175. formatDiagnostics,
  176. getFileSystem,
  177. getSourceFileOrError,
  178. isLocalRelativePath,
  179. isRoot,
  180. isRooted,
  181. isTsDiagnostic,
  182. join,
  183. performCompilation,
  184. readConfiguration,
  185. relative,
  186. relativeFrom,
  187. resolve,
  188. setFileSystem,
  189. toRelativeImport
  190. };
  191. /**
  192. * @license
  193. * Copyright Google LLC All Rights Reserved.
  194. *
  195. * Use of this source code is governed by an MIT-style license that can be
  196. * found in the LICENSE file at https://angular.io/license
  197. */
  198. //# sourceMappingURL=index.js.map