@angular-devkit/build-angular 18.0.0-next.3 → 18.0.0-next.4
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/builders.json +1 -5
- package/package.json +14 -13
- package/src/builders/app-shell/index.js +3 -5
- package/src/builders/browser/index.d.ts +1 -1
- package/src/builders/browser/index.js +8 -12
- package/src/builders/browser-esbuild/index.d.ts +2 -2
- package/src/builders/browser-esbuild/index.js +6 -9
- package/src/builders/dev-server/builder.d.ts +2 -2
- package/src/builders/dev-server/builder.js +11 -6
- package/src/builders/dev-server/index.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.d.ts +1 -1
- package/src/builders/dev-server/webpack-server.js +3 -4
- package/src/builders/extract-i18n/application-extraction.js +2 -2
- package/src/builders/extract-i18n/builder.js +3 -4
- package/src/builders/extract-i18n/options.d.ts +1 -1
- package/src/builders/extract-i18n/options.js +2 -2
- package/src/builders/jest/index.js +2 -2
- package/src/builders/karma/index.js +3 -4
- package/src/builders/ng-packagr/index.js +8 -7
- package/src/builders/ng-packagr/schema.d.ts +4 -0
- package/src/builders/ng-packagr/schema.json +4 -0
- package/src/builders/prerender/index.js +2 -2
- package/src/builders/prerender/render-worker.js +1 -1
- package/src/builders/server/index.js +3 -4
- package/src/builders/server/platform-server-exports-loader.js +2 -1
- package/src/builders/ssr-dev-server/index.js +7 -7
- package/src/builders/web-test-runner/index.js +2 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -2
- package/src/tools/babel/presets/application.js +1 -1
- package/src/tools/webpack/configs/styles.js +2 -2
- package/src/tools/webpack/plugins/any-component-style-budget-checker.d.ts +1 -1
- package/src/tools/webpack/plugins/any-component-style-budget-checker.js +5 -5
- package/src/tools/webpack/plugins/css-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/index-html-webpack-plugin.d.ts +1 -1
- package/src/tools/webpack/plugins/index-html-webpack-plugin.js +2 -2
- package/src/tools/webpack/plugins/javascript-optimizer-plugin.js +2 -2
- package/src/tools/webpack/plugins/service-worker-plugin.js +2 -2
- package/src/tools/webpack/utils/stats.d.ts +1 -1
- package/src/tools/webpack/utils/stats.js +2 -2
- package/src/utils/i18n-webpack.d.ts +1 -1
- package/src/utils/i18n-webpack.js +5 -6
- package/src/utils/index.d.ts +1 -2
- package/src/utils/index.js +4 -2
- package/src/utils/normalize-builder-schema.js +2 -2
- package/src/utils/normalize-cache.js +1 -1
- package/src/utils/normalize-optimization.d.ts +1 -1
- package/src/utils/normalize-optimization.js +0 -2
- package/src/builders/application/build-action.d.ts +0 -33
- package/src/builders/application/build-action.js +0 -183
- package/src/builders/application/execute-build.d.ts +0 -11
- package/src/builders/application/execute-build.js +0 -125
- package/src/builders/application/execute-post-bundle.d.ts +0 -25
- package/src/builders/application/execute-post-bundle.js +0 -93
- package/src/builders/application/i18n.d.ts +0 -29
- package/src/builders/application/i18n.js +0 -128
- package/src/builders/application/index.d.ts +0 -57
- package/src/builders/application/index.js +0 -121
- package/src/builders/application/options.d.ts +0 -149
- package/src/builders/application/options.js +0 -369
- package/src/builders/application/schema.d.ts +0 -512
- package/src/builders/application/schema.js +0 -58
- package/src/builders/application/schema.json +0 -635
- package/src/builders/application/setup-bundling.d.ts +0 -19
- package/src/builders/application/setup-bundling.js +0 -71
- package/src/builders/dev-server/vite-server.d.ts +0 -30
- package/src/builders/dev-server/vite-server.js +0 -502
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -27
- package/src/tools/babel/plugins/adjust-static-class-members.js +0 -351
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -23
- package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
- package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
- package/src/tools/babel/plugins/index.d.ts +0 -11
- package/src/tools/babel/plugins/index.js +0 -21
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -16
- package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -90
- package/src/tools/esbuild/angular/angular-host.d.ts +0 -26
- package/src/tools/esbuild/angular/angular-host.js +0 -72
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +0 -94
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +0 -228
- package/src/tools/esbuild/angular/compilation/factory.d.ts +0 -16
- package/src/tools/esbuild/angular/compilation/factory.js +0 -56
- package/src/tools/esbuild/angular/compilation/index.d.ts +0 -10
- package/src/tools/esbuild/angular/compilation/index.js +0 -17
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +0 -21
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +0 -106
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +0 -20
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +0 -26
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +0 -42
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +0 -123
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -33
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +0 -90
- package/src/tools/esbuild/angular/compilation-state.d.ts +0 -15
- package/src/tools/esbuild/angular/compilation-state.js +0 -44
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +0 -27
- package/src/tools/esbuild/angular/compiler-plugin.js +0 -441
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +0 -44
- package/src/tools/esbuild/angular/component-stylesheets.js +0 -150
- package/src/tools/esbuild/angular/diagnostics.d.ts +0 -15
- package/src/tools/esbuild/angular/diagnostics.js +0 -69
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +0 -17
- package/src/tools/esbuild/angular/file-reference-tracker.js +0 -57
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +0 -23
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +0 -117
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/jit-resource-transformer.js +0 -186
- package/src/tools/esbuild/angular/source-file-cache.d.ts +0 -18
- package/src/tools/esbuild/angular/source-file-cache.js +0 -65
- package/src/tools/esbuild/angular/uri.d.ts +0 -54
- package/src/tools/esbuild/angular/uri.js +0 -74
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +0 -17
- package/src/tools/esbuild/angular/web-worker-transformer.js +0 -94
- package/src/tools/esbuild/application-code-bundle.d.ts +0 -20
- package/src/tools/esbuild/application-code-bundle.js +0 -368
- package/src/tools/esbuild/budget-stats.d.ts +0 -19
- package/src/tools/esbuild/budget-stats.js +0 -59
- package/src/tools/esbuild/bundler-context.d.ts +0 -75
- package/src/tools/esbuild/bundler-context.js +0 -366
- package/src/tools/esbuild/bundler-execution-result.d.ts +0 -71
- package/src/tools/esbuild/bundler-execution-result.js +0 -131
- package/src/tools/esbuild/cache.d.ts +0 -88
- package/src/tools/esbuild/cache.js +0 -92
- package/src/tools/esbuild/commonjs-checker.d.ts +0 -28
- package/src/tools/esbuild/commonjs-checker.js +0 -151
- package/src/tools/esbuild/compiler-plugin-options.d.ts +0 -16
- package/src/tools/esbuild/compiler-plugin-options.js +0 -49
- package/src/tools/esbuild/external-packages-plugin.d.ts +0 -18
- package/src/tools/esbuild/external-packages-plugin.js +0 -70
- package/src/tools/esbuild/global-scripts.d.ts +0 -16
- package/src/tools/esbuild/global-scripts.js +0 -142
- package/src/tools/esbuild/global-styles.d.ts +0 -10
- package/src/tools/esbuild/global-styles.js +0 -74
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +0 -42
- package/src/tools/esbuild/i18n-inliner-worker.js +0 -136
- package/src/tools/esbuild/i18n-inliner.d.ts +0 -44
- package/src/tools/esbuild/i18n-inliner.js +0 -150
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +0 -22
- package/src/tools/esbuild/i18n-locale-plugin.js +0 -120
- package/src/tools/esbuild/index-html-generator.d.ts +0 -15
- package/src/tools/esbuild/index-html-generator.js +0 -81
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +0 -19
- package/src/tools/esbuild/javascript-transformer-worker.js +0 -154
- package/src/tools/esbuild/javascript-transformer.d.ts +0 -54
- package/src/tools/esbuild/javascript-transformer.js +0 -147
- package/src/tools/esbuild/license-extractor.d.ts +0 -25
- package/src/tools/esbuild/license-extractor.js +0 -158
- package/src/tools/esbuild/load-result-cache.d.ts +0 -21
- package/src/tools/esbuild/load-result-cache.js +0 -75
- package/src/tools/esbuild/profiling.d.ts +0 -11
- package/src/tools/esbuild/profiling.js +0 -78
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +0 -18
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +0 -44
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +0 -17
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +0 -73
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +0 -35
- package/src/tools/esbuild/stylesheets/bundle-options.js +0 -64
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +0 -25
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +0 -57
- package/src/tools/esbuild/stylesheets/css-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/css-language.js +0 -15
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +0 -18
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +0 -114
- package/src/tools/esbuild/stylesheets/less-language.d.ts +0 -9
- package/src/tools/esbuild/stylesheets/less-language.js +0 -155
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +0 -10
- package/src/tools/esbuild/stylesheets/sass-language.js +0 -185
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +0 -58
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +0 -282
- package/src/tools/esbuild/utils.d.ts +0 -41
- package/src/tools/esbuild/utils.js +0 -378
- package/src/tools/esbuild/virtual-module-plugin.d.ts +0 -33
- package/src/tools/esbuild/virtual-module-plugin.js +0 -43
- package/src/tools/esbuild/watcher.d.ts +0 -25
- package/src/tools/esbuild/watcher.js +0 -118
- package/src/tools/sass/lexer.d.ts +0 -18
- package/src/tools/sass/lexer.js +0 -161
- package/src/tools/sass/rebasing-importer.d.ts +0 -101
- package/src/tools/sass/rebasing-importer.js +0 -334
- package/src/tools/sass/sass-service.d.ts +0 -72
- package/src/tools/sass/sass-service.js +0 -213
- package/src/tools/sass/worker.d.ts +0 -8
- package/src/tools/sass/worker.js +0 -192
- package/src/tools/vite/angular-memory-plugin.d.ts +0 -24
- package/src/tools/vite/angular-memory-plugin.js +0 -268
- package/src/tools/vite/i18n-locale-plugin.d.ts +0 -18
- package/src/tools/vite/i18n-locale-plugin.js +0 -55
- package/src/typings.d.ts +0 -21
- package/src/utils/bundle-calculator.d.ts +0 -44
- package/src/utils/bundle-calculator.js +0 -303
- package/src/utils/check-port.d.ts +0 -8
- package/src/utils/check-port.js +0 -58
- package/src/utils/delete-output-dir.d.ts +0 -11
- package/src/utils/delete-output-dir.js +0 -46
- package/src/utils/format-bytes.d.ts +0 -8
- package/src/utils/format-bytes.js +0 -22
- package/src/utils/i18n-options.d.ts +0 -33
- package/src/utils/i18n-options.js +0 -161
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +0 -8
- package/src/utils/index-file/add-event-dispatch-contract.js +0 -28
- package/src/utils/index-file/augment-index-html.d.ts +0 -40
- package/src/utils/index-file/augment-index-html.js +0 -239
- package/src/utils/index-file/html-rewriting-stream.d.ts +0 -11
- package/src/utils/index-file/html-rewriting-stream.js +0 -28
- package/src/utils/index-file/index-html-generator.d.ts +0 -57
- package/src/utils/index-file/index-html-generator.js +0 -135
- package/src/utils/index-file/inline-critical-css.d.ts +0 -24
- package/src/utils/index-file/inline-critical-css.js +0 -179
- package/src/utils/index-file/inline-fonts.d.ts +0 -23
- package/src/utils/index-file/inline-fonts.js +0 -267
- package/src/utils/index-file/nonce.d.ts +0 -12
- package/src/utils/index-file/nonce.js +0 -55
- package/src/utils/load-proxy-config.d.ts +0 -8
- package/src/utils/load-proxy-config.js +0 -189
- package/src/utils/load-translations.d.ts +0 -16
- package/src/utils/load-translations.js +0 -84
- package/src/utils/postcss-configuration.d.ts +0 -17
- package/src/utils/postcss-configuration.js +0 -86
- package/src/utils/purge-cache.d.ts +0 -10
- package/src/utils/purge-cache.js +0 -40
- package/src/utils/resolve-assets.d.ts +0 -18
- package/src/utils/resolve-assets.js +0 -35
- package/src/utils/routes-extractor/extractor.d.ts +0 -15
- package/src/utils/routes-extractor/extractor.js +0 -97
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +0 -18
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -129
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +0 -8
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +0 -13
- package/src/utils/server-rendering/fetch-patch.d.ts +0 -8
- package/src/utils/server-rendering/fetch-patch.js +0 -66
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +0 -10
- package/src/utils/server-rendering/load-esm-from-memory.js +0 -26
- package/src/utils/server-rendering/main-bundle-exports.d.ts +0 -27
- package/src/utils/server-rendering/main-bundle-exports.js +0 -9
- package/src/utils/server-rendering/prerender.d.ts +0 -23
- package/src/utils/server-rendering/prerender.js +0 -192
- package/src/utils/server-rendering/render-page.d.ts +0 -26
- package/src/utils/server-rendering/render-page.js +0 -110
- package/src/utils/server-rendering/render-worker.d.ts +0 -22
- package/src/utils/server-rendering/render-worker.js +0 -30
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +0 -21
- package/src/utils/server-rendering/routes-extractor-worker.js +0 -53
- package/src/utils/service-worker.d.ts +0 -25
- package/src/utils/service-worker.js +0 -211
- package/src/utils/stats-table.d.ts +0 -20
- package/src/utils/stats-table.js +0 -205
- package/src/utils/supported-browsers.d.ts +0 -10
- package/src/utils/supported-browsers.js +0 -42
- package/src/utils/version.d.ts +0 -8
- package/src/utils/version.js +0 -59
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
-
};
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
|
|
37
|
-
const tslib = __importStar(require("tslib"));
|
|
38
|
-
/**
|
|
39
|
-
* A cached set of TypeScript helper function names used by the helper name matcher utility function.
|
|
40
|
-
*/
|
|
41
|
-
const tslibHelpers = new Set(Object.keys(tslib).filter((h) => h.startsWith('__')));
|
|
42
|
-
/**
|
|
43
|
-
* Determinates whether an identifier name matches one of the TypeScript helper function names.
|
|
44
|
-
*
|
|
45
|
-
* @param name The identifier name to check.
|
|
46
|
-
* @returns True, if the name matches a TypeScript helper name; otherwise, false.
|
|
47
|
-
*/
|
|
48
|
-
function isTslibHelperName(name) {
|
|
49
|
-
const nameParts = name.split('$');
|
|
50
|
-
const originalName = nameParts[0];
|
|
51
|
-
if (nameParts.length > 2 || (nameParts.length === 2 && isNaN(+nameParts[1]))) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return tslibHelpers.has(originalName);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
|
|
58
|
-
*
|
|
59
|
-
* @returns A babel plugin object instance.
|
|
60
|
-
*/
|
|
61
|
-
function default_1() {
|
|
62
|
-
return {
|
|
63
|
-
visitor: {
|
|
64
|
-
CallExpression(path) {
|
|
65
|
-
// If the expression has a function parent, it is not top-level
|
|
66
|
-
if (path.getFunctionParent()) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const callee = path.get('callee');
|
|
70
|
-
if ((callee.isFunctionExpression() || callee.isArrowFunctionExpression()) &&
|
|
71
|
-
path.node.arguments.length !== 0) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// Do not annotate TypeScript helpers emitted by the TypeScript compiler.
|
|
75
|
-
// TypeScript helpers are intended to cause side effects.
|
|
76
|
-
if (callee.isIdentifier() && isTslibHelperName(callee.node.name)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
(0, helper_annotate_as_pure_1.default)(path);
|
|
80
|
-
},
|
|
81
|
-
NewExpression(path) {
|
|
82
|
-
// If the expression has a function parent, it is not top-level
|
|
83
|
-
if (!path.getFunctionParent()) {
|
|
84
|
-
(0, helper_annotate_as_pure_1.default)(path);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
exports.default = default_1;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type ng from '@angular/compiler-cli';
|
|
9
|
-
import ts from 'typescript';
|
|
10
|
-
export type AngularCompilerOptions = ng.CompilerOptions;
|
|
11
|
-
export type AngularCompilerHost = ng.CompilerHost;
|
|
12
|
-
export interface AngularHostOptions {
|
|
13
|
-
fileReplacements?: Record<string, string>;
|
|
14
|
-
sourceFileCache?: Map<string, ts.SourceFile>;
|
|
15
|
-
modifiedFiles?: Set<string>;
|
|
16
|
-
transformStylesheet(data: string, containingFile: string, stylesheetFile?: string): Promise<string | null>;
|
|
17
|
-
processWebWorker(workerFile: string, containingFile: string): string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Patches in-place the `getSourceFiles` function on an instance of a TypeScript
|
|
21
|
-
* `Program` to ensure that all returned SourceFile instances have a `version`
|
|
22
|
-
* field. The `version` field is required when used with a TypeScript BuilderProgram.
|
|
23
|
-
* @param program The TypeScript Program instance to patch.
|
|
24
|
-
*/
|
|
25
|
-
export declare function ensureSourceFileVersions(program: ts.Program): void;
|
|
26
|
-
export declare function createAngularCompilerHost(compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions): AngularCompilerHost;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.createAngularCompilerHost = exports.ensureSourceFileVersions = void 0;
|
|
14
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
15
|
-
// Temporary deep import for host augmentation support.
|
|
16
|
-
// TODO: Move these to a private exports location or move the implementation into this package.
|
|
17
|
-
const { augmentHostWithCaching, augmentHostWithReplacements, augmentProgramWithVersioning, } = require('@ngtools/webpack/src/ivy/host');
|
|
18
|
-
/**
|
|
19
|
-
* Patches in-place the `getSourceFiles` function on an instance of a TypeScript
|
|
20
|
-
* `Program` to ensure that all returned SourceFile instances have a `version`
|
|
21
|
-
* field. The `version` field is required when used with a TypeScript BuilderProgram.
|
|
22
|
-
* @param program The TypeScript Program instance to patch.
|
|
23
|
-
*/
|
|
24
|
-
function ensureSourceFileVersions(program) {
|
|
25
|
-
augmentProgramWithVersioning(program);
|
|
26
|
-
}
|
|
27
|
-
exports.ensureSourceFileVersions = ensureSourceFileVersions;
|
|
28
|
-
function createAngularCompilerHost(compilerOptions, hostOptions) {
|
|
29
|
-
// Create TypeScript compiler host
|
|
30
|
-
const host = typescript_1.default.createIncrementalCompilerHost(compilerOptions);
|
|
31
|
-
// Set the parsing mode to the same as TS 5.3 default for tsc. This provides a parse
|
|
32
|
-
// performance improvement by skipping non-type related JSDoc parsing.
|
|
33
|
-
// NOTE: The check for this enum can be removed when TS 5.3 support is the minimum.
|
|
34
|
-
if (typescript_1.default.JSDocParsingMode) {
|
|
35
|
-
host.jsDocParsingMode = typescript_1.default.JSDocParsingMode.ParseForTypeErrors;
|
|
36
|
-
}
|
|
37
|
-
// The AOT compiler currently requires this hook to allow for a transformResource hook.
|
|
38
|
-
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.
|
|
39
|
-
host.readResource = async function (filename) {
|
|
40
|
-
return this.readFile(filename) ?? '';
|
|
41
|
-
};
|
|
42
|
-
// Add an AOT compiler resource transform hook
|
|
43
|
-
host.transformResource = async function (data, context) {
|
|
44
|
-
// Only style resources are transformed currently
|
|
45
|
-
if (context.type !== 'style') {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
// No transformation required if the resource is empty
|
|
49
|
-
if (data.trim().length === 0) {
|
|
50
|
-
return { content: '' };
|
|
51
|
-
}
|
|
52
|
-
const result = await hostOptions.transformStylesheet(data, context.containingFile, context.resourceFile ?? undefined);
|
|
53
|
-
return typeof result === 'string' ? { content: result } : null;
|
|
54
|
-
};
|
|
55
|
-
// Allow the AOT compiler to request the set of changed templates and styles
|
|
56
|
-
host.getModifiedResourceFiles = function () {
|
|
57
|
-
return hostOptions.modifiedFiles;
|
|
58
|
-
};
|
|
59
|
-
// Augment TypeScript Host for file replacements option
|
|
60
|
-
if (hostOptions.fileReplacements) {
|
|
61
|
-
// Provide a resolution cache since overriding resolution prevents automatic creation
|
|
62
|
-
const resolutionCache = typescript_1.default.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions);
|
|
63
|
-
host.getModuleResolutionCache = () => resolutionCache;
|
|
64
|
-
augmentHostWithReplacements(host, hostOptions.fileReplacements, resolutionCache);
|
|
65
|
-
}
|
|
66
|
-
// Augment TypeScript Host with source file caching if provided
|
|
67
|
-
if (hostOptions.sourceFileCache) {
|
|
68
|
-
augmentHostWithCaching(host, hostOptions.sourceFileCache);
|
|
69
|
-
}
|
|
70
|
-
return host;
|
|
71
|
-
}
|
|
72
|
-
exports.createAngularCompilerHost = createAngularCompilerHost;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type ng from '@angular/compiler-cli';
|
|
9
|
-
import type { PartialMessage } from 'esbuild';
|
|
10
|
-
import type ts from 'typescript';
|
|
11
|
-
import type { AngularHostOptions } from '../angular-host';
|
|
12
|
-
export interface EmitFileResult {
|
|
13
|
-
filename: string;
|
|
14
|
-
contents: string;
|
|
15
|
-
dependencies?: readonly string[];
|
|
16
|
-
}
|
|
17
|
-
export declare enum DiagnosticModes {
|
|
18
|
-
None = 0,
|
|
19
|
-
Option = 1,
|
|
20
|
-
Syntactic = 2,
|
|
21
|
-
Semantic = 4,
|
|
22
|
-
All = 7
|
|
23
|
-
}
|
|
24
|
-
export declare abstract class AngularCompilation {
|
|
25
|
-
#private;
|
|
26
|
-
static loadCompilerCli(): Promise<typeof ng>;
|
|
27
|
-
static loadTypescript(): Promise<typeof ts>;
|
|
28
|
-
protected loadConfiguration(tsconfig: string): Promise<ng.CompilerOptions>;
|
|
29
|
-
abstract initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions): Promise<{
|
|
30
|
-
affectedFiles: ReadonlySet<ts.SourceFile>;
|
|
31
|
-
compilerOptions: ng.CompilerOptions;
|
|
32
|
-
referencedFiles: readonly string[];
|
|
33
|
-
}>;
|
|
34
|
-
abstract emitAffectedFiles(): Iterable<EmitFileResult> | Promise<Iterable<EmitFileResult>>;
|
|
35
|
-
protected abstract collectDiagnostics(modes: DiagnosticModes): Iterable<ts.Diagnostic> | Promise<Iterable<ts.Diagnostic>>;
|
|
36
|
-
diagnoseFiles(modes?: DiagnosticModes): Promise<{
|
|
37
|
-
errors?: PartialMessage[];
|
|
38
|
-
warnings?: PartialMessage[];
|
|
39
|
-
}>;
|
|
40
|
-
update?(files: Set<string>): Promise<void>;
|
|
41
|
-
close?(): Promise<void>;
|
|
42
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.AngularCompilation = exports.DiagnosticModes = void 0;
|
|
34
|
-
const load_esm_1 = require("../../../../utils/load-esm");
|
|
35
|
-
const profiling_1 = require("../../profiling");
|
|
36
|
-
const diagnostics_1 = require("../diagnostics");
|
|
37
|
-
var DiagnosticModes;
|
|
38
|
-
(function (DiagnosticModes) {
|
|
39
|
-
DiagnosticModes[DiagnosticModes["None"] = 0] = "None";
|
|
40
|
-
DiagnosticModes[DiagnosticModes["Option"] = 1] = "Option";
|
|
41
|
-
DiagnosticModes[DiagnosticModes["Syntactic"] = 2] = "Syntactic";
|
|
42
|
-
DiagnosticModes[DiagnosticModes["Semantic"] = 4] = "Semantic";
|
|
43
|
-
DiagnosticModes[DiagnosticModes["All"] = 7] = "All";
|
|
44
|
-
})(DiagnosticModes || (exports.DiagnosticModes = DiagnosticModes = {}));
|
|
45
|
-
class AngularCompilation {
|
|
46
|
-
static #angularCompilerCliModule;
|
|
47
|
-
static #typescriptModule;
|
|
48
|
-
static async loadCompilerCli() {
|
|
49
|
-
// This uses a wrapped dynamic import to load `@angular/compiler-cli` which is ESM.
|
|
50
|
-
// Once TypeScript provides support for retaining dynamic imports this workaround can be dropped.
|
|
51
|
-
AngularCompilation.#angularCompilerCliModule ??=
|
|
52
|
-
await (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
|
|
53
|
-
return AngularCompilation.#angularCompilerCliModule;
|
|
54
|
-
}
|
|
55
|
-
static async loadTypescript() {
|
|
56
|
-
AngularCompilation.#typescriptModule ??= await Promise.resolve().then(() => __importStar(require('typescript')));
|
|
57
|
-
return AngularCompilation.#typescriptModule;
|
|
58
|
-
}
|
|
59
|
-
async loadConfiguration(tsconfig) {
|
|
60
|
-
const { readConfiguration } = await AngularCompilation.loadCompilerCli();
|
|
61
|
-
return (0, profiling_1.profileSync)('NG_READ_CONFIG', () => readConfiguration(tsconfig, {
|
|
62
|
-
// Angular specific configuration defaults and overrides to ensure a functioning compilation.
|
|
63
|
-
suppressOutputPathCheck: true,
|
|
64
|
-
outDir: undefined,
|
|
65
|
-
sourceMap: false,
|
|
66
|
-
declaration: false,
|
|
67
|
-
declarationMap: false,
|
|
68
|
-
allowEmptyCodegenFiles: false,
|
|
69
|
-
annotationsAs: 'decorators',
|
|
70
|
-
enableResourceInlining: false,
|
|
71
|
-
supportTestBed: false,
|
|
72
|
-
supportJitMode: false,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
async diagnoseFiles(modes = DiagnosticModes.All) {
|
|
76
|
-
const result = {};
|
|
77
|
-
// Avoid loading typescript until actually needed.
|
|
78
|
-
// This allows for avoiding the load of typescript in the main thread when using the parallel compilation.
|
|
79
|
-
const typescript = await AngularCompilation.loadTypescript();
|
|
80
|
-
await (0, profiling_1.profileAsync)('NG_DIAGNOSTICS_TOTAL', async () => {
|
|
81
|
-
for (const diagnostic of await this.collectDiagnostics(modes)) {
|
|
82
|
-
const message = (0, diagnostics_1.convertTypeScriptDiagnostic)(typescript, diagnostic);
|
|
83
|
-
if (diagnostic.category === typescript.DiagnosticCategory.Error) {
|
|
84
|
-
(result.errors ??= []).push(message);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
(result.warnings ??= []).push(message);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.AngularCompilation = AngularCompilation;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type ng from '@angular/compiler-cli';
|
|
9
|
-
import ts from 'typescript';
|
|
10
|
-
import { AngularHostOptions } from '../angular-host';
|
|
11
|
-
import { AngularCompilation, DiagnosticModes, EmitFileResult } from './angular-compilation';
|
|
12
|
-
export declare class AotCompilation extends AngularCompilation {
|
|
13
|
-
#private;
|
|
14
|
-
initialize(tsconfig: string, hostOptions: AngularHostOptions, compilerOptionsTransformer?: (compilerOptions: ng.CompilerOptions) => ng.CompilerOptions): Promise<{
|
|
15
|
-
affectedFiles: ReadonlySet<ts.SourceFile>;
|
|
16
|
-
compilerOptions: ng.CompilerOptions;
|
|
17
|
-
referencedFiles: readonly string[];
|
|
18
|
-
}>;
|
|
19
|
-
collectDiagnostics(modes: DiagnosticModes): Iterable<ts.Diagnostic>;
|
|
20
|
-
emitAffectedFiles(): Iterable<EmitFileResult>;
|
|
21
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.AotCompilation = void 0;
|
|
14
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
15
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
16
|
-
const profiling_1 = require("../../profiling");
|
|
17
|
-
const angular_host_1 = require("../angular-host");
|
|
18
|
-
const web_worker_transformer_1 = require("../web-worker-transformer");
|
|
19
|
-
const angular_compilation_1 = require("./angular-compilation");
|
|
20
|
-
// Temporary deep import for transformer support
|
|
21
|
-
// TODO: Move these to a private exports location or move the implementation into this package.
|
|
22
|
-
const { mergeTransformers, replaceBootstrap } = require('@ngtools/webpack/src/ivy/transformation');
|
|
23
|
-
class AngularCompilationState {
|
|
24
|
-
angularProgram;
|
|
25
|
-
compilerHost;
|
|
26
|
-
typeScriptProgram;
|
|
27
|
-
affectedFiles;
|
|
28
|
-
templateDiagnosticsOptimization;
|
|
29
|
-
webWorkerTransform;
|
|
30
|
-
diagnosticCache;
|
|
31
|
-
constructor(angularProgram, compilerHost, typeScriptProgram, affectedFiles, templateDiagnosticsOptimization, webWorkerTransform, diagnosticCache = new WeakMap()) {
|
|
32
|
-
this.angularProgram = angularProgram;
|
|
33
|
-
this.compilerHost = compilerHost;
|
|
34
|
-
this.typeScriptProgram = typeScriptProgram;
|
|
35
|
-
this.affectedFiles = affectedFiles;
|
|
36
|
-
this.templateDiagnosticsOptimization = templateDiagnosticsOptimization;
|
|
37
|
-
this.webWorkerTransform = webWorkerTransform;
|
|
38
|
-
this.diagnosticCache = diagnosticCache;
|
|
39
|
-
}
|
|
40
|
-
get angularCompiler() {
|
|
41
|
-
return this.angularProgram.compiler;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class AotCompilation extends angular_compilation_1.AngularCompilation {
|
|
45
|
-
#state;
|
|
46
|
-
async initialize(tsconfig, hostOptions, compilerOptionsTransformer) {
|
|
47
|
-
// Dynamically load the Angular compiler CLI package
|
|
48
|
-
const { NgtscProgram, OptimizeFor } = await angular_compilation_1.AngularCompilation.loadCompilerCli();
|
|
49
|
-
// Load the compiler configuration and transform as needed
|
|
50
|
-
const { options: originalCompilerOptions, rootNames, errors: configurationDiagnostics, } = await this.loadConfiguration(tsconfig);
|
|
51
|
-
const compilerOptions = compilerOptionsTransformer?.(originalCompilerOptions) ?? originalCompilerOptions;
|
|
52
|
-
// Create Angular compiler host
|
|
53
|
-
const host = (0, angular_host_1.createAngularCompilerHost)(compilerOptions, hostOptions);
|
|
54
|
-
// Create the Angular specific program that contains the Angular compiler
|
|
55
|
-
const angularProgram = (0, profiling_1.profileSync)('NG_CREATE_PROGRAM', () => new NgtscProgram(rootNames, compilerOptions, host, this.#state?.angularProgram));
|
|
56
|
-
const angularCompiler = angularProgram.compiler;
|
|
57
|
-
const angularTypeScriptProgram = angularProgram.getTsProgram();
|
|
58
|
-
(0, angular_host_1.ensureSourceFileVersions)(angularTypeScriptProgram);
|
|
59
|
-
let oldProgram = this.#state?.typeScriptProgram;
|
|
60
|
-
let usingBuildInfo = false;
|
|
61
|
-
if (!oldProgram) {
|
|
62
|
-
oldProgram = typescript_1.default.readBuilderProgram(compilerOptions, host);
|
|
63
|
-
usingBuildInfo = !!oldProgram;
|
|
64
|
-
}
|
|
65
|
-
const typeScriptProgram = typescript_1.default.createEmitAndSemanticDiagnosticsBuilderProgram(angularTypeScriptProgram, host, oldProgram, configurationDiagnostics);
|
|
66
|
-
await (0, profiling_1.profileAsync)('NG_ANALYZE_PROGRAM', () => angularCompiler.analyzeAsync());
|
|
67
|
-
const affectedFiles = (0, profiling_1.profileSync)('NG_FIND_AFFECTED', () => findAffectedFiles(typeScriptProgram, angularCompiler, usingBuildInfo));
|
|
68
|
-
// Get all files referenced in the TypeScript/Angular program including component resources
|
|
69
|
-
const referencedFiles = typeScriptProgram
|
|
70
|
-
.getSourceFiles()
|
|
71
|
-
.filter((sourceFile) => !angularCompiler.ignoreForEmit.has(sourceFile))
|
|
72
|
-
.flatMap((sourceFile) => {
|
|
73
|
-
const resourceDependencies = angularCompiler.getResourceDependencies(sourceFile);
|
|
74
|
-
// Also invalidate Angular diagnostics for a source file if component resources are modified
|
|
75
|
-
if (this.#state && hostOptions.modifiedFiles?.size) {
|
|
76
|
-
for (const resourceDependency of resourceDependencies) {
|
|
77
|
-
if (hostOptions.modifiedFiles.has(resourceDependency)) {
|
|
78
|
-
this.#state.diagnosticCache.delete(sourceFile);
|
|
79
|
-
// Also mark as affected in case changed template affects diagnostics
|
|
80
|
-
affectedFiles.add(sourceFile);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return [sourceFile.fileName, ...resourceDependencies];
|
|
85
|
-
});
|
|
86
|
-
this.#state = new AngularCompilationState(angularProgram, host, typeScriptProgram, affectedFiles, affectedFiles.size === 1 ? OptimizeFor.SingleFile : OptimizeFor.WholeProgram, (0, web_worker_transformer_1.createWorkerTransformer)(hostOptions.processWebWorker.bind(hostOptions)), this.#state?.diagnosticCache);
|
|
87
|
-
return { affectedFiles, compilerOptions, referencedFiles };
|
|
88
|
-
}
|
|
89
|
-
*collectDiagnostics(modes) {
|
|
90
|
-
(0, node_assert_1.default)(this.#state, 'Angular compilation must be initialized prior to collecting diagnostics.');
|
|
91
|
-
const { affectedFiles, angularCompiler, diagnosticCache, templateDiagnosticsOptimization, typeScriptProgram, } = this.#state;
|
|
92
|
-
const syntactic = modes & angular_compilation_1.DiagnosticModes.Syntactic;
|
|
93
|
-
const semantic = modes & angular_compilation_1.DiagnosticModes.Semantic;
|
|
94
|
-
// Collect program level diagnostics
|
|
95
|
-
if (modes & angular_compilation_1.DiagnosticModes.Option) {
|
|
96
|
-
yield* typeScriptProgram.getConfigFileParsingDiagnostics();
|
|
97
|
-
yield* angularCompiler.getOptionDiagnostics();
|
|
98
|
-
yield* typeScriptProgram.getOptionsDiagnostics();
|
|
99
|
-
}
|
|
100
|
-
if (syntactic) {
|
|
101
|
-
yield* typeScriptProgram.getGlobalDiagnostics();
|
|
102
|
-
}
|
|
103
|
-
// Collect source file specific diagnostics
|
|
104
|
-
for (const sourceFile of typeScriptProgram.getSourceFiles()) {
|
|
105
|
-
if (angularCompiler.ignoreForDiagnostics.has(sourceFile)) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
if (syntactic) {
|
|
109
|
-
// TypeScript will use cached diagnostics for files that have not been
|
|
110
|
-
// changed or affected for this build when using incremental building.
|
|
111
|
-
yield* (0, profiling_1.profileSync)('NG_DIAGNOSTICS_SYNTACTIC', () => typeScriptProgram.getSyntacticDiagnostics(sourceFile), true);
|
|
112
|
-
}
|
|
113
|
-
if (!semantic) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
yield* (0, profiling_1.profileSync)('NG_DIAGNOSTICS_SEMANTIC', () => typeScriptProgram.getSemanticDiagnostics(sourceFile), true);
|
|
117
|
-
// Declaration files cannot have template diagnostics
|
|
118
|
-
if (sourceFile.isDeclarationFile) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
// Only request Angular template diagnostics for affected files to avoid
|
|
122
|
-
// overhead of template diagnostics for unchanged files.
|
|
123
|
-
if (affectedFiles.has(sourceFile)) {
|
|
124
|
-
const angularDiagnostics = (0, profiling_1.profileSync)('NG_DIAGNOSTICS_TEMPLATE', () => angularCompiler.getDiagnosticsForFile(sourceFile, templateDiagnosticsOptimization), true);
|
|
125
|
-
diagnosticCache.set(sourceFile, angularDiagnostics);
|
|
126
|
-
yield* angularDiagnostics;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
const angularDiagnostics = diagnosticCache.get(sourceFile);
|
|
130
|
-
if (angularDiagnostics) {
|
|
131
|
-
yield* angularDiagnostics;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
emitAffectedFiles() {
|
|
137
|
-
(0, node_assert_1.default)(this.#state, 'Angular compilation must be initialized prior to emitting files.');
|
|
138
|
-
const { angularCompiler, compilerHost, typeScriptProgram, webWorkerTransform } = this.#state;
|
|
139
|
-
const buildInfoFilename = typeScriptProgram.getCompilerOptions().tsBuildInfoFile ?? '.tsbuildinfo';
|
|
140
|
-
const emittedFiles = new Map();
|
|
141
|
-
const writeFileCallback = (filename, contents, _a, _b, sourceFiles) => {
|
|
142
|
-
if (!sourceFiles?.length && filename.endsWith(buildInfoFilename)) {
|
|
143
|
-
// Save builder info contents to specified location
|
|
144
|
-
compilerHost.writeFile(filename, contents, false);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
(0, node_assert_1.default)(sourceFiles?.length === 1, 'Invalid TypeScript program emit for ' + filename);
|
|
148
|
-
const sourceFile = typescript_1.default.getOriginalNode(sourceFiles[0], typescript_1.default.isSourceFile);
|
|
149
|
-
if (angularCompiler.ignoreForEmit.has(sourceFile)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
angularCompiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
153
|
-
emittedFiles.set(sourceFile, { filename: sourceFile.fileName, contents });
|
|
154
|
-
};
|
|
155
|
-
const transformers = mergeTransformers(angularCompiler.prepareEmit().transformers, {
|
|
156
|
-
before: [
|
|
157
|
-
replaceBootstrap(() => typeScriptProgram.getProgram().getTypeChecker()),
|
|
158
|
-
webWorkerTransform,
|
|
159
|
-
],
|
|
160
|
-
});
|
|
161
|
-
// TypeScript will loop until there are no more affected files in the program
|
|
162
|
-
while (typeScriptProgram.emitNextAffectedFile(writeFileCallback, undefined, undefined, transformers)) {
|
|
163
|
-
/* empty */
|
|
164
|
-
}
|
|
165
|
-
// Angular may have files that must be emitted but TypeScript does not consider affected
|
|
166
|
-
for (const sourceFile of typeScriptProgram.getSourceFiles()) {
|
|
167
|
-
if (emittedFiles.has(sourceFile) || angularCompiler.ignoreForEmit.has(sourceFile)) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
if (sourceFile.isDeclarationFile) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
if (angularCompiler.incrementalCompilation.safeToSkipEmit(sourceFile)) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
typeScriptProgram.emit(sourceFile, writeFileCallback, undefined, undefined, transformers);
|
|
177
|
-
}
|
|
178
|
-
return emittedFiles.values();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.AotCompilation = AotCompilation;
|
|
182
|
-
function findAffectedFiles(builder, { ignoreForDiagnostics }, includeTTC) {
|
|
183
|
-
const affectedFiles = new Set();
|
|
184
|
-
// eslint-disable-next-line no-constant-condition
|
|
185
|
-
while (true) {
|
|
186
|
-
const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
187
|
-
// If the affected file is a TTC shim, add the shim's original source file.
|
|
188
|
-
// This ensures that changes that affect TTC are typechecked even when the changes
|
|
189
|
-
// are otherwise unrelated from a TS perspective and do not result in Ivy codegen changes.
|
|
190
|
-
// For example, changing @Input property types of a directive used in another component's
|
|
191
|
-
// template.
|
|
192
|
-
// A TTC shim is a file that has been ignored for diagnostics and has a filename ending in `.ngtypecheck.ts`.
|
|
193
|
-
if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {
|
|
194
|
-
// This file name conversion relies on internal compiler logic and should be converted
|
|
195
|
-
// to an official method when available. 15 is length of `.ngtypecheck.ts`
|
|
196
|
-
const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';
|
|
197
|
-
const originalSourceFile = builder.getSourceFile(originalFilename);
|
|
198
|
-
if (originalSourceFile) {
|
|
199
|
-
affectedFiles.add(originalSourceFile);
|
|
200
|
-
}
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
204
|
-
});
|
|
205
|
-
if (!result) {
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
affectedFiles.add(result.affected);
|
|
209
|
-
}
|
|
210
|
-
// Add all files with associated template type checking files.
|
|
211
|
-
// Stored TS build info does not have knowledge of the AOT compiler or the typechecking state of the templates.
|
|
212
|
-
// To ensure that errors are reported correctly, all AOT component diagnostics need to be analyzed even if build
|
|
213
|
-
// info is present.
|
|
214
|
-
if (includeTTC) {
|
|
215
|
-
for (const sourceFile of builder.getSourceFiles()) {
|
|
216
|
-
if (ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith('.ngtypecheck.ts')) {
|
|
217
|
-
// This file name conversion relies on internal compiler logic and should be converted
|
|
218
|
-
// to an official method when available. 15 is length of `.ngtypecheck.ts`
|
|
219
|
-
const originalFilename = sourceFile.fileName.slice(0, -15) + '.ts';
|
|
220
|
-
const originalSourceFile = builder.getSourceFile(originalFilename);
|
|
221
|
-
if (originalSourceFile) {
|
|
222
|
-
affectedFiles.add(originalSourceFile);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return affectedFiles;
|
|
228
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import type { AngularCompilation } from './angular-compilation';
|
|
9
|
-
/**
|
|
10
|
-
* Creates an Angular compilation object that can be used to perform Angular application
|
|
11
|
-
* compilation either for AOT or JIT mode. By default a parallel compilation is created
|
|
12
|
-
* that uses a Node.js worker thread.
|
|
13
|
-
* @param jit True, for Angular JIT compilation; False, for Angular AOT compilation.
|
|
14
|
-
* @returns An instance of an Angular compilation object.
|
|
15
|
-
*/
|
|
16
|
-
export declare function createAngularCompilation(jit: boolean): Promise<AngularCompilation>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
-
if (mod && mod.__esModule) return mod;
|
|
27
|
-
var result = {};
|
|
28
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
-
__setModuleDefault(result, mod);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.createAngularCompilation = void 0;
|
|
34
|
-
const environment_options_1 = require("../../../../utils/environment-options");
|
|
35
|
-
/**
|
|
36
|
-
* Creates an Angular compilation object that can be used to perform Angular application
|
|
37
|
-
* compilation either for AOT or JIT mode. By default a parallel compilation is created
|
|
38
|
-
* that uses a Node.js worker thread.
|
|
39
|
-
* @param jit True, for Angular JIT compilation; False, for Angular AOT compilation.
|
|
40
|
-
* @returns An instance of an Angular compilation object.
|
|
41
|
-
*/
|
|
42
|
-
async function createAngularCompilation(jit) {
|
|
43
|
-
if (environment_options_1.useParallelTs) {
|
|
44
|
-
const { ParallelCompilation } = await Promise.resolve().then(() => __importStar(require('./parallel-compilation')));
|
|
45
|
-
return new ParallelCompilation(jit);
|
|
46
|
-
}
|
|
47
|
-
if (jit) {
|
|
48
|
-
const { JitCompilation } = await Promise.resolve().then(() => __importStar(require('./jit-compilation')));
|
|
49
|
-
return new JitCompilation();
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const { AotCompilation } = await Promise.resolve().then(() => __importStar(require('./aot-compilation')));
|
|
53
|
-
return new AotCompilation();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.createAngularCompilation = createAngularCompilation;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
export { AngularCompilation, DiagnosticModes } from './angular-compilation';
|
|
9
|
-
export { createAngularCompilation } from './factory';
|
|
10
|
-
export { NoopCompilation } from './noop-compilation';
|