@angular/build 18.0.0-next.3
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/LICENSE +21 -0
- package/README.md +5 -0
- package/builders.json +14 -0
- package/package.json +87 -0
- package/src/builders/application/build-action.d.ts +33 -0
- package/src/builders/application/build-action.js +183 -0
- package/src/builders/application/execute-build.d.ts +11 -0
- package/src/builders/application/execute-build.js +125 -0
- package/src/builders/application/execute-post-bundle.d.ts +25 -0
- package/src/builders/application/execute-post-bundle.js +93 -0
- package/src/builders/application/i18n.d.ts +29 -0
- package/src/builders/application/i18n.js +128 -0
- package/src/builders/application/index.d.ts +57 -0
- package/src/builders/application/index.js +121 -0
- package/src/builders/application/options.d.ts +149 -0
- package/src/builders/application/options.js +369 -0
- package/src/builders/application/schema.d.ts +512 -0
- package/src/builders/application/schema.js +58 -0
- package/src/builders/application/schema.json +635 -0
- package/src/builders/application/setup-bundling.d.ts +19 -0
- package/src/builders/application/setup-bundling.js +71 -0
- package/src/builders/dev-server/builder.d.ts +32 -0
- package/src/builders/dev-server/builder.js +70 -0
- package/src/builders/dev-server/index.d.ts +14 -0
- package/src/builders/dev-server/index.js +15 -0
- package/src/builders/dev-server/internal.d.ts +19 -0
- package/src/builders/dev-server/internal.js +29 -0
- package/src/builders/dev-server/options.d.ts +47 -0
- package/src/builders/dev-server/options.js +65 -0
- package/src/builders/dev-server/output.d.ts +16 -0
- package/src/builders/dev-server/output.js +9 -0
- package/src/builders/dev-server/schema.d.ts +118 -0
- package/src/builders/dev-server/schema.js +4 -0
- package/src/builders/dev-server/schema.json +131 -0
- package/src/builders/dev-server/vite-server.d.ts +31 -0
- package/src/builders/dev-server/vite-server.js +504 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +16 -0
- package/src/private.d.ts +35 -0
- package/src/private.js +70 -0
- package/src/tools/babel/plugins/adjust-static-class-members.d.ts +26 -0
- package/src/tools/babel/plugins/adjust-static-class-members.js +351 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +22 -0
- package/src/tools/babel/plugins/adjust-typescript-enums.js +113 -0
- package/src/tools/babel/plugins/elide-angular-metadata.d.ts +22 -0
- package/src/tools/babel/plugins/elide-angular-metadata.js +110 -0
- package/src/tools/babel/plugins/index.d.ts +11 -0
- package/src/tools/babel/plugins/index.js +21 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +15 -0
- package/src/tools/babel/plugins/pure-toplevel-functions.js +90 -0
- package/src/tools/babel/typings.d.ts +21 -0
- package/src/tools/esbuild/angular/angular-host.d.ts +26 -0
- package/src/tools/esbuild/angular/angular-host.js +134 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/angular-compilation.js +94 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/aot-compilation.js +224 -0
- package/src/tools/esbuild/angular/compilation/factory.d.ts +16 -0
- package/src/tools/esbuild/angular/compilation/factory.js +56 -0
- package/src/tools/esbuild/angular/compilation/index.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/index.js +17 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.d.ts +10 -0
- package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +182 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.d.ts +21 -0
- package/src/tools/esbuild/angular/compilation/jit-compilation.js +106 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.d.ts +20 -0
- package/src/tools/esbuild/angular/compilation/noop-compilation.js +26 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.d.ts +42 -0
- package/src/tools/esbuild/angular/compilation/parallel-compilation.js +123 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +33 -0
- package/src/tools/esbuild/angular/compilation/parallel-worker.js +90 -0
- package/src/tools/esbuild/angular/compilation-state.d.ts +15 -0
- package/src/tools/esbuild/angular/compilation-state.js +44 -0
- package/src/tools/esbuild/angular/compiler-plugin.d.ts +27 -0
- package/src/tools/esbuild/angular/compiler-plugin.js +441 -0
- package/src/tools/esbuild/angular/component-stylesheets.d.ts +44 -0
- package/src/tools/esbuild/angular/component-stylesheets.js +150 -0
- package/src/tools/esbuild/angular/diagnostics.d.ts +15 -0
- package/src/tools/esbuild/angular/diagnostics.js +69 -0
- package/src/tools/esbuild/angular/file-reference-tracker.d.ts +17 -0
- package/src/tools/esbuild/angular/file-reference-tracker.js +57 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +23 -0
- package/src/tools/esbuild/angular/jit-plugin-callbacks.js +117 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/jit-resource-transformer.js +186 -0
- package/src/tools/esbuild/angular/source-file-cache.d.ts +18 -0
- package/src/tools/esbuild/angular/source-file-cache.js +65 -0
- package/src/tools/esbuild/angular/uri.d.ts +54 -0
- package/src/tools/esbuild/angular/uri.js +74 -0
- package/src/tools/esbuild/angular/web-worker-transformer.d.ts +17 -0
- package/src/tools/esbuild/angular/web-worker-transformer.js +94 -0
- package/src/tools/esbuild/application-code-bundle.d.ts +20 -0
- package/src/tools/esbuild/application-code-bundle.js +368 -0
- package/src/tools/esbuild/budget-stats.d.ts +19 -0
- package/src/tools/esbuild/budget-stats.js +59 -0
- package/src/tools/esbuild/bundler-context.d.ts +75 -0
- package/src/tools/esbuild/bundler-context.js +366 -0
- package/src/tools/esbuild/bundler-execution-result.d.ts +71 -0
- package/src/tools/esbuild/bundler-execution-result.js +131 -0
- package/src/tools/esbuild/cache.d.ts +88 -0
- package/src/tools/esbuild/cache.js +92 -0
- package/src/tools/esbuild/commonjs-checker.d.ts +28 -0
- package/src/tools/esbuild/commonjs-checker.js +151 -0
- package/src/tools/esbuild/compiler-plugin-options.d.ts +16 -0
- package/src/tools/esbuild/compiler-plugin-options.js +49 -0
- package/src/tools/esbuild/external-packages-plugin.d.ts +18 -0
- package/src/tools/esbuild/external-packages-plugin.js +70 -0
- package/src/tools/esbuild/global-scripts.d.ts +16 -0
- package/src/tools/esbuild/global-scripts.js +142 -0
- package/src/tools/esbuild/global-styles.d.ts +10 -0
- package/src/tools/esbuild/global-styles.js +74 -0
- package/src/tools/esbuild/i18n-inliner-worker.d.ts +42 -0
- package/src/tools/esbuild/i18n-inliner-worker.js +136 -0
- package/src/tools/esbuild/i18n-inliner.d.ts +44 -0
- package/src/tools/esbuild/i18n-inliner.js +150 -0
- package/src/tools/esbuild/i18n-locale-plugin.d.ts +22 -0
- package/src/tools/esbuild/i18n-locale-plugin.js +120 -0
- package/src/tools/esbuild/index-html-generator.d.ts +15 -0
- package/src/tools/esbuild/index-html-generator.js +81 -0
- package/src/tools/esbuild/javascript-transformer-worker.d.ts +19 -0
- package/src/tools/esbuild/javascript-transformer-worker.js +154 -0
- package/src/tools/esbuild/javascript-transformer.d.ts +54 -0
- package/src/tools/esbuild/javascript-transformer.js +147 -0
- package/src/tools/esbuild/license-extractor.d.ts +25 -0
- package/src/tools/esbuild/license-extractor.js +158 -0
- package/src/tools/esbuild/load-result-cache.d.ts +21 -0
- package/src/tools/esbuild/load-result-cache.js +75 -0
- package/src/tools/esbuild/profiling.d.ts +11 -0
- package/src/tools/esbuild/profiling.js +78 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.d.ts +18 -0
- package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +44 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.d.ts +17 -0
- package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +73 -0
- package/src/tools/esbuild/stylesheets/bundle-options.d.ts +35 -0
- package/src/tools/esbuild/stylesheets/bundle-options.js +64 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
- package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
- package/src/tools/esbuild/stylesheets/css-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/css-language.js +15 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.d.ts +18 -0
- package/src/tools/esbuild/stylesheets/css-resource-plugin.js +114 -0
- package/src/tools/esbuild/stylesheets/less-language.d.ts +9 -0
- package/src/tools/esbuild/stylesheets/less-language.js +155 -0
- package/src/tools/esbuild/stylesheets/sass-language.d.ts +10 -0
- package/src/tools/esbuild/stylesheets/sass-language.js +185 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.d.ts +58 -0
- package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +282 -0
- package/src/tools/esbuild/utils.d.ts +49 -0
- package/src/tools/esbuild/utils.js +392 -0
- package/src/tools/esbuild/virtual-module-plugin.d.ts +33 -0
- package/src/tools/esbuild/virtual-module-plugin.js +43 -0
- package/src/tools/esbuild/watcher.d.ts +25 -0
- package/src/tools/esbuild/watcher.js +118 -0
- package/src/tools/sass/lexer.d.ts +18 -0
- package/src/tools/sass/lexer.js +161 -0
- package/src/tools/sass/rebasing-importer.d.ts +101 -0
- package/src/tools/sass/rebasing-importer.js +334 -0
- package/src/tools/sass/sass-service.d.ts +72 -0
- package/src/tools/sass/sass-service.js +213 -0
- package/src/tools/sass/worker.d.ts +8 -0
- package/src/tools/sass/worker.js +192 -0
- package/src/tools/vite/angular-memory-plugin.d.ts +24 -0
- package/src/tools/vite/angular-memory-plugin.js +268 -0
- package/src/tools/vite/i18n-locale-plugin.d.ts +18 -0
- package/src/tools/vite/i18n-locale-plugin.js +55 -0
- package/src/utils/bundle-calculator.d.ts +44 -0
- package/src/utils/bundle-calculator.js +303 -0
- package/src/utils/check-port.d.ts +8 -0
- package/src/utils/check-port.js +58 -0
- package/src/utils/color.d.ts +10 -0
- package/src/utils/color.js +63 -0
- package/src/utils/delete-output-dir.d.ts +11 -0
- package/src/utils/delete-output-dir.js +46 -0
- package/src/utils/environment-options.d.ts +16 -0
- package/src/utils/environment-options.js +79 -0
- package/src/utils/error.d.ts +10 -0
- package/src/utils/error.js +21 -0
- package/src/utils/format-bytes.d.ts +8 -0
- package/src/utils/format-bytes.js +22 -0
- package/src/utils/i18n-options.d.ts +33 -0
- package/src/utils/i18n-options.js +161 -0
- package/src/utils/index-file/add-event-dispatch-contract.d.ts +8 -0
- package/src/utils/index-file/add-event-dispatch-contract.js +28 -0
- package/src/utils/index-file/augment-index-html.d.ts +40 -0
- package/src/utils/index-file/augment-index-html.js +239 -0
- package/src/utils/index-file/html-rewriting-stream.d.ts +11 -0
- package/src/utils/index-file/html-rewriting-stream.js +28 -0
- package/src/utils/index-file/index-html-generator.d.ts +57 -0
- package/src/utils/index-file/index-html-generator.js +135 -0
- package/src/utils/index-file/inline-critical-css.d.ts +24 -0
- package/src/utils/index-file/inline-critical-css.js +179 -0
- package/src/utils/index-file/inline-fonts.d.ts +23 -0
- package/src/utils/index-file/inline-fonts.js +267 -0
- package/src/utils/index-file/nonce.d.ts +12 -0
- package/src/utils/index-file/nonce.js +55 -0
- package/src/utils/index-file/style-nonce.d.ts +12 -0
- package/src/utils/index-file/style-nonce.js +55 -0
- package/src/utils/index.d.ts +11 -0
- package/src/utils/index.js +27 -0
- package/src/utils/load-esm.d.ts +20 -0
- package/src/utils/load-esm.js +31 -0
- package/src/utils/load-proxy-config.d.ts +8 -0
- package/src/utils/load-proxy-config.js +189 -0
- package/src/utils/load-translations.d.ts +16 -0
- package/src/utils/load-translations.js +84 -0
- package/src/utils/normalize-asset-patterns.d.ts +14 -0
- package/src/utils/normalize-asset-patterns.js +96 -0
- package/src/utils/normalize-cache.d.ts +16 -0
- package/src/utils/normalize-cache.js +44 -0
- package/src/utils/normalize-optimization.d.ts +13 -0
- package/src/utils/normalize-optimization.js +42 -0
- package/src/utils/normalize-source-maps.d.ts +9 -0
- package/src/utils/normalize-source-maps.js +23 -0
- package/src/utils/postcss-configuration.d.ts +17 -0
- package/src/utils/postcss-configuration.js +86 -0
- package/src/utils/purge-cache.d.ts +10 -0
- package/src/utils/purge-cache.js +40 -0
- package/src/utils/resolve-assets.d.ts +18 -0
- package/src/utils/resolve-assets.js +35 -0
- package/src/utils/routes-extractor/extractor.d.ts +15 -0
- package/src/utils/routes-extractor/extractor.js +97 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.d.ts +18 -0
- package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +129 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.d.ts +8 -0
- package/src/utils/server-rendering/esm-in-memory-loader/register-hooks.js +13 -0
- package/src/utils/server-rendering/fetch-patch.d.ts +8 -0
- package/src/utils/server-rendering/fetch-patch.js +66 -0
- package/src/utils/server-rendering/load-esm-from-memory.d.ts +10 -0
- package/src/utils/server-rendering/load-esm-from-memory.js +26 -0
- package/src/utils/server-rendering/main-bundle-exports.d.ts +27 -0
- package/src/utils/server-rendering/main-bundle-exports.js +9 -0
- package/src/utils/server-rendering/prerender.d.ts +23 -0
- package/src/utils/server-rendering/prerender.js +192 -0
- package/src/utils/server-rendering/render-page.d.ts +26 -0
- package/src/utils/server-rendering/render-page.js +110 -0
- package/src/utils/server-rendering/render-worker.d.ts +22 -0
- package/src/utils/server-rendering/render-worker.js +30 -0
- package/src/utils/server-rendering/routes-extractor-worker.d.ts +21 -0
- package/src/utils/server-rendering/routes-extractor-worker.js +53 -0
- package/src/utils/service-worker.d.ts +25 -0
- package/src/utils/service-worker.js +211 -0
- package/src/utils/spinner.d.ts +20 -0
- package/src/utils/spinner.js +55 -0
- package/src/utils/stats-table.d.ts +20 -0
- package/src/utils/stats-table.js +205 -0
- package/src/utils/supported-browsers.d.ts +10 -0
- package/src/utils/supported-browsers.js +42 -0
- package/src/utils/tty.d.ts +8 -0
- package/src/utils/tty.js +23 -0
- package/src/utils/url.d.ts +8 -0
- package/src/utils/url.js +18 -0
- package/src/utils/version.d.ts +8 -0
- package/src/utils/version.js +59 -0
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.getKeywords = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the Angular class metadata function created by the Angular compiler.
|
|
13
|
+
*/
|
|
14
|
+
const SET_CLASS_METADATA_NAME = 'ɵsetClassMetadata';
|
|
15
|
+
/**
|
|
16
|
+
* Name of the asynchronous Angular class metadata function created by the Angular compiler.
|
|
17
|
+
*/
|
|
18
|
+
const SET_CLASS_METADATA_ASYNC_NAME = 'ɵsetClassMetadataAsync';
|
|
19
|
+
/**
|
|
20
|
+
* Name of the function that sets debug information on classes.
|
|
21
|
+
*/
|
|
22
|
+
const SET_CLASS_DEBUG_INFO_NAME = 'ɵsetClassDebugInfo';
|
|
23
|
+
/**
|
|
24
|
+
* Provides one or more keywords that if found within the content of a source file indicate
|
|
25
|
+
* that this plugin should be used with a source file.
|
|
26
|
+
*
|
|
27
|
+
* @returns An a string iterable containing one or more keywords.
|
|
28
|
+
*/
|
|
29
|
+
function getKeywords() {
|
|
30
|
+
return Object.keys(angularMetadataFunctions);
|
|
31
|
+
}
|
|
32
|
+
exports.getKeywords = getKeywords;
|
|
33
|
+
/**
|
|
34
|
+
* An object map of function names and related value checks for discovery of Angular generated
|
|
35
|
+
* metadata calls.
|
|
36
|
+
*/
|
|
37
|
+
const angularMetadataFunctions = {
|
|
38
|
+
[SET_CLASS_METADATA_NAME]: isSetClassMetadataCall,
|
|
39
|
+
[SET_CLASS_METADATA_ASYNC_NAME]: isSetClassMetadataAsyncCall,
|
|
40
|
+
[SET_CLASS_DEBUG_INFO_NAME]: isSetClassDebugInfoCall,
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A babel plugin factory function for eliding the Angular class metadata function (`ɵsetClassMetadata`).
|
|
44
|
+
*
|
|
45
|
+
* @returns A babel plugin object instance.
|
|
46
|
+
*/
|
|
47
|
+
function default_1() {
|
|
48
|
+
return {
|
|
49
|
+
visitor: {
|
|
50
|
+
CallExpression(path) {
|
|
51
|
+
const callee = path.get('callee');
|
|
52
|
+
// The function being called must be the metadata function name
|
|
53
|
+
let calleeName;
|
|
54
|
+
if (callee.isMemberExpression()) {
|
|
55
|
+
const calleeProperty = callee.get('property');
|
|
56
|
+
if (calleeProperty.isIdentifier()) {
|
|
57
|
+
calleeName = calleeProperty.node.name;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (callee.isIdentifier()) {
|
|
61
|
+
calleeName = callee.node.name;
|
|
62
|
+
}
|
|
63
|
+
if (!calleeName) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (Object.hasOwn(angularMetadataFunctions, calleeName) &&
|
|
67
|
+
angularMetadataFunctions[calleeName](path.get('arguments'))) {
|
|
68
|
+
// The metadata function is always emitted inside a function expression
|
|
69
|
+
const parent = path.getFunctionParent();
|
|
70
|
+
if (parent && (parent.isFunctionExpression() || parent.isArrowFunctionExpression())) {
|
|
71
|
+
// Replace the metadata function with `void 0` which is the equivalent return value
|
|
72
|
+
// of the metadata function.
|
|
73
|
+
path.replaceWith(path.scope.buildUndefinedNode());
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
exports.default = default_1;
|
|
81
|
+
/** Determines if a function call is a call to `setClassMetadata`. */
|
|
82
|
+
function isSetClassMetadataCall(callArguments) {
|
|
83
|
+
// `setClassMetadata` calls have to meet the following criteria:
|
|
84
|
+
// * First must be an identifier
|
|
85
|
+
// * Second must be an array literal
|
|
86
|
+
return (callArguments.length === 4 &&
|
|
87
|
+
callArguments[0].isIdentifier() &&
|
|
88
|
+
callArguments[1].isArrayExpression());
|
|
89
|
+
}
|
|
90
|
+
/** Determines if a function call is a call to `setClassMetadataAsync`. */
|
|
91
|
+
function isSetClassMetadataAsyncCall(callArguments) {
|
|
92
|
+
// `setClassMetadataAsync` calls have to meet the following criteria:
|
|
93
|
+
// * First argument must be an identifier.
|
|
94
|
+
// * Second argument must be an inline function.
|
|
95
|
+
// * Third argument must be an inline function.
|
|
96
|
+
return (callArguments.length === 3 &&
|
|
97
|
+
callArguments[0].isIdentifier() &&
|
|
98
|
+
isInlineFunction(callArguments[1]) &&
|
|
99
|
+
isInlineFunction(callArguments[2]));
|
|
100
|
+
}
|
|
101
|
+
/** Determines if a function call is a call to `setClassDebugInfo`. */
|
|
102
|
+
function isSetClassDebugInfoCall(callArguments) {
|
|
103
|
+
return (callArguments.length === 2 &&
|
|
104
|
+
callArguments[0].isIdentifier() &&
|
|
105
|
+
callArguments[1].isObjectExpression());
|
|
106
|
+
}
|
|
107
|
+
/** Determines if a node is an inline function expression. */
|
|
108
|
+
function isInlineFunction(path) {
|
|
109
|
+
return path.isFunctionExpression() || path.isArrowFunctionExpression();
|
|
110
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { default as adjustStaticMembers } from './adjust-static-class-members';
|
|
9
|
+
export { default as adjustTypeScriptEnums } from './adjust-typescript-enums';
|
|
10
|
+
export { default as elideAngularMetadata } from './elide-angular-metadata';
|
|
11
|
+
export { default as markTopLevelPure } from './pure-toplevel-functions';
|
|
@@ -0,0 +1,21 @@
|
|
|
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.markTopLevelPure = exports.elideAngularMetadata = exports.adjustTypeScriptEnums = exports.adjustStaticMembers = void 0;
|
|
14
|
+
var adjust_static_class_members_1 = require("./adjust-static-class-members");
|
|
15
|
+
Object.defineProperty(exports, "adjustStaticMembers", { enumerable: true, get: function () { return __importDefault(adjust_static_class_members_1).default; } });
|
|
16
|
+
var adjust_typescript_enums_1 = require("./adjust-typescript-enums");
|
|
17
|
+
Object.defineProperty(exports, "adjustTypeScriptEnums", { enumerable: true, get: function () { return __importDefault(adjust_typescript_enums_1).default; } });
|
|
18
|
+
var elide_angular_metadata_1 = require("./elide-angular-metadata");
|
|
19
|
+
Object.defineProperty(exports, "elideAngularMetadata", { enumerable: true, get: function () { return __importDefault(elide_angular_metadata_1).default; } });
|
|
20
|
+
var pure_toplevel_functions_1 = require("./pure-toplevel-functions");
|
|
21
|
+
Object.defineProperty(exports, "markTopLevelPure", { enumerable: true, get: function () { return __importDefault(pure_toplevel_functions_1).default; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/// <reference types="@angular/compiler-cli/private/babel" />
|
|
9
|
+
import type { PluginObj } from '@babel/core';
|
|
10
|
+
/**
|
|
11
|
+
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
|
|
12
|
+
*
|
|
13
|
+
* @returns A babel plugin object instance.
|
|
14
|
+
*/
|
|
15
|
+
export default function (): PluginObj;
|
|
@@ -0,0 +1,90 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
|
|
9
|
+
declare module '@babel/helper-annotate-as-pure' {
|
|
10
|
+
export default function annotateAsPure(
|
|
11
|
+
pathOrNode: import('@babel/types').Node | { node: import('@babel/types').Node },
|
|
12
|
+
): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module '@babel/helper-split-export-declaration' {
|
|
16
|
+
export default function splitExportDeclaration(
|
|
17
|
+
exportDeclaration: import('@babel/core').NodePath<
|
|
18
|
+
import('@babel/types').ExportDefaultDeclaration
|
|
19
|
+
>,
|
|
20
|
+
): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 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(typescript: typeof ts, compilerOptions: AngularCompilerOptions, hostOptions: AngularHostOptions): AngularCompilerHost;
|
|
@@ -0,0 +1,134 @@
|
|
|
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 node_crypto_1 = require("node:crypto");
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
/**
|
|
17
|
+
* Patches in-place the `getSourceFiles` function on an instance of a TypeScript
|
|
18
|
+
* `Program` to ensure that all returned SourceFile instances have a `version`
|
|
19
|
+
* field. The `version` field is required when used with a TypeScript BuilderProgram.
|
|
20
|
+
* @param program The TypeScript Program instance to patch.
|
|
21
|
+
*/
|
|
22
|
+
function ensureSourceFileVersions(program) {
|
|
23
|
+
const baseGetSourceFiles = program.getSourceFiles;
|
|
24
|
+
// TODO: Update Angular compiler to add versions to all internal files and remove this
|
|
25
|
+
program.getSourceFiles = function (...parameters) {
|
|
26
|
+
const files = baseGetSourceFiles(...parameters);
|
|
27
|
+
for (const file of files) {
|
|
28
|
+
if (file.version === undefined) {
|
|
29
|
+
file.version = (0, node_crypto_1.createHash)('sha256').update(file.text).digest('hex');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return files;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.ensureSourceFileVersions = ensureSourceFileVersions;
|
|
36
|
+
function augmentHostWithCaching(host, cache) {
|
|
37
|
+
const baseGetSourceFile = host.getSourceFile;
|
|
38
|
+
host.getSourceFile = function (fileName, languageVersion, onError, shouldCreateNewSourceFile, ...parameters) {
|
|
39
|
+
if (!shouldCreateNewSourceFile && cache.has(fileName)) {
|
|
40
|
+
return cache.get(fileName);
|
|
41
|
+
}
|
|
42
|
+
const file = baseGetSourceFile.call(host, fileName, languageVersion, onError, true, ...parameters);
|
|
43
|
+
if (file) {
|
|
44
|
+
cache.set(fileName, file);
|
|
45
|
+
}
|
|
46
|
+
return file;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function augmentResolveModuleNames(typescript, host, resolvedModuleModifier, moduleResolutionCache) {
|
|
50
|
+
if (host.resolveModuleNames) {
|
|
51
|
+
const baseResolveModuleNames = host.resolveModuleNames;
|
|
52
|
+
host.resolveModuleNames = function (moduleNames, ...parameters) {
|
|
53
|
+
return moduleNames.map((name) => {
|
|
54
|
+
const result = baseResolveModuleNames.call(host, [name], ...parameters);
|
|
55
|
+
return resolvedModuleModifier(result[0], name);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
host.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, options) {
|
|
61
|
+
return moduleNames.map((name) => {
|
|
62
|
+
const result = typescript.resolveModuleName(name, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule;
|
|
63
|
+
return resolvedModuleModifier(result, name);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function normalizePath(path) {
|
|
69
|
+
return node_path_1.default.win32.normalize(path).replace(/\\/g, node_path_1.default.posix.sep);
|
|
70
|
+
}
|
|
71
|
+
function augmentHostWithReplacements(typescript, host, replacements, moduleResolutionCache) {
|
|
72
|
+
if (Object.keys(replacements).length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const normalizedReplacements = {};
|
|
76
|
+
for (const [key, value] of Object.entries(replacements)) {
|
|
77
|
+
normalizedReplacements[normalizePath(key)] = normalizePath(value);
|
|
78
|
+
}
|
|
79
|
+
const tryReplace = (resolvedModule) => {
|
|
80
|
+
const replacement = resolvedModule && normalizedReplacements[resolvedModule.resolvedFileName];
|
|
81
|
+
if (replacement) {
|
|
82
|
+
return {
|
|
83
|
+
resolvedFileName: replacement,
|
|
84
|
+
isExternalLibraryImport: /[/\\]node_modules[/\\]/.test(replacement),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
return resolvedModule;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
augmentResolveModuleNames(typescript, host, tryReplace, moduleResolutionCache);
|
|
92
|
+
}
|
|
93
|
+
function createAngularCompilerHost(typescript, compilerOptions, hostOptions) {
|
|
94
|
+
// Create TypeScript compiler host
|
|
95
|
+
const host = typescript.createIncrementalCompilerHost(compilerOptions);
|
|
96
|
+
// Set the parsing mode to the same as TS 5.3+ default for tsc. This provides a parse
|
|
97
|
+
// performance improvement by skipping non-type related JSDoc parsing.
|
|
98
|
+
host.jsDocParsingMode = typescript.JSDocParsingMode.ParseForTypeErrors;
|
|
99
|
+
// The AOT compiler currently requires this hook to allow for a transformResource hook.
|
|
100
|
+
// Once the AOT compiler allows only a transformResource hook, this can be reevaluated.
|
|
101
|
+
host.readResource = async function (filename) {
|
|
102
|
+
return this.readFile(filename) ?? '';
|
|
103
|
+
};
|
|
104
|
+
// Add an AOT compiler resource transform hook
|
|
105
|
+
host.transformResource = async function (data, context) {
|
|
106
|
+
// Only style resources are transformed currently
|
|
107
|
+
if (context.type !== 'style') {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
// No transformation required if the resource is empty
|
|
111
|
+
if (data.trim().length === 0) {
|
|
112
|
+
return { content: '' };
|
|
113
|
+
}
|
|
114
|
+
const result = await hostOptions.transformStylesheet(data, context.containingFile, context.resourceFile ?? undefined);
|
|
115
|
+
return typeof result === 'string' ? { content: result } : null;
|
|
116
|
+
};
|
|
117
|
+
// Allow the AOT compiler to request the set of changed templates and styles
|
|
118
|
+
host.getModifiedResourceFiles = function () {
|
|
119
|
+
return hostOptions.modifiedFiles;
|
|
120
|
+
};
|
|
121
|
+
// Augment TypeScript Host for file replacements option
|
|
122
|
+
if (hostOptions.fileReplacements) {
|
|
123
|
+
// Provide a resolution cache since overriding resolution prevents automatic creation
|
|
124
|
+
const resolutionCache = typescript.createModuleResolutionCache(host.getCurrentDirectory(), host.getCanonicalFileName.bind(host), compilerOptions);
|
|
125
|
+
host.getModuleResolutionCache = () => resolutionCache;
|
|
126
|
+
augmentHostWithReplacements(typescript, host, hostOptions.fileReplacements, resolutionCache);
|
|
127
|
+
}
|
|
128
|
+
// Augment TypeScript Host with source file caching if provided
|
|
129
|
+
if (hostOptions.sourceFileCache) {
|
|
130
|
+
augmentHostWithCaching(host, hostOptions.sourceFileCache);
|
|
131
|
+
}
|
|
132
|
+
return host;
|
|
133
|
+
}
|
|
134
|
+
exports.createAngularCompilerHost = createAngularCompilerHost;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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;
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|