@nx/angular 16.8.0-beta.3 → 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.
- package/mf/mf.js +31 -36
- package/migrations.json +9 -0
- package/package.json +11 -11
- package/plugins/component-testing.js +82 -44
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +4 -6
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +4 -6
- package/src/builders/utilities/buildable-libs.js +1 -2
- package/src/builders/utilities/module-federation.js +2 -3
- package/src/builders/utilities/webpack.js +16 -21
- package/src/builders/webpack-browser/webpack-browser.impl.js +13 -13
- package/src/builders/webpack-dev-server/lib/normalize-options.js +8 -1
- package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -18
- package/src/builders/webpack-server/webpack-server.impl.js +5 -7
- package/src/executors/browser-esbuild/browser-esbuild.impl.js +19 -23
- package/src/executors/browser-esbuild/lib/buildable-libs.js +1 -2
- package/src/executors/delegate-build/delegate-build.impl.js +9 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +4 -7
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.transform.js +4 -5
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +158 -156
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/options.di.js +6 -3
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +118 -118
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ts/cache-compiler-host.js +20 -12
- package/src/executors/ng-packagr-lite/ng-packagr-lite.impl.js +18 -21
- package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js +6 -9
- package/src/executors/package/ng-packagr-adjustments/ng-package/options.di.js +6 -3
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +122 -122
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +96 -103
- package/src/executors/package/ng-packagr-adjustments/ts/cache-compiler-host.js +21 -13
- package/src/executors/package/ng-packagr-adjustments/utils/ng-compiler-cli.js +5 -8
- package/src/executors/package/package.impl.js +33 -38
- package/src/executors/utilities/angular-version-utils.js +1 -1
- package/src/executors/utilities/tailwindcss.js +2 -2
- package/src/executors/utilities/typescript.js +23 -28
- package/src/generators/add-linting/add-linting.js +76 -69
- package/src/generators/add-linting/lib/add-angular-eslint-dependencies.js +2 -0
- package/src/generators/add-linting/lib/create-eslint-configuration.js +12 -4
- package/src/generators/application/application.js +56 -55
- package/src/generators/application/lib/add-e2e.js +36 -40
- package/src/generators/application/lib/add-linting.js +12 -15
- package/src/generators/application/lib/add-proxy-config.js +4 -1
- package/src/generators/application/lib/add-unit-test-runner.js +15 -18
- package/src/generators/application/lib/create-files.js +44 -47
- package/src/generators/application/lib/enable-strict-type-checking.js +2 -2
- package/src/generators/application/lib/normalize-options.js +37 -25
- package/src/generators/application/lib/set-app-strict-default.js +1 -2
- package/src/generators/application/lib/update-editor-tsconfig.js +1 -2
- package/src/generators/component/component.js +40 -43
- package/src/generators/component/lib/normalize-options.js +15 -5
- package/src/generators/component-cypress-spec/component-cypress-spec.js +25 -28
- package/src/generators/component-story/component-story.js +19 -22
- package/src/generators/convert-to-with-mf/convert-to-with-mf.js +19 -22
- package/src/generators/convert-to-with-mf/lib/get-webpack-config-path.js +3 -4
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +103 -106
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +59 -62
- package/src/generators/directive/directive.js +21 -24
- package/src/generators/directive/lib/normalize-options.js +11 -5
- package/src/generators/host/files/src/main.server.ts__tmpl__ +1 -1
- package/src/generators/host/host.js +77 -67
- package/src/generators/host/lib/add-ssr.js +32 -33
- package/src/generators/init/init.js +101 -92
- package/src/generators/library/lib/add-standalone-component.js +18 -13
- package/src/generators/library/lib/enable-strict-type-checking.js +17 -5
- package/src/generators/library/lib/normalize-options.js +68 -53
- package/src/generators/library/library.js +89 -92
- package/src/generators/library-secondary-entry-point/lib/add-files.js +5 -1
- package/src/generators/library-secondary-entry-point/lib/normalize-options.js +6 -3
- package/src/generators/library-secondary-entry-point/lib/update-linting-file-patterns.js +1 -2
- package/src/generators/library-secondary-entry-point/library-secondary-entry-point.js +6 -9
- package/src/generators/move/lib/normalize-schema.js +5 -1
- package/src/generators/move/lib/update-module-name.js +1 -1
- package/src/generators/move/lib/update-ng-package.js +1 -2
- package/src/generators/move/lib/update-secondary-entry-points.js +1 -2
- package/src/generators/move/move.js +9 -12
- package/src/generators/ng-add/migrate-from-angular-cli.js +54 -53
- package/src/generators/ng-add/migrators/builders/angular-devkit-karma.migrator.js +4 -3
- package/src/generators/ng-add/migrators/builders/angular-devkit-ng-packagr.migrator.js +11 -12
- package/src/generators/ng-add/migrators/builders/angular-eslint-lint.migrator.js +39 -42
- package/src/generators/ng-add/migrators/builders/builder.migrator.js +1 -2
- package/src/generators/ng-add/migrators/migrator.js +7 -11
- package/src/generators/ng-add/migrators/projects/app.migrator.js +39 -43
- package/src/generators/ng-add/migrators/projects/e2e.migrator.js +115 -91
- package/src/generators/ng-add/migrators/projects/lib.migrator.js +23 -31
- package/src/generators/ng-add/migrators/projects/project.migrator.js +10 -14
- package/src/generators/ng-add/ng-add.js +5 -8
- package/src/generators/ng-add/utilities/dependencies.js +2 -3
- package/src/generators/ng-add/utilities/format-files-task.js +1 -1
- package/src/generators/ng-add/utilities/projects.js +1 -1
- package/src/generators/ng-add/utilities/workspace.js +25 -36
- package/src/generators/ngrx/lib/add-imports-to-module.js +1 -2
- package/src/generators/ngrx/lib/add-ngrx-to-package-json.js +1 -3
- package/src/generators/ngrx/lib/generate-files.js +11 -2
- package/src/generators/ngrx/lib/normalize-options.js +9 -4
- package/src/generators/ngrx/lib/validate-options.js +3 -3
- package/src/generators/ngrx/ngrx.js +18 -21
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.actions.ts__tmpl__ +1 -1
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.spec.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.spec.ts__tmpl__ +6 -6
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.spec.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.reducer.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.spec.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/files/base/__directory__/__fileName__.selectors.ts__tmpl__ +1 -1
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +2 -2
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +3 -3
- package/src/generators/ngrx-feature-store/lib/add-exports-barrel.js +4 -1
- package/src/generators/ngrx-feature-store/lib/add-imports.js +1 -1
- package/src/generators/ngrx-feature-store/lib/add-ngrx-to-package-json.js +1 -3
- package/src/generators/ngrx-feature-store/lib/generate-files.js +20 -4
- package/src/generators/ngrx-feature-store/lib/normalize-options.d.ts +1 -0
- package/src/generators/ngrx-feature-store/lib/normalize-options.js +22 -3
- package/src/generators/ngrx-feature-store/lib/validate-options.js +2 -2
- package/src/generators/ngrx-feature-store/ngrx-feature-store.js +18 -21
- package/src/generators/ngrx-root-store/lib/add-ngrx-to-package-json.js +8 -6
- package/src/generators/ngrx-root-store/lib/normalize-options.js +8 -4
- package/src/generators/ngrx-root-store/lib/validate-options.js +2 -2
- package/src/generators/ngrx-root-store/ngrx-root-store.js +27 -30
- package/src/generators/pipe/lib/normalize-options.js +9 -3
- package/src/generators/pipe/pipe.js +21 -24
- package/src/generators/remote/files/base/src/main.server.ts__tmpl__ +2 -2
- package/src/generators/remote/lib/add-ssr.js +46 -43
- package/src/generators/remote/lib/find-next-available-port.js +1 -2
- package/src/generators/remote/remote.js +52 -49
- package/src/generators/scam/lib/convert-component-to-scam.js +1 -2
- package/src/generators/scam/lib/normalize-options.js +11 -4
- package/src/generators/scam/scam.js +15 -12
- package/src/generators/scam-directive/lib/normalize-options.js +12 -4
- package/src/generators/scam-directive/scam-directive.js +13 -10
- package/src/generators/scam-pipe/lib/normalize-options.js +12 -4
- package/src/generators/scam-pipe/scam-pipe.js +13 -10
- package/src/generators/scam-to-standalone/scam-to-standalone.js +23 -26
- package/src/generators/setup-mf/lib/add-cypress-workaround.js +1 -1
- package/src/generators/setup-mf/lib/add-remote-to-host.js +4 -1
- package/src/generators/setup-mf/lib/change-build-target.js +10 -4
- package/src/generators/setup-mf/lib/generate-config.js +1 -1
- package/src/generators/setup-mf/lib/get-remotes-with-ports.js +1 -2
- package/src/generators/setup-mf/lib/normalize-options.js +5 -2
- package/src/generators/setup-mf/lib/set-tsconfig-target.js +7 -1
- package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +1 -2
- package/src/generators/setup-mf/lib/setup-serve-target.js +10 -3
- package/src/generators/setup-mf/setup-mf.js +32 -35
- package/src/generators/setup-ssr/lib/generate-files.js +8 -5
- package/src/generators/setup-ssr/lib/normalize-options.js +9 -10
- package/src/generators/setup-ssr/lib/update-project-config.js +21 -17
- package/src/generators/setup-ssr/setup-ssr.js +26 -27
- package/src/generators/setup-tailwind/lib/add-tailwind-config-path-to-project.js +6 -4
- package/src/generators/setup-tailwind/lib/detect-tailwind-installed-version.js +1 -2
- package/src/generators/setup-tailwind/lib/normalize-options.js +4 -1
- package/src/generators/setup-tailwind/lib/update-application-styles.js +5 -6
- package/src/generators/setup-tailwind/setup-tailwind.js +20 -23
- package/src/generators/stories/lib/get-e2e-project.js +1 -1
- package/src/generators/stories/stories.js +43 -50
- package/src/generators/storybook-configuration/lib/assert-compatible-storybook-version.js +1 -1
- package/src/generators/storybook-configuration/lib/generate-stories.js +10 -13
- package/src/generators/storybook-configuration/lib/generate-storybook-configuration.js +12 -15
- package/src/generators/storybook-configuration/storybook-configuration.js +20 -16
- package/src/generators/utils/create-ts-config.js +1 -1
- package/src/generators/utils/entry-point.js +1 -2
- package/src/generators/utils/export-scam.js +1 -1
- package/src/generators/utils/insert-ngmodule-import.js +1 -1
- package/src/generators/utils/path.js +3 -3
- package/src/generators/utils/project.js +2 -3
- package/src/generators/utils/selector.js +1 -1
- package/src/generators/utils/storybook-ast/component-info.js +1 -2
- package/src/generators/utils/storybook-ast/entry-point.js +1 -2
- package/src/generators/utils/storybook-ast/module-info.js +1 -2
- package/src/generators/utils/storybook-ast/tree-utilities.js +1 -1
- package/src/generators/utils/testing.js +141 -138
- package/src/generators/utils/validations.js +1 -1
- package/src/generators/utils/version-utils.js +5 -7
- package/src/generators/web-worker/lib/normalize-options.js +6 -3
- package/src/generators/web-worker/web-worker.js +25 -28
- package/src/migrations/update-14-2-0/remove-show-circular-dependencies-option.js +10 -13
- package/src/migrations/update-14-2-0/update-angular-cli.js +14 -18
- package/src/migrations/update-14-2-0/update-libraries-secondary-entrypoints.js +22 -26
- package/src/migrations/update-14-2-0/update-ngcc-target.js +10 -14
- package/src/migrations/update-14-2-0/update-router-initial-navigation.js +31 -39
- package/src/migrations/update-14-2-0/update-tsconfig-target.js +48 -56
- package/src/migrations/update-14-5-0/migrate-mfe-to-mf.js +14 -17
- package/src/migrations/update-14-5-2/update-angular-cli.js +14 -18
- package/src/migrations/update-14-6-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-0-0/add-karma-inputs.js +27 -32
- package/src/migrations/update-15-0-0/switch-to-jasmine-marbles.js +62 -68
- package/src/migrations/update-15-2-0/remove-browserlist-config.js +34 -37
- package/src/migrations/update-15-2-0/remove-platform-server-exports.js +49 -52
- package/src/migrations/update-15-2-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-2-0/update-karma-main-file.js +11 -12
- package/src/migrations/update-15-2-0/update-typescript-target.js +40 -39
- package/src/migrations/update-15-2-0/update-workspace-config.js +16 -19
- package/src/migrations/update-15-5-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-7-0/install-required-packages.js +26 -28
- package/src/migrations/update-15-8-0/update-angular-cli.js +14 -18
- package/src/migrations/update-15-9-0/update-file-server-executor.js +31 -35
- package/src/migrations/update-15-9-0/update-testing-tsconfig.js +17 -22
- package/src/migrations/update-16-0-0/remove-karma-defaults.js +15 -18
- package/src/migrations/update-16-0-0/remove-library-generator-simple-module-name-option.js +22 -25
- package/src/migrations/update-16-0-0/remove-protractor-defaults.js +15 -18
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-1-0/extract-standalone-config-from-bootstrap.js +38 -42
- package/src/migrations/update-16-1-0/remove-ngcc-invocation.js +15 -19
- package/src/migrations/update-16-1-0/remove-render-module-platform-server-exports.js +49 -52
- package/src/migrations/update-16-1-0/update-angular-cli.js +14 -18
- package/src/migrations/update-16-1-0/update-server-executor-config.js +13 -16
- package/src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store.js +25 -29
- package/src/migrations/update-16-4-0/rename-angular-eslint-accesibility-rules.js +13 -16
- package/src/migrations/update-16-4-0/update-angular-cli.js +14 -18
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +19 -24
- package/src/migrations/update-16-7-0/update-angular-cli.js +14 -18
- package/src/migrations/utils/projects.js +9 -15
- package/src/utils/backward-compatible-versions.js +2 -0
- package/src/utils/get-mf-projects.js +1 -2
- package/src/utils/mf/utils.js +43 -44
- package/src/utils/mf/with-module-federation-ssr.js +39 -24
- package/src/utils/mf/with-module-federation.js +40 -21
- package/src/utils/nx-devkit/ast-utils.js +2 -3
- package/src/utils/nx-devkit/testing.js +9 -9
- package/src/utils/version-utils.js +2 -4
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.js +2 -1
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
package/src/executors/package/ng-packagr-adjustments/ng-package/entry-point/compile-ngc.transform.js
CHANGED
|
@@ -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) =>
|
|
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)(
|
|
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
|
-
|
|
47
|
+
await ngccProcessor.process();
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
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 =
|
|
23
|
+
const isCI = ciEnv?.toLowerCase() === 'true' || ciEnv === '1';
|
|
24
24
|
const { cacheEnabled = !isCI, cacheDirectory = findCachePath() } = options;
|
|
25
|
-
return
|
|
26
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
76
|
-
});
|
|
77
|
-
if (!result) {
|
|
78
|
-
break;
|
|
74
|
+
return true;
|
|
79
75
|
}
|
|
80
|
-
|
|
76
|
+
return false;
|
|
77
|
+
});
|
|
78
|
+
if (!result) {
|
|
79
|
+
break;
|
|
81
80
|
}
|
|
81
|
+
affectedFiles.add(result.affected);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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
|
-
|
|
143
|
-
|
|
136
|
+
else {
|
|
137
|
+
otherDiagnostics.push(diagnostic);
|
|
144
138
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
|
140
|
-
return cachedResult.css;
|
|
108
|
+
return cachedResult;
|
|
141
109
|
}
|
|
142
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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;
|