@nx/angular 16.8.0-beta.4 → 16.8.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/mf/mf.js +31 -36
  2. package/package.json +10 -10
  3. package/plugins/component-testing.js +48 -40
  4. package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +4 -6
  5. package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +4 -6
  6. package/src/builders/utilities/buildable-libs.js +1 -2
  7. package/src/builders/utilities/module-federation.js +2 -3
  8. package/src/builders/utilities/webpack.js +16 -21
  9. package/src/builders/webpack-browser/webpack-browser.impl.js +13 -13
  10. package/src/builders/webpack-dev-server/lib/normalize-options.js +8 -1
  11. package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -18
  12. package/src/builders/webpack-server/webpack-server.impl.js +5 -7
  13. package/src/executors/browser-esbuild/browser-esbuild.impl.js +19 -23
  14. package/src/executors/browser-esbuild/lib/buildable-libs.js +1 -2
  15. package/src/executors/delegate-build/delegate-build.impl.js +9 -12
  16. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +4 -7
  17. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.transform.js +4 -5
  18. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +158 -156
  19. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/options.di.js +6 -3
  20. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +118 -118
  21. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
  22. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ts/cache-compiler-host.js +20 -12
  23. package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +18 -21
  24. package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +6 -9
  25. package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +6 -3
  26. package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +122 -122
  27. package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
  28. package/src/executors/package/ng-packagr-adjustments/ts/cache-compiler-host.js +21 -13
  29. package/src/executors/package/ng-packagr-adjustments/utils/ng-compiler-cli.js +5 -8
  30. package/src/executors/package/package.impl.js +33 -38
  31. package/src/executors/utilities/angular-version-utils.js +1 -1
  32. package/src/executors/utilities/tailwindcss.js +2 -2
  33. package/src/executors/utilities/typescript.js +23 -28
  34. package/src/generators/add-linting/add-linting.js +76 -74
  35. package/src/generators/add-linting/lib/create-eslint-configuration.js +12 -4
  36. package/src/generators/application/application.js +56 -55
  37. package/src/generators/application/lib/add-e2e.js +36 -40
  38. package/src/generators/application/lib/add-linting.js +12 -15
  39. package/src/generators/application/lib/add-proxy-config.js +4 -1
  40. package/src/generators/application/lib/add-unit-test-runner.js +15 -18
  41. package/src/generators/application/lib/create-files.js +44 -47
  42. package/src/generators/application/lib/enable-strict-type-checking.js +2 -2
  43. package/src/generators/application/lib/normalize-options.js +37 -25
  44. package/src/generators/application/lib/set-app-strict-default.js +1 -2
  45. package/src/generators/application/lib/update-editor-tsconfig.js +1 -2
  46. package/src/generators/component/component.js +40 -43
  47. package/src/generators/component/lib/normalize-options.js +15 -5
  48. package/src/generators/component-cypress-spec/component-cypress-spec.js +25 -28
  49. package/src/generators/component-story/component-story.js +19 -22
  50. package/src/generators/convert-to-with-mf/convert-to-with-mf.js +19 -22
  51. package/src/generators/convert-to-with-mf/lib/get-webpack-config-path.js +3 -4
  52. package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +103 -106
  53. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +59 -62
  54. package/src/generators/directive/directive.js +21 -24
  55. package/src/generators/directive/lib/normalize-options.js +11 -5
  56. package/src/generators/host/host.js +77 -67
  57. package/src/generators/host/lib/add-ssr.js +32 -35
  58. package/src/generators/init/init.js +101 -92
  59. package/src/generators/library/lib/add-standalone-component.js +18 -13
  60. package/src/generators/library/lib/enable-strict-type-checking.js +17 -5
  61. package/src/generators/library/lib/normalize-options.js +68 -53
  62. package/src/generators/library/library.js +89 -92
  63. package/src/generators/library-secondary-entry-point/lib/add-files.js +5 -1
  64. package/src/generators/library-secondary-entry-point/lib/normalize-options.js +6 -3
  65. package/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.js +1 -2
  66. package/src/generators/library-secondary-entry-point/library-secondary-entry-point.js +6 -9
  67. package/src/generators/move/lib/normalize-schema.js +5 -1
  68. package/src/generators/move/lib/update-module-name.js +1 -1
  69. package/src/generators/move/lib/update-ng-package.js +1 -2
  70. package/src/generators/move/lib/update-secondary-entry-points.js +1 -2
  71. package/src/generators/move/move.js +9 -12
  72. package/src/generators/ng-add/migrate-from-angular-cli.js +54 -53
  73. package/src/generators/ng-add/migrators/builders/angular-devkit-karma.migrator.js +4 -3
  74. package/src/generators/ng-add/migrators/builders/angular-devkit-ng-packagr.migrator.js +11 -12
  75. package/src/generators/ng-add/migrators/builders/angular-eslint-lint.migrator.js +39 -42
  76. package/src/generators/ng-add/migrators/builders/builder.migrator.js +1 -2
  77. package/src/generators/ng-add/migrators/migrator.js +7 -11
  78. package/src/generators/ng-add/migrators/projects/app.migrator.js +39 -43
  79. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +115 -91
  80. package/src/generators/ng-add/migrators/projects/lib.migrator.js +23 -31
  81. package/src/generators/ng-add/migrators/projects/project.migrator.js +10 -14
  82. package/src/generators/ng-add/ng-add.js +5 -8
  83. package/src/generators/ng-add/utilities/dependencies.js +2 -3
  84. package/src/generators/ng-add/utilities/format-files-task.js +1 -1
  85. package/src/generators/ng-add/utilities/projects.js +1 -1
  86. package/src/generators/ng-add/utilities/workspace.js +25 -36
  87. package/src/generators/ngrx/lib/add-imports-to-module.js +1 -2
  88. package/src/generators/ngrx/lib/add-ngrx-to-package-json.js +1 -3
  89. package/src/generators/ngrx/lib/generate-files.js +11 -2
  90. package/src/generators/ngrx/lib/normalize-options.js +9 -4
  91. package/src/generators/ngrx/lib/validate-options.js +3 -3
  92. package/src/generators/ngrx/ngrx.js +18 -21
  93. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.actions.ts__tmpl__ +1 -1
  94. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.spec.ts__tmpl__ +2 -2
  95. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
  96. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.spec.ts__tmpl__ +6 -6
  97. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
  98. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.spec.ts__tmpl__ +3 -3
  99. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.ts__tmpl__ +2 -2
  100. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.spec.ts__tmpl__ +3 -3
  101. package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.ts__tmpl__ +1 -1
  102. package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
  103. package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
  104. package/src/generators/ngrx-feature-store/lib/add-exports-barrel.js +4 -1
  105. package/src/generators/ngrx-feature-store/lib/add-imports.js +1 -1
  106. package/src/generators/ngrx-feature-store/lib/add-ngrx-to-package-json.js +1 -3
  107. package/src/generators/ngrx-feature-store/lib/generate-files.js +20 -4
  108. package/src/generators/ngrx-feature-store/lib/normalize-options.d.ts +1 -0
  109. package/src/generators/ngrx-feature-store/lib/normalize-options.js +22 -3
  110. package/src/generators/ngrx-feature-store/lib/validate-options.js +2 -2
  111. package/src/generators/ngrx-feature-store/ngrx-feature-store.js +18 -21
  112. package/src/generators/ngrx-root-store/lib/add-ngrx-to-package-json.js +8 -6
  113. package/src/generators/ngrx-root-store/lib/normalize-options.js +8 -4
  114. package/src/generators/ngrx-root-store/lib/validate-options.js +2 -2
  115. package/src/generators/ngrx-root-store/ngrx-root-store.js +27 -30
  116. package/src/generators/pipe/lib/normalize-options.js +9 -3
  117. package/src/generators/pipe/pipe.js +21 -24
  118. package/src/generators/remote/lib/add-ssr.js +46 -47
  119. package/src/generators/remote/lib/find-next-available-port.js +1 -2
  120. package/src/generators/remote/remote.js +52 -49
  121. package/src/generators/scam/lib/convert-component-to-scam.js +1 -2
  122. package/src/generators/scam/lib/normalize-options.js +11 -4
  123. package/src/generators/scam/scam.js +15 -12
  124. package/src/generators/scam-directive/lib/normalize-options.js +12 -4
  125. package/src/generators/scam-directive/scam-directive.js +13 -10
  126. package/src/generators/scam-pipe/lib/normalize-options.js +12 -4
  127. package/src/generators/scam-pipe/scam-pipe.js +13 -10
  128. package/src/generators/scam-to-standalone/scam-to-standalone.js +23 -26
  129. package/src/generators/setup-mf/lib/add-cypress-workaround.js +1 -1
  130. package/src/generators/setup-mf/lib/add-remote-to-host.js +4 -1
  131. package/src/generators/setup-mf/lib/change-build-target.js +10 -4
  132. package/src/generators/setup-mf/lib/generate-config.js +1 -1
  133. package/src/generators/setup-mf/lib/get-remotes-with-ports.js +1 -2
  134. package/src/generators/setup-mf/lib/normalize-options.js +5 -2
  135. package/src/generators/setup-mf/lib/set-tsconfig-target.js +7 -1
  136. package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +1 -2
  137. package/src/generators/setup-mf/lib/setup-serve-target.js +10 -3
  138. package/src/generators/setup-mf/setup-mf.js +32 -35
  139. package/src/generators/setup-ssr/lib/generate-files.js +8 -5
  140. package/src/generators/setup-ssr/lib/normalize-options.js +9 -10
  141. package/src/generators/setup-ssr/lib/update-project-config.js +21 -17
  142. package/src/generators/setup-ssr/setup-ssr.js +26 -27
  143. package/src/generators/setup-tailwind/lib/add-tailwind-config-path-to-project.js +6 -4
  144. package/src/generators/setup-tailwind/lib/detect-tailwind-installed-version.js +1 -2
  145. package/src/generators/setup-tailwind/lib/normalize-options.js +4 -1
  146. package/src/generators/setup-tailwind/lib/update-application-styles.js +5 -6
  147. package/src/generators/setup-tailwind/setup-tailwind.js +20 -23
  148. package/src/generators/stories/lib/get-e2e-project.js +1 -1
  149. package/src/generators/stories/stories.js +43 -50
  150. package/src/generators/storybook-configuration/lib/assert-compatible-storybook-version.js +1 -1
  151. package/src/generators/storybook-configuration/lib/generate-stories.js +10 -13
  152. package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +12 -15
  153. package/src/generators/storybook-configuration/storybook-configuration.js +20 -16
  154. package/src/generators/utils/create-ts-config.js +1 -1
  155. package/src/generators/utils/entry-point.js +1 -2
  156. package/src/generators/utils/export-scam.js +1 -1
  157. package/src/generators/utils/insert-ngmodule-import.js +1 -1
  158. package/src/generators/utils/path.js +3 -3
  159. package/src/generators/utils/project.js +2 -3
  160. package/src/generators/utils/selector.js +1 -1
  161. package/src/generators/utils/storybook-ast/component-info.js +1 -2
  162. package/src/generators/utils/storybook-ast/entry-point.js +1 -2
  163. package/src/generators/utils/storybook-ast/module-info.js +1 -2
  164. package/src/generators/utils/storybook-ast/tree-utilities.js +1 -1
  165. package/src/generators/utils/testing.js +141 -139
  166. package/src/generators/utils/validations.js +1 -1
  167. package/src/generators/utils/version-utils.js +5 -7
  168. package/src/generators/web-worker/lib/normalize-options.js +6 -3
  169. package/src/generators/web-worker/web-worker.js +25 -28
  170. package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.js +10 -13
  171. package/src/migrations/update-14-2-0/update-angular-cli.js +14 -18
  172. package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.js +22 -26
  173. package/src/migrations/update-14-2-0/update-ngcc-target.js +10 -14
  174. package/src/migrations/update-14-2-0/update-router-initial-navigation.js +31 -39
  175. package/src/migrations/update-14-2-0/update-tsconfig-target.js +48 -56
  176. package/src/migrations/update-14-5-0/migrate-mfe-to-mf.js +14 -17
  177. package/src/migrations/update-14-5-2/update-angular-cli.js +14 -18
  178. package/src/migrations/update-14-6-0/update-angular-cli.js +14 -18
  179. package/src/migrations/update-15-0-0/add-karma-inputs.js +27 -32
  180. package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.js +62 -68
  181. package/src/migrations/update-15-2-0/remove-browserlist-config.js +34 -37
  182. package/src/migrations/update-15-2-0/remove-platform-server-exports.js +49 -52
  183. package/src/migrations/update-15-2-0/update-angular-cli.js +14 -18
  184. package/src/migrations/update-15-2-0/update-karma-main-file.js +11 -12
  185. package/src/migrations/update-15-2-0/update-typescript-target.js +40 -39
  186. package/src/migrations/update-15-2-0/update-workspace-config.js +16 -19
  187. package/src/migrations/update-15-5-0/update-angular-cli.js +14 -18
  188. package/src/migrations/update-15-7-0/install-required-packages.js +26 -28
  189. package/src/migrations/update-15-8-0/update-angular-cli.js +14 -18
  190. package/src/migrations/update-15-9-0/update-file-server-executor.js +31 -35
  191. package/src/migrations/update-15-9-0/update-testing-tsconfig.js +17 -22
  192. package/src/migrations/update-16-0-0/remove-karma-defaults.js +15 -18
  193. package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.js +22 -25
  194. package/src/migrations/update-16-0-0/remove-protractor-defaults.js +15 -18
  195. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  196. package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.js +38 -42
  197. package/src/migrations/update-16-1-0/remove-ngcc-invocation.js +15 -19
  198. package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +49 -52
  199. package/src/migrations/update-16-1-0/update-angular-cli.js +14 -18
  200. package/src/migrations/update-16-1-0/update-server-executor-config.js +13 -16
  201. package/src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store.js +25 -29
  202. package/src/migrations/update-16-4-0/rename-angular-eslint-accesibility-rules.js +13 -16
  203. package/src/migrations/update-16-4-0/update-angular-cli.js +14 -18
  204. package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
  205. package/src/migrations/update-16-7-0/update-angular-cli.js +14 -18
  206. package/src/migrations/utils/projects.js +9 -15
  207. package/src/utils/get-mf-projects.js +1 -2
  208. package/src/utils/mf/utils.js +43 -44
  209. package/src/utils/mf/with-module-federation-ssr.js +39 -24
  210. package/src/utils/mf/with-module-federation.js +40 -21
  211. package/src/utils/nx-devkit/ast-utils.js +2 -3
  212. package/src/utils/version-utils.js +2 -4
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngPackagrLiteExecutor = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
6
5
  const ng_packagr_1 = require("ng-packagr");
7
6
  const path_1 = require("path");
@@ -10,26 +9,24 @@ const typescript_1 = require("../utilities/typescript");
10
9
  const entry_point_di_1 = require("./ng-packagr-adjustments/ng-package/entry-point/entry-point.di");
11
10
  const options_di_1 = require("./ng-packagr-adjustments/ng-package/options.di");
12
11
  const package_di_1 = require("./ng-packagr-adjustments/ng-package/package.di");
13
- function initializeNgPackgrLite(options, context, projectDependencies) {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- const packager = new ng_packagr_1.NgPackagr([
16
- // Add default providers to this list.
17
- ...package_di_1.NX_PACKAGE_PROVIDERS,
18
- ...entry_point_di_1.NX_ENTRY_POINT_PROVIDERS,
19
- (0, options_di_1.nxProvideOptions)({
20
- tailwindConfig: options.tailwindConfig,
21
- watch: options.watch,
22
- }),
23
- ]);
24
- packager.forProject((0, path_1.resolve)(context.root, options.project));
25
- packager.withBuildTransform(package_di_1.NX_PACKAGE_TRANSFORM.provide);
26
- if (options.tsConfig) {
27
- const remappedTsConfigFilePath = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, context.root, context.projectsConfigurations.projects[context.projectName].root, projectDependencies);
28
- const tsConfig = yield (0, typescript_1.parseRemappedTsConfigAndMergeDefaults)(context.root, options.tsConfig, remappedTsConfigFilePath);
29
- packager.withTsConfig(tsConfig);
30
- }
31
- return packager;
32
- });
12
+ async function initializeNgPackgrLite(options, context, projectDependencies) {
13
+ const packager = new ng_packagr_1.NgPackagr([
14
+ // Add default providers to this list.
15
+ ...package_di_1.NX_PACKAGE_PROVIDERS,
16
+ ...entry_point_di_1.NX_ENTRY_POINT_PROVIDERS,
17
+ (0, options_di_1.nxProvideOptions)({
18
+ tailwindConfig: options.tailwindConfig,
19
+ watch: options.watch,
20
+ }),
21
+ ]);
22
+ packager.forProject((0, path_1.resolve)(context.root, options.project));
23
+ packager.withBuildTransform(package_di_1.NX_PACKAGE_TRANSFORM.provide);
24
+ if (options.tsConfig) {
25
+ const remappedTsConfigFilePath = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, context.root, context.projectsConfigurations.projects[context.projectName].root, projectDependencies);
26
+ const tsConfig = await (0, typescript_1.parseRemappedTsConfigAndMergeDefaults)(context.root, options.tsConfig, remappedTsConfigFilePath);
27
+ packager.withTsConfig(tsConfig);
28
+ }
29
+ return packager;
33
30
  }
34
31
  exports.ngPackagrLiteExecutor = (0, package_impl_1.createLibraryExecutor)(initializeNgPackgrLite);
35
32
  exports.default = exports.ngPackagrLiteExecutor;
@@ -9,7 +9,6 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.compileNgcTransformFactory = void 0;
12
- const tslib_1 = require("tslib");
13
12
  const transform_1 = require("ng-packagr/lib/graph/transform");
14
13
  const nodes_1 = require("ng-packagr/lib/ng-package/nodes");
15
14
  const tsconfig_1 = require("ng-packagr/lib/ts/tsconfig");
@@ -20,9 +19,7 @@ const angular_version_utils_1 = require("../../../../utilities/angular-version-u
20
19
  const compile_source_files_1 = require("../../ngc/compile-source-files");
21
20
  const ng_compiler_cli_1 = require("../../utils/ng-compiler-cli");
22
21
  const compileNgcTransformFactory = (StylesheetProcessor, options) => {
23
- return (0, transform_1.transformFromPromise)((graph) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
24
- var _a;
25
- var _b;
22
+ return (0, transform_1.transformFromPromise)(async (graph) => {
26
23
  const spinner = ora({
27
24
  hideCursor: false,
28
25
  discardStdin: false,
@@ -44,14 +41,14 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
44
41
  let ngccProcessor;
45
42
  if (angularVersion && angularVersion.major < 16) {
46
43
  ngccProcessor =
47
- new (require('ng-packagr/lib/ngc/ngcc-processor').NgccProcessor)(yield (0, ng_compiler_cli_1.ngccCompilerCli)(), entryPoint.cache.ngccProcessingCache, tsConfig.project, tsConfig.options, entryPoints);
44
+ new (require('ng-packagr/lib/ngc/ngcc-processor').NgccProcessor)(await (0, ng_compiler_cli_1.ngccCompilerCli)(), entryPoint.cache.ngccProcessingCache, tsConfig.project, tsConfig.options, entryPoints);
48
45
  if (!entryPoint.data.entryPoint.isSecondaryEntryPoint) {
49
46
  // Only run the async version of NGCC during the primary entrypoint processing.
50
- yield ngccProcessor.process();
47
+ await ngccProcessor.process();
51
48
  }
52
49
  }
53
- (_a = (_b = entryPoint.cache).stylesheetProcessor) !== null && _a !== void 0 ? _a : (_b.stylesheetProcessor = new StylesheetProcessor(basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory, options.watch, options.tailwindConfig));
54
- yield (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, {
50
+ entryPoint.cache.stylesheetProcessor ??= new StylesheetProcessor(basePath, cssUrl, styleIncludePaths, options.cacheEnabled && options.cacheDirectory, options.watch, options.tailwindConfig);
51
+ await (0, compile_source_files_1.compileSourceFiles)(graph, tsConfig, moduleResolutionCache, {
55
52
  outDir: path.dirname(esmModulePath),
56
53
  declarationDir: path.dirname(declarations),
57
54
  declaration: true,
@@ -66,6 +63,6 @@ const compileNgcTransformFactory = (StylesheetProcessor, options) => {
66
63
  }
67
64
  spinner.succeed();
68
65
  return graph;
69
- }));
66
+ });
70
67
  };
71
68
  exports.compileNgcTransformFactory = compileNgcTransformFactory;
@@ -20,10 +20,13 @@ exports.nxProvideOptions = nxProvideOptions;
20
20
  exports.NX_DEFAULT_OPTIONS_PROVIDER = (0, exports.nxProvideOptions)();
21
21
  function normalizeOptions(options = {}) {
22
22
  const ciEnv = process.env['CI'];
23
- const isCI = (ciEnv === null || ciEnv === void 0 ? void 0 : ciEnv.toLowerCase()) === 'true' || ciEnv === '1';
23
+ const isCI = ciEnv?.toLowerCase() === 'true' || ciEnv === '1';
24
24
  const { cacheEnabled = !isCI, cacheDirectory = findCachePath() } = options;
25
- return Object.assign(Object.assign({}, options), { cacheEnabled,
26
- cacheDirectory });
25
+ return {
26
+ ...options,
27
+ cacheEnabled,
28
+ cacheDirectory,
29
+ };
27
30
  }
28
31
  function findCachePath() {
29
32
  const name = 'ng-packagr';
@@ -9,145 +9,145 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.compileSourceFiles = void 0;
12
- const tslib_1 = require("tslib");
13
12
  const nodes_1 = require("ng-packagr/lib/ng-package/nodes");
14
13
  const log = require("ng-packagr/lib/utils/log");
15
14
  const ng_compiler_cli_1 = require("ng-packagr/lib/utils/ng-compiler-cli");
16
15
  const ts = require("typescript");
17
16
  const angular_version_utils_1 = require("../../../utilities/angular-version-utils");
18
17
  const cache_compiler_host_1 = require("../ts/cache-compiler-host");
19
- function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraOptions, stylesheetProcessor, ngccProcessor, watch) {
20
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
- const { NgtscProgram, formatDiagnostics } = yield (0, ng_compiler_cli_1.ngCompilerCli)();
22
- const tsConfigOptions = Object.assign(Object.assign({}, tsConfig.options), extraOptions);
23
- const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
24
- const ngPackageNode = graph.find(nodes_1.isPackage);
25
- const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;
26
- let tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage);
27
- if (ngccProcessor) {
28
- tsCompilerHost =
29
- require('ng-packagr/lib/ts/ngcc-transform-compiler-host').ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);
30
- }
31
- const cache = entryPoint.cache;
32
- const sourceFileCache = cache.sourcesFileCache;
33
- // Create the Angular specific program that contains the Angular compiler
34
- const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);
35
- const angularCompiler = angularProgram.compiler;
36
- const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;
37
- // SourceFile versions are required for builder programs.
38
- // The wrapped host inside NgtscProgram adds additional files that will not have versions.
39
- const typeScriptProgram = angularProgram.getTsProgram();
40
- (0, cache_compiler_host_1.augmentProgramWithVersioning)(typeScriptProgram);
41
- let builder;
42
- if (watch) {
43
- builder = cache.oldBuilder =
44
- ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost, cache.oldBuilder);
45
- cache.oldNgtscProgram = angularProgram;
46
- }
47
- else {
48
- // When not in watch mode, the startup cost of the incremental analysis can be avoided by
49
- // using an abstract builder that only wraps a TypeScript program.
50
- builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);
51
- }
52
- // Update semantic diagnostics cache
53
- const affectedFiles = new Set();
54
- // Analyze affected files when in watch mode for incremental type checking
55
- if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {
56
- // eslint-disable-next-line no-constant-condition
57
- while (true) {
58
- const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
59
- // If the affected file is a TTC shim, add the shim's original source file.
60
- // This ensures that changes that affect TTC are typechecked even when the changes
61
- // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.
62
- // For example, changing @Input property types of a directive used in another component's
63
- // template.
64
- if (ignoreForDiagnostics.has(sourceFile) &&
65
- sourceFile.fileName.endsWith('.ngtypecheck.ts')) {
66
- // This file name conversion relies on internal compiler logic and should be converted
67
- // to an official method when available. 15 is length of `.ngtypecheck.ts`
68
- const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';
69
- const originalSourceFile = builder.getSourceFile(originalFilename);
70
- if (originalSourceFile) {
71
- affectedFiles.add(originalSourceFile);
72
- }
73
- return true;
18
+ async function compileSourceFiles(graph, tsConfig, moduleResolutionCache, extraOptions, stylesheetProcessor, ngccProcessor, watch) {
19
+ const { NgtscProgram, formatDiagnostics } = await (0, ng_compiler_cli_1.ngCompilerCli)();
20
+ const tsConfigOptions = {
21
+ ...tsConfig.options,
22
+ ...extraOptions,
23
+ };
24
+ const entryPoint = graph.find((0, nodes_1.isEntryPointInProgress)());
25
+ const ngPackageNode = graph.find(nodes_1.isPackage);
26
+ const inlineStyleLanguage = ngPackageNode.data.inlineStyleLanguage;
27
+ let tsCompilerHost = (0, cache_compiler_host_1.cacheCompilerHost)(graph, entryPoint, tsConfigOptions, moduleResolutionCache, stylesheetProcessor, inlineStyleLanguage);
28
+ if (ngccProcessor) {
29
+ tsCompilerHost =
30
+ require('ng-packagr/lib/ts/ngcc-transform-compiler-host').ngccTransformCompilerHost(tsCompilerHost, tsConfigOptions, ngccProcessor, moduleResolutionCache);
31
+ }
32
+ const cache = entryPoint.cache;
33
+ const sourceFileCache = cache.sourcesFileCache;
34
+ // Create the Angular specific program that contains the Angular compiler
35
+ const angularProgram = new NgtscProgram(tsConfig.rootNames, tsConfigOptions, tsCompilerHost, cache.oldNgtscProgram);
36
+ const angularCompiler = angularProgram.compiler;
37
+ const { ignoreForDiagnostics, ignoreForEmit } = angularCompiler;
38
+ // SourceFile versions are required for builder programs.
39
+ // The wrapped host inside NgtscProgram adds additional files that will not have versions.
40
+ const typeScriptProgram = angularProgram.getTsProgram();
41
+ (0, cache_compiler_host_1.augmentProgramWithVersioning)(typeScriptProgram);
42
+ let builder;
43
+ if (watch) {
44
+ builder = cache.oldBuilder =
45
+ ts.createEmitAndSemanticDiagnosticsBuilderProgram(typeScriptProgram, tsCompilerHost, cache.oldBuilder);
46
+ cache.oldNgtscProgram = angularProgram;
47
+ }
48
+ else {
49
+ // When not in watch mode, the startup cost of the incremental analysis can be avoided by
50
+ // using an abstract builder that only wraps a TypeScript program.
51
+ builder = ts.createAbstractBuilder(typeScriptProgram, tsCompilerHost);
52
+ }
53
+ // Update semantic diagnostics cache
54
+ const affectedFiles = new Set();
55
+ // Analyze affected files when in watch mode for incremental type checking
56
+ if ('getSemanticDiagnosticsOfNextAffectedFile' in builder) {
57
+ // eslint-disable-next-line no-constant-condition
58
+ while (true) {
59
+ const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
60
+ // If the affected file is a TTC shim, add the shim's original source file.
61
+ // This ensures that changes that affect TTC are typechecked even when the changes
62
+ // are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.
63
+ // For example, changing @Input property types of a directive used in another component's
64
+ // template.
65
+ if (ignoreForDiagnostics.has(sourceFile) &&
66
+ sourceFile.fileName.endsWith('.ngtypecheck.ts')) {
67
+ // This file name conversion relies on internal compiler logic and should be converted
68
+ // to an official method when available. 15 is length of `.ngtypecheck.ts`
69
+ const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';
70
+ const originalSourceFile = builder.getSourceFile(originalFilename);
71
+ if (originalSourceFile) {
72
+ affectedFiles.add(originalSourceFile);
74
73
  }
75
- return false;
76
- });
77
- if (!result) {
78
- break;
74
+ return true;
79
75
  }
80
- affectedFiles.add(result.affected);
76
+ return false;
77
+ });
78
+ if (!result) {
79
+ break;
81
80
  }
81
+ affectedFiles.add(result.affected);
82
82
  }
83
- // Collect program level diagnostics
84
- const allDiagnostics = [
85
- ...angularCompiler.getOptionDiagnostics(),
86
- ...builder.getOptionsDiagnostics(),
87
- ...builder.getGlobalDiagnostics(),
88
- ];
89
- // Required to support asynchronous resource loading
90
- // Must be done before creating transformers or getting template diagnostics
91
- yield angularCompiler.analyzeAsync();
92
- // Collect source file specific diagnostics
93
- for (const sourceFile of builder.getSourceFiles()) {
94
- if (!ignoreForDiagnostics.has(sourceFile)) {
95
- allDiagnostics.push(...builder.getDeclarationDiagnostics(sourceFile), ...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
96
- }
97
- if (sourceFile.isDeclarationFile) {
98
- continue;
99
- }
100
- // Collect sources that are required to be emitted
101
- const angularVersion = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
102
- const incrementalCompilation = angularVersion.major < 16
103
- ? angularCompiler.incrementalDriver
104
- : angularCompiler.incrementalCompilation;
105
- if (!ignoreForEmit.has(sourceFile) &&
106
- !incrementalCompilation.safeToSkipEmit(sourceFile)) {
107
- // If required to emit, diagnostics may have also changed
108
- if (!ignoreForDiagnostics.has(sourceFile)) {
109
- affectedFiles.add(sourceFile);
110
- }
111
- }
112
- else if (sourceFileCache &&
113
- !affectedFiles.has(sourceFile) &&
114
- !ignoreForDiagnostics.has(sourceFile)) {
115
- // Use cached Angular diagnostics for unchanged and unaffected files
116
- const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);
117
- if (angularDiagnostics === null || angularDiagnostics === void 0 ? void 0 : angularDiagnostics.length) {
118
- allDiagnostics.push(...angularDiagnostics);
119
- }
120
- }
83
+ }
84
+ // Collect program level diagnostics
85
+ const allDiagnostics = [
86
+ ...angularCompiler.getOptionDiagnostics(),
87
+ ...builder.getOptionsDiagnostics(),
88
+ ...builder.getGlobalDiagnostics(),
89
+ ];
90
+ // Required to support asynchronous resource loading
91
+ // Must be done before creating transformers or getting template diagnostics
92
+ await angularCompiler.analyzeAsync();
93
+ // Collect source file specific diagnostics
94
+ for (const sourceFile of builder.getSourceFiles()) {
95
+ if (!ignoreForDiagnostics.has(sourceFile)) {
96
+ allDiagnostics.push(...builder.getDeclarationDiagnostics(sourceFile), ...builder.getSyntacticDiagnostics(sourceFile), ...builder.getSemanticDiagnostics(sourceFile));
121
97
  }
122
- // Collect new Angular diagnostics for files affected by changes
123
- for (const affectedFile of affectedFiles) {
124
- const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile,
125
- /** OptimizeFor.WholeProgram */ 1);
126
- allDiagnostics.push(...angularDiagnostics);
127
- sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);
98
+ if (sourceFile.isDeclarationFile) {
99
+ continue;
128
100
  }
129
- const otherDiagnostics = [];
130
- const errorDiagnostics = [];
131
- for (const diagnostic of allDiagnostics) {
132
- if (diagnostic.category === ts.DiagnosticCategory.Error) {
133
- errorDiagnostics.push(diagnostic);
101
+ // Collect sources that are required to be emitted
102
+ const angularVersion = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
103
+ const incrementalCompilation = angularVersion.major < 16
104
+ ? angularCompiler.incrementalDriver
105
+ : angularCompiler.incrementalCompilation;
106
+ if (!ignoreForEmit.has(sourceFile) &&
107
+ !incrementalCompilation.safeToSkipEmit(sourceFile)) {
108
+ // If required to emit, diagnostics may have also changed
109
+ if (!ignoreForDiagnostics.has(sourceFile)) {
110
+ affectedFiles.add(sourceFile);
134
111
  }
135
- else {
136
- otherDiagnostics.push(diagnostic);
112
+ }
113
+ else if (sourceFileCache &&
114
+ !affectedFiles.has(sourceFile) &&
115
+ !ignoreForDiagnostics.has(sourceFile)) {
116
+ // Use cached Angular diagnostics for unchanged and unaffected files
117
+ const angularDiagnostics = sourceFileCache.getAngularDiagnostics(sourceFile);
118
+ if (angularDiagnostics?.length) {
119
+ allDiagnostics.push(...angularDiagnostics);
137
120
  }
138
121
  }
139
- if (otherDiagnostics.length) {
140
- log.msg(formatDiagnostics(errorDiagnostics));
122
+ }
123
+ // Collect new Angular diagnostics for files affected by changes
124
+ for (const affectedFile of affectedFiles) {
125
+ const angularDiagnostics = angularCompiler.getDiagnosticsForFile(affectedFile,
126
+ /** OptimizeFor.WholeProgram */ 1);
127
+ allDiagnostics.push(...angularDiagnostics);
128
+ sourceFileCache.updateAngularDiagnostics(affectedFile, angularDiagnostics);
129
+ }
130
+ const otherDiagnostics = [];
131
+ const errorDiagnostics = [];
132
+ for (const diagnostic of allDiagnostics) {
133
+ if (diagnostic.category === ts.DiagnosticCategory.Error) {
134
+ errorDiagnostics.push(diagnostic);
141
135
  }
142
- if (errorDiagnostics.length) {
143
- throw new Error(formatDiagnostics(errorDiagnostics));
136
+ else {
137
+ otherDiagnostics.push(diagnostic);
144
138
  }
145
- const transformers = angularCompiler.prepareEmit().transformers;
146
- for (const sourceFile of builder.getSourceFiles()) {
147
- if (!ignoreForEmit.has(sourceFile)) {
148
- builder.emit(sourceFile, undefined, undefined, undefined, transformers);
149
- }
139
+ }
140
+ if (otherDiagnostics.length) {
141
+ log.msg(formatDiagnostics(errorDiagnostics));
142
+ }
143
+ if (errorDiagnostics.length) {
144
+ throw new Error(formatDiagnostics(errorDiagnostics));
145
+ }
146
+ const transformers = angularCompiler.prepareEmit().transformers;
147
+ for (const sourceFile of builder.getSourceFiles()) {
148
+ if (!ignoreForEmit.has(sourceFile)) {
149
+ builder.emit(sourceFile, undefined, undefined, undefined, transformers);
150
150
  }
151
- });
151
+ }
152
152
  }
153
153
  exports.compileSourceFiles = compileSourceFiles;
@@ -10,7 +10,6 @@
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.StylesheetProcessor = exports.CssUrl = void 0;
13
- const tslib_1 = require("tslib");
14
13
  const browserslist = require("browserslist");
15
14
  const fs_1 = require("fs");
16
15
  const esbuild_executor_1 = require("ng-packagr/lib/esbuild/esbuild-executor");
@@ -65,82 +64,78 @@ class StylesheetProcessor {
65
64
  this.tailwindSetup = (0, tailwindcss_1.getTailwindSetup)(this.basePath, this.tailwindConfig);
66
65
  this.postCssProcessor = this.createPostCssPlugins();
67
66
  }
68
- process({ filePath, content, }) {
69
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
70
- let key;
71
- if (this.cacheDirectory &&
72
- !content.includes('@import') &&
73
- !content.includes('@use') &&
74
- !this.containsTailwindDirectives(content)) {
75
- // No transitive deps and no Tailwind directives, we can cache more aggressively.
76
- key = yield (0, cache_1.generateKey)(content, ...this.browserslistData, filePath);
77
- const result = yield (0, cache_1.readCacheEntry)(this.cacheDirectory, key);
78
- if (result) {
79
- result.warnings.forEach((msg) => log.warn(msg));
80
- return result.css;
81
- }
67
+ async process({ filePath, content, }) {
68
+ let key;
69
+ if (this.cacheDirectory &&
70
+ !content.includes('@import') &&
71
+ !content.includes('@use') &&
72
+ !this.containsTailwindDirectives(content)) {
73
+ // No transitive deps and no Tailwind directives, we can cache more aggressively.
74
+ key = await (0, cache_1.generateKey)(content, ...this.browserslistData, filePath);
75
+ const result = await (0, cache_1.readCacheEntry)(this.cacheDirectory, key);
76
+ if (result) {
77
+ result.warnings.forEach((msg) => log.warn(msg));
78
+ return result.css;
82
79
  }
83
- // Render pre-processor language (sass, styl, less)
84
- const renderedCss = yield this.renderCss(filePath, content);
85
- let containsTailwindDirectives = false;
86
- if (this.cacheDirectory) {
87
- containsTailwindDirectives = this.containsTailwindDirectives(renderedCss);
88
- if (!containsTailwindDirectives) {
89
- // No Tailwind directives to process by PostCSS, we can return cached results
90
- if (!key) {
91
- key = yield (0, cache_1.generateKey)(renderedCss, ...this.browserslistData, filePath);
92
- }
93
- const cachedResult = yield this.getCachedResult(key);
94
- if (cachedResult) {
95
- return cachedResult;
96
- }
80
+ }
81
+ // Render pre-processor language (sass, styl, less)
82
+ const renderedCss = await this.renderCss(filePath, content);
83
+ let containsTailwindDirectives = false;
84
+ if (this.cacheDirectory) {
85
+ containsTailwindDirectives = this.containsTailwindDirectives(renderedCss);
86
+ if (!containsTailwindDirectives) {
87
+ // No Tailwind directives to process by PostCSS, we can return cached results
88
+ if (!key) {
89
+ key = await (0, cache_1.generateKey)(renderedCss, ...this.browserslistData, filePath);
97
90
  }
98
- }
99
- // Render postcss (autoprefixing and friends)
100
- const result = yield this.postCssProcessor.process(renderedCss, {
101
- from: filePath,
102
- to: filePath.replace((0, path_1.extname)(filePath), '.css'),
103
- });
104
- if (this.cacheDirectory && containsTailwindDirectives) {
105
- // We had Tailwind directives to process by PostCSS, only now
106
- // is safe to return cached results
107
- key = yield (0, cache_1.generateKey)(result.css, ...this.browserslistData, filePath);
108
- const cachedResult = yield this.getCachedResult(key);
91
+ const cachedResult = await this.getCachedResult(key);
109
92
  if (cachedResult) {
110
93
  return cachedResult;
111
94
  }
112
95
  }
113
- const warnings = result.warnings().map((w) => w.toString());
114
- const { code, warnings: esBuildWarnings } = yield this.esbuild.transform(result.css, {
115
- loader: 'css',
116
- minify: true,
117
- target: this.targets,
118
- sourcefile: filePath,
119
- });
120
- if (esBuildWarnings.length > 0) {
121
- warnings.push(...(yield this.esbuild.formatMessages(esBuildWarnings, {
122
- kind: 'warning',
123
- })));
124
- }
125
- if (this.cacheDirectory) {
126
- yield (0, cache_1.saveCacheEntry)(this.cacheDirectory, key, JSON.stringify({
127
- css: code,
128
- warnings,
129
- }));
130
- }
131
- warnings.forEach((msg) => log.warn(msg));
132
- return code;
96
+ }
97
+ // Render postcss (autoprefixing and friends)
98
+ const result = await this.postCssProcessor.process(renderedCss, {
99
+ from: filePath,
100
+ to: filePath.replace((0, path_1.extname)(filePath), '.css'),
133
101
  });
134
- }
135
- getCachedResult(key) {
136
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
137
- const cachedResult = yield (0, cache_1.readCacheEntry)(this.cacheDirectory, key);
102
+ if (this.cacheDirectory && containsTailwindDirectives) {
103
+ // We had Tailwind directives to process by PostCSS, only now
104
+ // is safe to return cached results
105
+ key = await (0, cache_1.generateKey)(result.css, ...this.browserslistData, filePath);
106
+ const cachedResult = await this.getCachedResult(key);
138
107
  if (cachedResult) {
139
- cachedResult.warnings.forEach((msg) => log.warn(msg));
140
- return cachedResult.css;
108
+ return cachedResult;
141
109
  }
142
- return undefined;
110
+ }
111
+ const warnings = result.warnings().map((w) => w.toString());
112
+ const { code, warnings: esBuildWarnings } = await this.esbuild.transform(result.css, {
113
+ loader: 'css',
114
+ minify: true,
115
+ target: this.targets,
116
+ sourcefile: filePath,
143
117
  });
118
+ if (esBuildWarnings.length > 0) {
119
+ warnings.push(...(await this.esbuild.formatMessages(esBuildWarnings, {
120
+ kind: 'warning',
121
+ })));
122
+ }
123
+ if (this.cacheDirectory) {
124
+ await (0, cache_1.saveCacheEntry)(this.cacheDirectory, key, JSON.stringify({
125
+ css: code,
126
+ warnings,
127
+ }));
128
+ }
129
+ warnings.forEach((msg) => log.warn(msg));
130
+ return code;
131
+ }
132
+ async getCachedResult(key) {
133
+ const cachedResult = await (0, cache_1.readCacheEntry)(this.cacheDirectory, key);
134
+ if (cachedResult) {
135
+ cachedResult.warnings.forEach((msg) => log.warn(msg));
136
+ return cachedResult.css;
137
+ }
138
+ return undefined;
144
139
  }
145
140
  containsTailwindDirectives(content) {
146
141
  return (this.tailwindSetup && tailwindcss_1.tailwindDirectives.some((d) => content.includes(d)));
@@ -160,46 +155,44 @@ class StylesheetProcessor {
160
155
  }));
161
156
  return postcss(postCssPlugins);
162
157
  }
163
- renderCss(filePath, css) {
164
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
165
- const ext = (0, path_1.extname)(filePath);
166
- switch (ext) {
167
- case '.sass':
168
- case '.scss': {
169
- const angularVersion = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
170
- if (angularVersion && angularVersion.major < 15) {
171
- return (yield Promise.resolve().then(() => require('sass')))
172
- .renderSync({
173
- file: filePath,
174
- data: css,
175
- indentedSyntax: '.sass' === ext,
176
- importer: customSassImporter,
177
- includePaths: this.styleIncludePaths,
178
- })
179
- .css.toString();
180
- }
181
- return (yield Promise.resolve().then(() => require('sass')))
182
- .compileString(css, {
183
- url: (0, node_url_1.pathToFileURL)(filePath),
184
- syntax: '.sass' === ext ? 'indented' : 'scss',
185
- loadPaths: this.styleIncludePaths,
158
+ async renderCss(filePath, css) {
159
+ const ext = (0, path_1.extname)(filePath);
160
+ switch (ext) {
161
+ case '.sass':
162
+ case '.scss': {
163
+ const angularVersion = (0, angular_version_utils_1.getInstalledAngularVersionInfo)();
164
+ if (angularVersion && angularVersion.major < 15) {
165
+ return (await Promise.resolve().then(() => require('sass')))
166
+ .renderSync({
167
+ file: filePath,
168
+ data: css,
169
+ indentedSyntax: '.sass' === ext,
170
+ importer: customSassImporter,
171
+ includePaths: this.styleIncludePaths,
186
172
  })
187
173
  .css.toString();
188
174
  }
189
- case '.less': {
190
- const { css: content } = yield (yield Promise.resolve().then(() => require('less'))).render(css, {
191
- filename: filePath,
192
- math: 'always',
193
- javascriptEnabled: true,
194
- paths: this.styleIncludePaths,
195
- });
196
- return content;
197
- }
198
- case '.css':
199
- default:
200
- return css;
175
+ return (await Promise.resolve().then(() => require('sass')))
176
+ .compileString(css, {
177
+ url: (0, node_url_1.pathToFileURL)(filePath),
178
+ syntax: '.sass' === ext ? 'indented' : 'scss',
179
+ loadPaths: this.styleIncludePaths,
180
+ })
181
+ .css.toString();
201
182
  }
202
- });
183
+ case '.less': {
184
+ const { css: content } = await (await Promise.resolve().then(() => require('less'))).render(css, {
185
+ filename: filePath,
186
+ math: 'always',
187
+ javascriptEnabled: true,
188
+ paths: this.styleIncludePaths,
189
+ });
190
+ return content;
191
+ }
192
+ case '.css':
193
+ default:
194
+ return css;
195
+ }
203
196
  }
204
197
  }
205
198
  exports.StylesheetProcessor = StylesheetProcessor;