remove-tsickle.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const dependencies_1 = require("../../utility/dependencies");
  4. const json_utils_1 = require("../../utility/json-utils");
  5. const workspace_models_1 = require("../../utility/workspace-models");
  6. const utils_1 = require("./utils");
  7. /**
  8. * Remove tsickle from libraries
  9. */
  10. function removeTsickle() {
  11. return (tree, context) => {
  12. dependencies_1.removePackageJsonDependency(tree, 'tsickle');
  13. const logger = context.logger;
  14. const workspace = utils_1.getWorkspace(tree);
  15. for (const { target } of utils_1.getTargets(workspace, 'build', workspace_models_1.Builders.NgPackagr)) {
  16. for (const options of utils_1.getAllOptions(target)) {
  17. const tsConfigOption = json_utils_1.findPropertyInAstObject(options, 'tsConfig');
  18. if (!tsConfigOption || tsConfigOption.kind !== 'string') {
  19. continue;
  20. }
  21. const tsConfigPath = tsConfigOption.value;
  22. const tsConfigAst = utils_1.readJsonFileAsAstObject(tree, tsConfigPath);
  23. if (!tsConfigAst) {
  24. logger.warn(`Cannot find file: ${tsConfigPath}`);
  25. continue;
  26. }
  27. const ngCompilerOptions = json_utils_1.findPropertyInAstObject(tsConfigAst, 'angularCompilerOptions');
  28. if (ngCompilerOptions && ngCompilerOptions.kind === 'object') {
  29. // remove annotateForClosureCompiler option
  30. const recorder = tree.beginUpdate(tsConfigPath);
  31. json_utils_1.removePropertyInAstObject(recorder, ngCompilerOptions, 'annotateForClosureCompiler');
  32. tree.commitUpdate(recorder);
  33. }
  34. }
  35. }
  36. return tree;
  37. };
  38. }
  39. exports.removeTsickle = removeTsickle;