@angular/build 22.2.0-next.0 → 22.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/package.json +5 -7
  2. package/src/builders/application/build-action.js +2 -2
  3. package/src/builders/application/build-action.js.map +1 -1
  4. package/src/builders/application/execute-build.js +153 -140
  5. package/src/builders/application/execute-build.js.map +1 -1
  6. package/src/private.d.ts +0 -1
  7. package/src/private.js +0 -2
  8. package/src/private.js.map +1 -1
  9. package/src/tools/angular/linker/oxc-ast-host.d.ts +33 -0
  10. package/src/tools/angular/linker/oxc-ast-host.js +204 -0
  11. package/src/tools/angular/linker/oxc-ast-host.js.map +1 -0
  12. package/src/tools/angular/linker/oxc-linker.d.ts +25 -0
  13. package/src/tools/angular/linker/oxc-linker.js +145 -0
  14. package/src/tools/angular/linker/oxc-linker.js.map +1 -0
  15. package/src/tools/angular/linker/string-ast-factory.d.ts +86 -0
  16. package/src/tools/angular/linker/string-ast-factory.js +223 -0
  17. package/src/tools/angular/linker/string-ast-factory.js.map +1 -0
  18. package/src/tools/babel/plugins/oxc-transform.js +9 -9
  19. package/src/tools/babel/plugins/oxc-transform.js.map +1 -1
  20. package/src/tools/babel/plugins/types.d.ts +8 -8
  21. package/src/tools/esbuild/angular/compilation-state.js +6 -6
  22. package/src/tools/esbuild/angular/compilation-state.js.map +1 -1
  23. package/src/tools/esbuild/angular/source-file-cache.d.ts +6 -0
  24. package/src/tools/esbuild/angular/source-file-cache.js +12 -0
  25. package/src/tools/esbuild/angular/source-file-cache.js.map +1 -1
  26. package/src/tools/esbuild/bundler-execution-result.d.ts +2 -1
  27. package/src/tools/esbuild/bundler-execution-result.js +15 -6
  28. package/src/tools/esbuild/bundler-execution-result.js.map +1 -1
  29. package/src/tools/esbuild/i18n-inliner.js +2 -2
  30. package/src/tools/esbuild/i18n-inliner.js.map +1 -1
  31. package/src/tools/esbuild/javascript-transformer-worker.js +78 -83
  32. package/src/tools/esbuild/javascript-transformer-worker.js.map +1 -1
  33. package/src/tools/esbuild/license-extractor.js +18 -11
  34. package/src/tools/esbuild/license-extractor.js.map +1 -1
  35. package/src/tools/esbuild/load-result-cache.d.ts +2 -1
  36. package/src/tools/esbuild/load-result-cache.js +22 -2
  37. package/src/tools/esbuild/load-result-cache.js.map +1 -1
  38. package/src/tools/esbuild/persistent-load-result-cache.d.ts +87 -0
  39. package/src/tools/esbuild/persistent-load-result-cache.js +267 -0
  40. package/src/tools/esbuild/persistent-load-result-cache.js.map +1 -0
  41. package/src/tools/esbuild/stylesheets/stylesheet-cache-key.d.ts +35 -0
  42. package/src/tools/esbuild/stylesheets/stylesheet-cache-key.js +68 -0
  43. package/src/tools/esbuild/stylesheets/stylesheet-cache-key.js.map +1 -0
  44. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +1 -0
  45. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js.map +1 -1
  46. package/src/utils/environment-options.d.ts +6 -0
  47. package/src/utils/environment-options.js +7 -1
  48. package/src/utils/environment-options.js.map +1 -1
  49. package/src/utils/normalize-cache.js +1 -1
  50. package/src/tools/babel/plugins/add-code-coverage.d.ts +0 -14
  51. package/src/tools/babel/plugins/add-code-coverage.js +0 -44
  52. package/src/tools/babel/plugins/add-code-coverage.js.map +0 -1
  53. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -25
  54. package/src/tools/babel/plugins/adjust-static-class-members.js +0 -349
  55. package/src/tools/babel/plugins/adjust-static-class-members.js.map +0 -1
  56. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -21
  57. package/src/tools/babel/plugins/adjust-typescript-enums.js +0 -113
  58. package/src/tools/babel/plugins/adjust-typescript-enums.js.map +0 -1
  59. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -23
  60. package/src/tools/babel/plugins/elide-angular-metadata.js +0 -110
  61. package/src/tools/babel/plugins/elide-angular-metadata.js.map +0 -1
  62. package/src/tools/babel/plugins/index.d.ts +0 -11
  63. package/src/tools/babel/plugins/index.js +0 -22
  64. package/src/tools/babel/plugins/index.js.map +0 -1
  65. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -13
  66. package/src/tools/babel/plugins/pure-toplevel-functions.js +0 -128
  67. package/src/tools/babel/plugins/pure-toplevel-functions.js.map +0 -1
  68. package/src/tools/babel/typings.d.ts +0 -21
@@ -1,349 +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.dev/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 = getKeywords;
14
- exports.default = default_1;
15
- const core_1 = require("@babel/core");
16
- const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
17
- const helper_split_export_declaration_1 = __importDefault(require("@babel/helper-split-export-declaration"));
18
- /**
19
- * The name of the Typescript decorator helper function created by the TypeScript compiler.
20
- */
21
- const TSLIB_DECORATE_HELPER_NAME = '__decorate';
22
- /**
23
- * The set of Angular static fields that should always be wrapped.
24
- * These fields may appear to have side effects but are safe to remove if the associated class
25
- * is otherwise unused within the output.
26
- */
27
- const angularStaticsToWrap = new Set([
28
- 'ɵcmp',
29
- 'ɵdir',
30
- 'ɵfac',
31
- 'ɵinj',
32
- 'ɵmod',
33
- 'ɵpipe',
34
- 'ɵprov',
35
- 'INJECTOR_KEY',
36
- ]);
37
- /**
38
- * An object map of static fields and related value checks for discovery of Angular generated
39
- * JIT related static fields.
40
- */
41
- const angularStaticsToElide = {
42
- 'ctorParameters'(path) {
43
- return path.isFunctionExpression() || path.isArrowFunctionExpression();
44
- },
45
- 'decorators'(path) {
46
- return path.isArrayExpression();
47
- },
48
- 'propDecorators'(path) {
49
- return path.isObjectExpression();
50
- },
51
- };
52
- /**
53
- * Provides one or more keywords that if found within the content of a source file indicate
54
- * that this plugin should be used with a source file.
55
- *
56
- * @returns An a string iterable containing one or more keywords.
57
- */
58
- function getKeywords() {
59
- return ['class'];
60
- }
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 no statements to wrap, check for static class properties.
220
- if (hasPotentialSideEffects ||
221
- (wrapStatementPaths.length === 0 && !analyzeClassStaticProperties(path).shouldWrap)) {
222
- return;
223
- }
224
- const wrapStatementNodes = [];
225
- for (const statementPath of wrapStatementPaths) {
226
- wrapStatementNodes.push(statementPath.node);
227
- statementPath.remove();
228
- }
229
- // Wrap class and safe static assignments in a pure annotated IIFE
230
- const container = core_1.types.arrowFunctionExpression([], core_1.types.blockStatement([
231
- classNode,
232
- ...wrapStatementNodes,
233
- core_1.types.returnStatement(core_1.types.cloneNode(classNode.id)),
234
- ]));
235
- const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
236
- (0, helper_annotate_as_pure_1.default)(replacementInitializer);
237
- // Replace class with IIFE wrapped class
238
- const declaration = core_1.types.variableDeclaration('let', [
239
- core_1.types.variableDeclarator(core_1.types.cloneNode(classNode.id), replacementInitializer),
240
- ]);
241
- path.replaceWith(declaration);
242
- },
243
- ClassExpression(path, state) {
244
- const { node: classNode, parentPath } = path;
245
- const { wrapDecorators } = state.opts;
246
- if (visitedClasses.has(classNode)) {
247
- return;
248
- }
249
- if (!parentPath.isVariableDeclarator() || !core_1.types.isIdentifier(parentPath.node.id)) {
250
- return;
251
- }
252
- const origin = parentPath.parentPath;
253
- if (!origin.isVariableDeclaration() || origin.node.declarations.length !== 1) {
254
- return;
255
- }
256
- const { wrapStatementPaths, hasPotentialSideEffects } = analyzeClassSiblings(origin, parentPath.node.id, wrapDecorators);
257
- visitedClasses.add(classNode);
258
- // If no statements to wrap, check for static class properties.
259
- if (hasPotentialSideEffects ||
260
- (wrapStatementPaths.length === 0 && !analyzeClassStaticProperties(path).shouldWrap)) {
261
- return;
262
- }
263
- const wrapStatementNodes = [];
264
- for (const statementPath of wrapStatementPaths) {
265
- wrapStatementNodes.push(statementPath.node);
266
- statementPath.remove();
267
- }
268
- // Wrap class and safe static assignments in a pure annotated IIFE
269
- const container = core_1.types.arrowFunctionExpression([], core_1.types.blockStatement([
270
- core_1.types.variableDeclaration('let', [
271
- core_1.types.variableDeclarator(core_1.types.cloneNode(parentPath.node.id), classNode),
272
- ]),
273
- ...wrapStatementNodes,
274
- core_1.types.returnStatement(core_1.types.cloneNode(parentPath.node.id)),
275
- ]));
276
- const replacementInitializer = core_1.types.callExpression(core_1.types.parenthesizedExpression(container), []);
277
- (0, helper_annotate_as_pure_1.default)(replacementInitializer);
278
- // Add the wrapped class directly to the variable declaration
279
- parentPath.get('init').replaceWith(replacementInitializer);
280
- },
281
- },
282
- };
283
- }
284
- /**
285
- * Static class properties may be downleveled at later stages in the build pipeline
286
- * which results in additional function calls outside the class body. These calls
287
- * then cause the class to be referenced and not eligible for removal. Since it is
288
- * not known at this stage whether the class needs to be downleveled, the transform
289
- * wraps classes preemptively to allow for potential removal within the optimization stages.
290
- */
291
- function analyzeClassStaticProperties(path) {
292
- let shouldWrap = false;
293
- for (const element of path.get('body').get('body')) {
294
- if (element.isClassProperty()) {
295
- // Only need to analyze static properties
296
- if (!element.node.static) {
297
- continue;
298
- }
299
- // Check for potential side effects.
300
- // These checks are conservative and could potentially be expanded in the future.
301
- const elementKey = element.get('key');
302
- const elementValue = element.get('value');
303
- if (elementKey.isIdentifier() &&
304
- (!elementValue.isExpression() || canWrapProperty(elementKey.node.name, elementValue))) {
305
- shouldWrap = true;
306
- }
307
- else {
308
- // Not safe to wrap
309
- shouldWrap = false;
310
- break;
311
- }
312
- }
313
- else if (element.isStaticBlock()) {
314
- // Only need to analyze static blocks
315
- const body = element.get('body');
316
- if (Array.isArray(body) && body.length > 1) {
317
- // Not safe to wrap
318
- shouldWrap = false;
319
- break;
320
- }
321
- const expression = body.find((n) => n.isExpressionStatement());
322
- const assignmentExpression = expression?.get('expression');
323
- if (assignmentExpression?.isAssignmentExpression()) {
324
- const left = assignmentExpression.get('left');
325
- if (!left.isMemberExpression()) {
326
- continue;
327
- }
328
- if (!left.get('object').isThisExpression()) {
329
- // Not safe to wrap
330
- shouldWrap = false;
331
- break;
332
- }
333
- const element = left.get('property');
334
- const right = assignmentExpression.get('right');
335
- if (element.isIdentifier() &&
336
- (!right.isExpression() || canWrapProperty(element.node.name, right))) {
337
- shouldWrap = true;
338
- }
339
- else {
340
- // Not safe to wrap
341
- shouldWrap = false;
342
- break;
343
- }
344
- }
345
- }
346
- }
347
- return { shouldWrap };
348
- }
349
- //# sourceMappingURL=adjust-static-class-members.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adjust-static-class-members.js","sourceRoot":"","sources":["adjust-static-class-members.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAiDH,kCAEC;AAuJD,4BAwIC;AAhVD,sCAAwE;AACxE,6FAA4D;AAC5D,6GAA4E;AAE5E;;GAEG;AACH,MAAM,0BAA0B,GAAG,YAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,cAAc;CACf,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,qBAAqB,GAAkE;IAC3F,gBAAgB,CAAC,IAAI;QACnB,OAAO,IAAI,CAAC,oBAAoB,EAAE,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;IACzE,CAAC;IACD,YAAY,CAAC,IAAI;QACf,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;IACD,gBAAgB,CAAC,IAAI;QACnB,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,WAAW;IACzB,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,YAAoB,EAAE,eAAyB;IACtE,IAAI,oBAAoB,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,eAAe,EAAE,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I,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC;YAE/D,MAAM,oBAAoB,GAAG,UAAU,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;YAC3D,IAAI,oBAAoB,EAAE,sBAAsB,EAAE,EAAE,CAAC;gBACnD,MAAM,IAAI,GAAG,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC9C,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;oBAC/B,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC;oBAC3C,mBAAmB;oBACnB,UAAU,GAAG,KAAK,CAAC;oBACnB,MAAM;gBACR,CAAC;gBAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACrC,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAChD,IACE,OAAO,CAAC,YAAY,EAAE;oBACtB,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EACpE,CAAC;oBACD,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;qBAAM,CAAC;oBACN,mBAAmB;oBACnB,UAAU,GAAG,KAAK,CAAC;oBACnB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
@@ -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.dev/license
7
- */
8
- import { PluginObject } from '@babel/core';
9
- /**
10
- * Provides one or more keywords that if found within the content of a source file indicate
11
- * that this plugin should be used with a source file.
12
- *
13
- * @returns An a string iterable containing one or more keywords.
14
- */
15
- export declare function getKeywords(): Iterable<string>;
16
- /**
17
- * A babel plugin factory function for adjusting TypeScript emitted enums.
18
- *
19
- * @returns A babel plugin object instance.
20
- */
21
- export default function (): PluginObject;
@@ -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.dev/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 = getKeywords;
14
- exports.default = default_1;
15
- const core_1 = require("@babel/core");
16
- const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
17
- /**
18
- * Provides one or more keywords that if found within the content of a source file indicate
19
- * that this plugin should be used with a source file.
20
- *
21
- * @returns An a string iterable containing one or more keywords.
22
- */
23
- function getKeywords() {
24
- return ['var'];
25
- }
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
- //# sourceMappingURL=adjust-typescript-enums.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"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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.dev/license
7
- */
8
- import type { types as BabelTypes, PluginObject } from '@babel/core';
9
- /**
10
- * Provides one or more keywords that if found within the content of a source file indicate
11
- * that this plugin should be used with a source file.
12
- *
13
- * @returns An a string iterable containing one or more keywords.
14
- */
15
- export declare function getKeywords(): Iterable<string>;
16
- /**
17
- * A babel plugin factory function for eliding the Angular class metadata function (`ɵsetClassMetadata`).
18
- *
19
- * @returns A babel plugin object instance.
20
- */
21
- export default function ({ types: t }: {
22
- types: typeof BabelTypes;
23
- }): PluginObject;
@@ -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.dev/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getKeywords = getKeywords;
11
- exports.default = default_1;
12
- /**
13
- * The name of the Angular class metadata function created by the Angular compiler.
14
- */
15
- const SET_CLASS_METADATA_NAME = 'ɵsetClassMetadata';
16
- /**
17
- * Name of the asynchronous Angular class metadata function created by the Angular compiler.
18
- */
19
- const SET_CLASS_METADATA_ASYNC_NAME = 'ɵsetClassMetadataAsync';
20
- /**
21
- * Name of the function that sets debug information on classes.
22
- */
23
- const SET_CLASS_DEBUG_INFO_NAME = 'ɵsetClassDebugInfo';
24
- /**
25
- * Provides one or more keywords that if found within the content of a source file indicate
26
- * that this plugin should be used with a source file.
27
- *
28
- * @returns An a string iterable containing one or more keywords.
29
- */
30
- function getKeywords() {
31
- return Object.keys(angularMetadataFunctions);
32
- }
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({ types: t }) {
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(t.buildUndefinedNode());
74
- }
75
- }
76
- },
77
- },
78
- };
79
- }
80
- /** Determines if a function call is a call to `setClassMetadata`. */
81
- function isSetClassMetadataCall(callArguments) {
82
- // `setClassMetadata` calls have to meet the following criteria:
83
- // * First must be an identifier
84
- // * Second must be an array literal
85
- return (callArguments.length === 4 &&
86
- callArguments[0].isIdentifier() &&
87
- callArguments[1].isArrayExpression());
88
- }
89
- /** Determines if a function call is a call to `setClassMetadataAsync`. */
90
- function isSetClassMetadataAsyncCall(callArguments) {
91
- // `setClassMetadataAsync` calls have to meet the following criteria:
92
- // * First argument must be an identifier.
93
- // * Second argument must be an inline function.
94
- // * Third argument must be an inline function.
95
- return (callArguments.length === 3 &&
96
- callArguments[0].isIdentifier() &&
97
- isInlineFunction(callArguments[1]) &&
98
- isInlineFunction(callArguments[2]));
99
- }
100
- /** Determines if a function call is a call to `setClassDebugInfo`. */
101
- function isSetClassDebugInfoCall(callArguments) {
102
- return (callArguments.length === 2 &&
103
- callArguments[0].isIdentifier() &&
104
- callArguments[1].isObjectExpression());
105
- }
106
- /** Determines if a node is an inline function expression. */
107
- function isInlineFunction(path) {
108
- return path.isFunctionExpression() || path.isArrowFunctionExpression();
109
- }
110
- //# sourceMappingURL=elide-angular-metadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elide-angular-metadata.js","sourceRoot":"","sources":["elide-angular-metadata.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAyBH,kCAEC;AAiBD,4BAqCC;AA7ED;;GAEG;AACH,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD;;GAEG;AACH,MAAM,6BAA6B,GAAG,wBAAwB,CAAC;AAE/D;;GAEG;AACH,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAEvD;;;;;GAKG;AACH,SAAgB,WAAW;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,wBAAwB,GAAkD;IAC9E,CAAC,uBAAuB,CAAC,EAAE,sBAAsB;IACjD,CAAC,6BAA6B,CAAC,EAAE,2BAA2B;IAC5D,CAAC,yBAAyB,CAAC,EAAE,uBAAuB;CACrD,CAAC;AAEF;;;;GAIG;AACH,mBAAyB,EAAE,KAAK,EAAE,CAAC,EAAgC;IACjE,OAAO;QACL,OAAO,EAAE;YACP,cAAc,CAAC,IAAyC;gBACtD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAElC,+DAA+D;gBAC/D,IAAI,UAAU,CAAC;gBACf,IAAI,MAAM,CAAC,kBAAkB,EAAE,EAAE,CAAC;oBAChC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAC9C,IAAI,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC;wBAClC,UAAU,GAAG,cAAc,CAAC,IAAI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AC,CAAC,CAAC;QAClC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CACnC,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,SAAS,uBAAuB,CAAC,aAAyB;IACxD,OAAO,CACL,aAAa,CAAC,MAAM,KAAK,CAAC;QAC1B,aAAa,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE;QAC/B,aAAa,CAAC,CAAC,CAAC,CAAC,kBAAkB,EAAE,CACtC,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,SAAS,gBAAgB,CAAC,IAAc;IACtC,OAAO,IAAI,CAAC,oBAAoB,EAAE,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;AACzE,CAAC"}
@@ -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.dev/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';