@angular-devkit/build-angular 18.0.0-next.3 → 18.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,351 +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.getKeywords = void 0;
|
|
14
|
-
const core_1 = require("@babel/core");
|
|
15
|
-
const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
|
|
16
|
-
const helper_split_export_declaration_1 = __importDefault(require("@babel/helper-split-export-declaration"));
|
|
17
|
-
/**
|
|
18
|
-
* The name of the Typescript decorator helper function created by the TypeScript compiler.
|
|
19
|
-
*/
|
|
20
|
-
const TSLIB_DECORATE_HELPER_NAME = '__decorate';
|
|
21
|
-
/**
|
|
22
|
-
* The set of Angular static fields that should always be wrapped.
|
|
23
|
-
* These fields may appear to have side effects but are safe to remove if the associated class
|
|
24
|
-
* is otherwise unused within the output.
|
|
25
|
-
*/
|
|
26
|
-
const angularStaticsToWrap = new Set([
|
|
27
|
-
'ɵcmp',
|
|
28
|
-
'ɵdir',
|
|
29
|
-
'ɵfac',
|
|
30
|
-
'ɵinj',
|
|
31
|
-
'ɵmod',
|
|
32
|
-
'ɵpipe',
|
|
33
|
-
'ɵprov',
|
|
34
|
-
'INJECTOR_KEY',
|
|
35
|
-
]);
|
|
36
|
-
/**
|
|
37
|
-
* An object map of static fields and related value checks for discovery of Angular generated
|
|
38
|
-
* JIT related static fields.
|
|
39
|
-
*/
|
|
40
|
-
const angularStaticsToElide = {
|
|
41
|
-
'ctorParameters'(path) {
|
|
42
|
-
return path.isFunctionExpression() || path.isArrowFunctionExpression();
|
|
43
|
-
},
|
|
44
|
-
'decorators'(path) {
|
|
45
|
-
return path.isArrayExpression();
|
|
46
|
-
},
|
|
47
|
-
'propDecorators'(path) {
|
|
48
|
-
return path.isObjectExpression();
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Provides one or more keywords that if found within the content of a source file indicate
|
|
53
|
-
* that this plugin should be used with a source file.
|
|
54
|
-
*
|
|
55
|
-
* @returns An a string iterable containing one or more keywords.
|
|
56
|
-
*/
|
|
57
|
-
function getKeywords() {
|
|
58
|
-
return ['class'];
|
|
59
|
-
}
|
|
60
|
-
exports.getKeywords = getKeywords;
|
|
61
|
-
/**
|
|
62
|
-
* Determines whether a property and its initializer value can be safely wrapped in a pure
|
|
63
|
-
* annotated IIFE. Values that may cause side effects are not considered safe to wrap.
|
|
64
|
-
* Wrapping such values may cause runtime errors and/or incorrect runtime behavior.
|
|
65
|
-
*
|
|
66
|
-
* @param propertyName The name of the property to analyze.
|
|
67
|
-
* @param assignmentValue The initializer value that will be assigned to the property.
|
|
68
|
-
* @returns If the property can be safely wrapped, then true; otherwise, false.
|
|
69
|
-
*/
|
|
70
|
-
function canWrapProperty(propertyName, assignmentValue) {
|
|
71
|
-
if (angularStaticsToWrap.has(propertyName)) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
const { leadingComments } = assignmentValue.node;
|
|
75
|
-
if (leadingComments?.some(
|
|
76
|
-
// `@pureOrBreakMyCode` is used by closure and is present in Angular code
|
|
77
|
-
({ value }) => value.includes('@__PURE__') ||
|
|
78
|
-
value.includes('#__PURE__') ||
|
|
79
|
-
value.includes('@pureOrBreakMyCode'))) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return assignmentValue.isPure();
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Analyze the sibling nodes of a class to determine if any downlevel elements should be
|
|
86
|
-
* wrapped in a pure annotated IIFE. Also determines if any elements have potential side
|
|
87
|
-
* effects.
|
|
88
|
-
*
|
|
89
|
-
* @param origin The starting NodePath location for analyzing siblings.
|
|
90
|
-
* @param classIdentifier The identifier node that represents the name of the class.
|
|
91
|
-
* @param allowWrappingDecorators Whether to allow decorators to be wrapped.
|
|
92
|
-
* @returns An object containing the results of the analysis.
|
|
93
|
-
*/
|
|
94
|
-
function analyzeClassSiblings(origin, classIdentifier, allowWrappingDecorators) {
|
|
95
|
-
const wrapStatementPaths = [];
|
|
96
|
-
let hasPotentialSideEffects = false;
|
|
97
|
-
for (let i = 1;; ++i) {
|
|
98
|
-
const nextStatement = origin.getSibling(+(origin.key ?? 0) + i);
|
|
99
|
-
if (!nextStatement.isExpressionStatement()) {
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
// Valid sibling statements for class declarations are only assignment expressions
|
|
103
|
-
// and TypeScript decorator helper call expressions
|
|
104
|
-
const nextExpression = nextStatement.get('expression');
|
|
105
|
-
if (nextExpression.isCallExpression()) {
|
|
106
|
-
if (!core_1.types.isIdentifier(nextExpression.node.callee) ||
|
|
107
|
-
nextExpression.node.callee.name !== TSLIB_DECORATE_HELPER_NAME) {
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
if (allowWrappingDecorators) {
|
|
111
|
-
wrapStatementPaths.push(nextStatement);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// Statement cannot be safely wrapped which makes wrapping the class unneeded.
|
|
115
|
-
// The statement will prevent even a wrapped class from being optimized away.
|
|
116
|
-
hasPotentialSideEffects = true;
|
|
117
|
-
}
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
else if (!nextExpression.isAssignmentExpression()) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
// Valid assignment expressions should be member access expressions using the class
|
|
124
|
-
// name as the object and an identifier as the property for static fields or only
|
|
125
|
-
// the class name for decorators.
|
|
126
|
-
const left = nextExpression.get('left');
|
|
127
|
-
if (left.isIdentifier()) {
|
|
128
|
-
if (!left.scope.bindingIdentifierEquals(left.node.name, classIdentifier) ||
|
|
129
|
-
!core_1.types.isCallExpression(nextExpression.node.right) ||
|
|
130
|
-
!core_1.types.isIdentifier(nextExpression.node.right.callee) ||
|
|
131
|
-
nextExpression.node.right.callee.name !== TSLIB_DECORATE_HELPER_NAME) {
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
if (allowWrappingDecorators) {
|
|
135
|
-
wrapStatementPaths.push(nextStatement);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
// Statement cannot be safely wrapped which makes wrapping the class unneeded.
|
|
139
|
-
// The statement will prevent even a wrapped class from being optimized away.
|
|
140
|
-
hasPotentialSideEffects = true;
|
|
141
|
-
}
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
else if (!left.isMemberExpression() ||
|
|
145
|
-
!core_1.types.isIdentifier(left.node.object) ||
|
|
146
|
-
!left.scope.bindingIdentifierEquals(left.node.object.name, classIdentifier) ||
|
|
147
|
-
!core_1.types.isIdentifier(left.node.property)) {
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
const propertyName = left.node.property.name;
|
|
151
|
-
const assignmentValue = nextExpression.get('right');
|
|
152
|
-
if (angularStaticsToElide[propertyName]?.(assignmentValue)) {
|
|
153
|
-
nextStatement.remove();
|
|
154
|
-
--i;
|
|
155
|
-
}
|
|
156
|
-
else if (canWrapProperty(propertyName, assignmentValue)) {
|
|
157
|
-
wrapStatementPaths.push(nextStatement);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// Statement cannot be safely wrapped which makes wrapping the class unneeded.
|
|
161
|
-
// The statement will prevent even a wrapped class from being optimized away.
|
|
162
|
-
hasPotentialSideEffects = true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return { hasPotentialSideEffects, wrapStatementPaths };
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* The set of classes already visited and analyzed during the plugin's execution.
|
|
169
|
-
* This is used to prevent adjusted classes from being repeatedly analyzed which can lead
|
|
170
|
-
* to an infinite loop.
|
|
171
|
-
*/
|
|
172
|
-
const visitedClasses = new WeakSet();
|
|
173
|
-
/**
|
|
174
|
-
* A map of classes that have already been analyzed during the default export splitting step.
|
|
175
|
-
* This is used to avoid analyzing a class declaration twice if it is a direct default export.
|
|
176
|
-
*/
|
|
177
|
-
const exportDefaultAnalysis = new WeakMap();
|
|
178
|
-
/**
|
|
179
|
-
* A babel plugin factory function for adjusting classes; primarily with Angular metadata.
|
|
180
|
-
* The adjustments include wrapping classes with known safe or no side effects with pure
|
|
181
|
-
* annotations to support dead code removal of unused classes. Angular compiler generated
|
|
182
|
-
* metadata static fields not required in AOT mode are also elided to better support bundler-
|
|
183
|
-
* level treeshaking.
|
|
184
|
-
*
|
|
185
|
-
* @returns A babel plugin object instance.
|
|
186
|
-
*/
|
|
187
|
-
// eslint-disable-next-line max-lines-per-function
|
|
188
|
-
function default_1() {
|
|
189
|
-
return {
|
|
190
|
-
visitor: {
|
|
191
|
-
// When a class is converted to a variable declaration, the default export must be moved
|
|
192
|
-
// to a subsequent statement to prevent a JavaScript syntax error.
|
|
193
|
-
ExportDefaultDeclaration(path, state) {
|
|
194
|
-
const declaration = path.get('declaration');
|
|
195
|
-
if (!declaration.isClassDeclaration() || !declaration.node.id) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
const { wrapDecorators } = state.opts;
|
|
199
|
-
const analysis = analyzeClassSiblings(path, declaration.node.id, wrapDecorators);
|
|
200
|
-
exportDefaultAnalysis.set(declaration.node, analysis);
|
|
201
|
-
// Splitting the export declaration is not needed if the class will not be wrapped
|
|
202
|
-
if (analysis.hasPotentialSideEffects) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
(0, helper_split_export_declaration_1.default)(path);
|
|
206
|
-
},
|
|
207
|
-
ClassDeclaration(path, state) {
|
|
208
|
-
const { node: classNode, parentPath } = path;
|
|
209
|
-
const { wrapDecorators } = state.opts;
|
|
210
|
-
// Skip if already visited or has no name
|
|
211
|
-
if (visitedClasses.has(classNode) || !classNode.id) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
// Analyze sibling statements for elements of the class that were downleveled
|
|
215
|
-
const origin = parentPath.isExportNamedDeclaration() ? parentPath : path;
|
|
216
|
-
const { wrapStatementPaths, hasPotentialSideEffects } = exportDefaultAnalysis.get(classNode) ??
|
|
217
|
-
analyzeClassSiblings(origin, classNode.id, wrapDecorators);
|
|
218
|
-
visitedClasses.add(classNode);
|
|
219
|
-
if (hasPotentialSideEffects) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
// If no statements to wrap, check for static class properties.
|
|
223
|
-
// Static class properties may be downleveled at later stages in the build pipeline
|
|
224
|
-
// which results in additional function calls outside the class body. These calls
|
|
225
|
-
// then cause the class to be referenced and not eligible for removal. Since it is
|
|
226
|
-
// not known at this stage whether the class needs to be downleveled, the transform
|
|
227
|
-
// wraps classes preemptively to allow for potential removal within the optimization
|
|
228
|
-
// stages.
|
|
229
|
-
if (wrapStatementPaths.length === 0) {
|
|
230
|
-
let shouldWrap = false;
|
|
231
|
-
for (const element of path.get('body').get('body')) {
|
|
232
|
-
if (element.isClassProperty()) {
|
|
233
|
-
// Only need to analyze static properties
|
|
234
|
-
if (!element.node.static) {
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
// Check for potential side effects.
|
|
238
|
-
// These checks are conservative and could potentially be expanded in the future.
|
|
239
|
-
const elementKey = element.get('key');
|
|
240
|
-
const elementValue = element.get('value');
|
|
241
|
-
if (elementKey.isIdentifier() &&
|
|
242
|
-
(!elementValue.isExpression() ||
|
|
243
|
-
canWrapProperty(elementKey.node.name, elementValue))) {
|
|
244
|
-
shouldWrap = true;
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
// Not safe to wrap
|
|
248
|
-
shouldWrap = false;
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
252
|
-
}
|
|
253
|
-
else if (element.isStaticBlock()) {
|
|
254
|
-
// Only need to analyze static blocks
|
|
255
|
-
const body = element.get('body');
|
|
256
|
-
if (Array.isArray(body) && body.length > 1) {
|
|
257
|
-
// Not safe to wrap
|
|
258
|
-
shouldWrap = false;
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
const expression = body.find((n) => n.isExpressionStatement());
|
|
262
|
-
const assignmentExpression = expression?.get('expression');
|
|
263
|
-
if (assignmentExpression?.isAssignmentExpression()) {
|
|
264
|
-
const left = assignmentExpression.get('left');
|
|
265
|
-
if (!left.isMemberExpression()) {
|
|
266
|
-
continue;
|
|
267
|
-
}
|
|
268
|
-
if (!left.get('object').isThisExpression()) {
|
|
269
|
-
// Not safe to wrap
|
|
270
|
-
shouldWrap = false;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
const element = left.get('property');
|
|
274
|
-
const right = assignmentExpression.get('right');
|
|
275
|
-
if (element.isIdentifier() &&
|
|
276
|
-
(!right.isExpression() || canWrapProperty(element.node.name, right))) {
|
|
277
|
-
shouldWrap = true;
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
// Not safe to wrap
|
|
281
|
-
shouldWrap = false;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (!shouldWrap) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
const wrapStatementNodes = [];
|
|
292
|
-
for (const statementPath of wrapStatementPaths) {
|
|
293
|
-
wrapStatementNodes.push(statementPath.node);
|
|
294
|
-
statementPath.remove();
|
|
295
|
-
}
|
|
296
|
-
// Wrap class and safe static assignments in a pure annotated IIFE
|
|
297
|
-
const container = core_1.types.arrowFunctionExpression([], core_1.types.blockStatement([
|
|
298
|
-
classNode,
|
|
299
|
-
...wrapStatementNodes,
|
|
300
|
-
core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
|
|
301
|
-
]));
|
|
302
|
-
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
303
|
-
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
304
|
-
// Replace class with IIFE wrapped class
|
|
305
|
-
const declaration = core_1.types.variableDeclaration('let', [
|
|
306
|
-
core_1.types.variableDeclarator(core_1.types.cloneNode(classNode.id), replacementInitializer),
|
|
307
|
-
]);
|
|
308
|
-
path.replaceWith(declaration);
|
|
309
|
-
},
|
|
310
|
-
ClassExpression(path, state) {
|
|
311
|
-
const { node: classNode, parentPath } = path;
|
|
312
|
-
const { wrapDecorators } = state.opts;
|
|
313
|
-
// Class expressions are used by TypeScript to represent downlevel class/constructor decorators.
|
|
314
|
-
// If not wrapping decorators, they do not need to be processed.
|
|
315
|
-
if (!wrapDecorators || visitedClasses.has(classNode)) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (!parentPath.isVariableDeclarator() || !core_1.types.isIdentifier(parentPath.node.id)) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const origin = parentPath.parentPath;
|
|
322
|
-
if (!origin.isVariableDeclaration() || origin.node.declarations.length !== 1) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
const { wrapStatementPaths, hasPotentialSideEffects } = analyzeClassSiblings(origin, parentPath.node.id, wrapDecorators);
|
|
326
|
-
visitedClasses.add(classNode);
|
|
327
|
-
if (hasPotentialSideEffects || wrapStatementPaths.length === 0) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
const wrapStatementNodes = [];
|
|
331
|
-
for (const statementPath of wrapStatementPaths) {
|
|
332
|
-
wrapStatementNodes.push(statementPath.node);
|
|
333
|
-
statementPath.remove();
|
|
334
|
-
}
|
|
335
|
-
// Wrap class and safe static assignments in a pure annotated IIFE
|
|
336
|
-
const container = core_1.types.arrowFunctionExpression([], core_1.types.blockStatement([
|
|
337
|
-
core_1.types.variableDeclaration('let', [
|
|
338
|
-
core_1.types.variableDeclarator(core_1.types.cloneNode(parentPath.node.id), classNode),
|
|
339
|
-
]),
|
|
340
|
-
...wrapStatementNodes,
|
|
341
|
-
core_1.types.returnStatement(core_1.types.cloneNode(parentPath.node.id)),
|
|
342
|
-
]));
|
|
343
|
-
const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
|
|
344
|
-
(0, helper_annotate_as_pure_1.default)(replacementInitializer);
|
|
345
|
-
// Add the wrapped class directly to the variable declaration
|
|
346
|
-
parentPath.get('init').replaceWith(replacementInitializer);
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
exports.default = default_1;
|
|
@@ -1,23 +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
|
-
/// <reference path="../../../../../../../../../../packages/angular_devkit/build_angular/src/babel-bazel.d.ts" />
|
|
9
|
-
/// <reference types="@angular/compiler-cli/private/babel" />
|
|
10
|
-
import { PluginObj } from '@babel/core';
|
|
11
|
-
/**
|
|
12
|
-
* Provides one or more keywords that if found within the content of a source file indicate
|
|
13
|
-
* that this plugin should be used with a source file.
|
|
14
|
-
*
|
|
15
|
-
* @returns An a string iterable containing one or more keywords.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getKeywords(): Iterable<string>;
|
|
18
|
-
/**
|
|
19
|
-
* A babel plugin factory function for adjusting TypeScript emitted enums.
|
|
20
|
-
*
|
|
21
|
-
* @returns A babel plugin object instance.
|
|
22
|
-
*/
|
|
23
|
-
export default function (): PluginObj;
|
|
@@ -1,113 +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.getKeywords = void 0;
|
|
14
|
-
const core_1 = require("@babel/core");
|
|
15
|
-
const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
|
|
16
|
-
/**
|
|
17
|
-
* Provides one or more keywords that if found within the content of a source file indicate
|
|
18
|
-
* that this plugin should be used with a source file.
|
|
19
|
-
*
|
|
20
|
-
* @returns An a string iterable containing one or more keywords.
|
|
21
|
-
*/
|
|
22
|
-
function getKeywords() {
|
|
23
|
-
return ['var'];
|
|
24
|
-
}
|
|
25
|
-
exports.getKeywords = getKeywords;
|
|
26
|
-
/**
|
|
27
|
-
* A babel plugin factory function for adjusting TypeScript emitted enums.
|
|
28
|
-
*
|
|
29
|
-
* @returns A babel plugin object instance.
|
|
30
|
-
*/
|
|
31
|
-
function default_1() {
|
|
32
|
-
return {
|
|
33
|
-
visitor: {
|
|
34
|
-
VariableDeclaration(path) {
|
|
35
|
-
const { parentPath, node } = path;
|
|
36
|
-
if (node.kind !== 'var' || node.declarations.length !== 1) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const declaration = path.get('declarations')[0];
|
|
40
|
-
if (declaration.node.init) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const declarationId = declaration.node.id;
|
|
44
|
-
if (!core_1.types.isIdentifier(declarationId)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const hasExport = parentPath.isExportNamedDeclaration() || parentPath.isExportDefaultDeclaration();
|
|
48
|
-
const origin = hasExport ? parentPath : path;
|
|
49
|
-
const nextStatement = origin.getSibling(+(origin.key ?? 0) + 1);
|
|
50
|
-
if (!nextStatement.isExpressionStatement()) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const nextExpression = nextStatement.get('expression');
|
|
54
|
-
if (!nextExpression.isCallExpression() || nextExpression.node.arguments.length !== 1) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const enumCallArgument = nextExpression.get('arguments')[0];
|
|
58
|
-
if (!enumCallArgument.isLogicalExpression({ operator: '||' })) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const leftCallArgument = enumCallArgument.get('left');
|
|
62
|
-
const rightCallArgument = enumCallArgument.get('right');
|
|
63
|
-
// Check if identifiers match var declaration
|
|
64
|
-
if (!leftCallArgument.isIdentifier() ||
|
|
65
|
-
!nextExpression.scope.bindingIdentifierEquals(leftCallArgument.node.name, declarationId) ||
|
|
66
|
-
!rightCallArgument.isAssignmentExpression()) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const enumCallee = nextExpression.get('callee');
|
|
70
|
-
if (!enumCallee.isFunctionExpression() || enumCallee.node.params.length !== 1) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const parameterId = enumCallee.get('params')[0];
|
|
74
|
-
if (!parameterId.isIdentifier()) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// Check if all enum member values are pure.
|
|
78
|
-
// If not, leave as-is due to potential side efects
|
|
79
|
-
let hasElements = false;
|
|
80
|
-
for (const enumStatement of enumCallee.get('body').get('body')) {
|
|
81
|
-
if (!enumStatement.isExpressionStatement()) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const enumValueAssignment = enumStatement.get('expression');
|
|
85
|
-
if (!enumValueAssignment.isAssignmentExpression() ||
|
|
86
|
-
!enumValueAssignment.get('right').isPure()) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
hasElements = true;
|
|
90
|
-
}
|
|
91
|
-
// If there are no enum elements then there is nothing to wrap
|
|
92
|
-
if (!hasElements) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
// Update right-side of initializer call argument to remove redundant assignment
|
|
96
|
-
if (rightCallArgument.get('left').isIdentifier()) {
|
|
97
|
-
rightCallArgument.replaceWith(rightCallArgument.get('right'));
|
|
98
|
-
}
|
|
99
|
-
// Add a return statement to the enum initializer block
|
|
100
|
-
enumCallee
|
|
101
|
-
.get('body')
|
|
102
|
-
.node.body.push(core_1.types.returnStatement(core_1.types.cloneNode(parameterId.node)));
|
|
103
|
-
// Remove existing enum initializer
|
|
104
|
-
const enumInitializer = nextExpression.node;
|
|
105
|
-
nextExpression.remove();
|
|
106
|
-
(0, helper_annotate_as_pure_1.default)(enumInitializer);
|
|
107
|
-
// Add the wrapped enum initializer directly to the variable declaration
|
|
108
|
-
declaration.get('init').replaceWith(enumInitializer);
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
exports.default = default_1;
|
|
@@ -1,23 +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
|
-
/// <reference path="../../../../../../../../../../packages/angular_devkit/build_angular/src/babel-bazel.d.ts" />
|
|
9
|
-
/// <reference types="@angular/compiler-cli/private/babel" />
|
|
10
|
-
import type { PluginObj } from '@babel/core';
|
|
11
|
-
/**
|
|
12
|
-
* Provides one or more keywords that if found within the content of a source file indicate
|
|
13
|
-
* that this plugin should be used with a source file.
|
|
14
|
-
*
|
|
15
|
-
* @returns An a string iterable containing one or more keywords.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getKeywords(): Iterable<string>;
|
|
18
|
-
/**
|
|
19
|
-
* A babel plugin factory function for eliding the Angular class metadata function (`ɵsetClassMetadata`).
|
|
20
|
-
*
|
|
21
|
-
* @returns A babel plugin object instance.
|
|
22
|
-
*/
|
|
23
|
-
export default function (): PluginObj;
|
|
@@ -1,110 +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
|
-
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
|
-
}
|
|
@@ -1,11 +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 { 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';
|
|
@@ -1,21 +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.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; } });
|
|
@@ -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
|
-
/// <reference path="../../../../../../../../../../packages/angular_devkit/build_angular/src/babel-bazel.d.ts" />
|
|
9
|
-
/// <reference types="@angular/compiler-cli/private/babel" />
|
|
10
|
-
import type { PluginObj } from '@babel/core';
|
|
11
|
-
/**
|
|
12
|
-
* A babel plugin factory function for adding the PURE annotation to top-level new and call expressions.
|
|
13
|
-
*
|
|
14
|
-
* @returns A babel plugin object instance.
|
|
15
|
-
*/
|
|
16
|
-
export default function (): PluginObj;
|