@angular/core 19.0.0-rc.1 → 19.0.0-rc.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.
Files changed (34) hide show
  1. package/fesm2022/core.mjs +13164 -13060
  2. package/fesm2022/core.mjs.map +1 -1
  3. package/fesm2022/primitives/event-dispatch.mjs +2 -2
  4. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  5. package/fesm2022/primitives/signals.mjs +1 -1
  6. package/fesm2022/rxjs-interop.mjs +1 -1
  7. package/fesm2022/testing.mjs +4 -4
  8. package/index.d.ts +74 -13
  9. package/package.json +1 -1
  10. package/primitives/event-dispatch/index.d.ts +1 -1
  11. package/primitives/signals/index.d.ts +1 -1
  12. package/rxjs-interop/index.d.ts +1 -1
  13. package/schematics/bundles/{checker-9ca42e51.js → checker-e3da3b0a.js} +95 -54
  14. package/schematics/bundles/{combine_units-a16385aa.js → combine_units-2adebceb.js} +97 -28
  15. package/schematics/bundles/{compiler_host-31afa4ed.js → compiler_host-d642e87e.js} +2 -2
  16. package/schematics/bundles/control-flow-migration.js +3 -3
  17. package/schematics/bundles/explicit-standalone-flag.js +3 -3
  18. package/schematics/bundles/imports-4ac08251.js +1 -1
  19. package/schematics/bundles/inject-migration.js +3 -3
  20. package/schematics/bundles/leading_space-d190b83b.js +1 -1
  21. package/schematics/bundles/{migrate_ts_type_references-b2a28742.js → migrate_ts_type_references-ed2c0669.js} +527 -31
  22. package/schematics/bundles/nodes-0e7d45ca.js +1 -1
  23. package/schematics/bundles/output-migration.js +17 -14
  24. package/schematics/bundles/pending-tasks.js +3 -3
  25. package/schematics/bundles/{program-71beec0b.js → program-f984ab63.js} +45 -52
  26. package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
  27. package/schematics/bundles/provide-initializer.js +3 -3
  28. package/schematics/bundles/route-lazy-loading.js +3 -3
  29. package/schematics/bundles/signal-input-migration.js +48 -35
  30. package/schematics/bundles/signal-queries-migration.js +21 -14
  31. package/schematics/bundles/signals.js +5 -5
  32. package/schematics/bundles/standalone-migration.js +159 -75
  33. package/schematics/ng-generate/signals/schema.json +1 -0
  34. package/testing/index.d.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,8 +10,8 @@ var core = require('@angular-devkit/core');
10
10
  var posixPath = require('node:path/posix');
11
11
  var os = require('os');
12
12
  var ts = require('typescript');
13
- var checker = require('./checker-9ca42e51.js');
14
- var program = require('./program-71beec0b.js');
13
+ var checker = require('./checker-e3da3b0a.js');
14
+ var program = require('./program-f984ab63.js');
15
15
  require('path');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -155,9 +155,14 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
155
155
  // Errors are handled later on by 'parseJsonConfigFileContent'
156
156
  return parentOptions;
157
157
  }
158
+ // Note: In Google, `angularCompilerOptions` are stored in `bazelOptions`.
159
+ // This function typically doesn't run for actual Angular compilations, but
160
+ // tooling like Tsurge, or schematics may leverage this helper, so we account
161
+ // for this here.
162
+ const angularCompilerOptions = config.angularCompilerOptions ?? config.bazelOptions?.angularCompilerOptions;
158
163
  // we are only interested into merging 'angularCompilerOptions' as
159
164
  // other options like 'compilerOptions' are merged by TS
160
- let existingNgCompilerOptions = { ...config.angularCompilerOptions, ...parentOptions };
165
+ let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
161
166
  if (!config.extends) {
162
167
  return existingNgCompilerOptions;
163
168
  }
@@ -410,32 +415,56 @@ function groupReplacementsByFile(replacements) {
410
415
  return result;
411
416
  }
412
417
 
413
- /** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
414
- const NO_INPUTS_ERROR_CODE = 18003;
418
+ /**
419
+ * By default, Tsurge will always create an Angular compiler program
420
+ * for projects analyzed and migrated. This works perfectly fine in
421
+ * third-party where Tsurge migrations run in Angular CLI projects.
422
+ *
423
+ * In first party, when running against full Google3, creating an Angular
424
+ * program for e.g. plain `ts_library` targets is overly expensive and
425
+ * can result in out of memory issues for large TS targets. In 1P we can
426
+ * reliably distinguish between TS and Angular targets via the `angularCompilerOptions`.
427
+ */
428
+ function google3UsePlainTsProgramIfNoKnownAngularOption() {
429
+ return process.env['GOOGLE3_TSURGE'] === '1';
430
+ }
431
+
432
+ /** Options that are good defaults for Tsurge migrations. */
433
+ const defaultMigrationTsOptions = {
434
+ // Avoid checking libraries to speed up migrations.
435
+ skipLibCheck: true,
436
+ skipDefaultLibCheck: true,
437
+ noEmit: true,
438
+ };
439
+ /**
440
+ * Creates an instance of a TypeScript program for the given project.
441
+ */
442
+ function createPlainTsProgram(tsHost, tsconfig, optionOverrides) {
443
+ const program = ts__default["default"].createProgram({
444
+ rootNames: tsconfig.rootNames,
445
+ options: {
446
+ ...tsconfig.options,
447
+ ...defaultMigrationTsOptions,
448
+ ...optionOverrides,
449
+ },
450
+ });
451
+ return {
452
+ ngCompiler: null,
453
+ program,
454
+ userOptions: tsconfig.options,
455
+ programAbsoluteRootFileNames: tsconfig.rootNames,
456
+ host: tsHost,
457
+ };
458
+ }
459
+
415
460
  /**
416
461
  * Parses the configuration of the given TypeScript project and creates
417
462
  * an instance of the Angular compiler for the project.
418
463
  */
419
- function createNgtscProgram(absoluteTsconfigPath, fs, optionOverrides = {}) {
420
- if (fs === undefined) {
421
- fs = new checker.NodeJSFileSystem();
422
- checker.setFileSystem(fs);
423
- }
424
- const tsconfig = readConfiguration(absoluteTsconfigPath, {}, fs);
425
- // Skip the "No inputs found..." error since we don't want to interrupt the migration if a
426
- // tsconfig doesn't match a file. This will result in an empty `Program` which is still valid.
427
- const errors = tsconfig.errors.filter((diag) => diag.code !== NO_INPUTS_ERROR_CODE);
428
- if (errors.length) {
429
- throw new Error(`Tsconfig could not be parsed or is invalid:\n\n` + `${errors.map((e) => e.messageText)}`);
430
- }
431
- const tsHost = new NgtscCompilerHost(fs, tsconfig.options);
464
+ function createNgtscProgram(tsHost, tsconfig, optionOverrides) {
432
465
  const ngtscProgram = new program.NgtscProgram(tsconfig.rootNames, {
433
466
  ...tsconfig.options,
434
- // Avoid checking libraries to speed up migrations.
435
- skipLibCheck: true,
436
- skipDefaultLibCheck: true,
437
- noEmit: true,
438
- // Additional override options.
467
+ ...defaultMigrationTsOptions,
439
468
  ...optionOverrides,
440
469
  }, tsHost);
441
470
  // Expose an easy way to debug-print ng semantic diagnostics.
@@ -451,6 +480,37 @@ function createNgtscProgram(absoluteTsconfigPath, fs, optionOverrides = {}) {
451
480
  };
452
481
  }
453
482
 
483
+ /** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
484
+ const NO_INPUTS_ERROR_CODE = 18003;
485
+ /** Parses the given tsconfig file, supporting Angular compiler options. */
486
+ function parseTsconfigOrDie(absoluteTsconfigPath, fs) {
487
+ const tsconfig = readConfiguration(absoluteTsconfigPath, {}, fs);
488
+ // Skip the "No inputs found..." error since we don't want to interrupt the migration if a
489
+ // tsconfig doesn't match a file. This will result in an empty `Program` which is still valid.
490
+ const errors = tsconfig.errors.filter((diag) => diag.code !== NO_INPUTS_ERROR_CODE);
491
+ if (errors.length) {
492
+ throw new Error(`Tsconfig could not be parsed or is invalid:\n\n` + `${errors.map((e) => e.messageText)}`);
493
+ }
494
+ return tsconfig;
495
+ }
496
+
497
+ /** Creates the base program info for the given tsconfig path. */
498
+ function createBaseProgramInfo(absoluteTsconfigPath, fs, optionOverrides = {}) {
499
+ if (fs === undefined) {
500
+ fs = new checker.NodeJSFileSystem();
501
+ checker.setFileSystem(fs);
502
+ }
503
+ const tsconfig = parseTsconfigOrDie(absoluteTsconfigPath, fs);
504
+ const tsHost = new NgtscCompilerHost(fs, tsconfig.options);
505
+ // When enabled, use a plain TS program if we are sure it's not
506
+ // an Angular project based on the `tsconfig.json`.
507
+ if (google3UsePlainTsProgramIfNoKnownAngularOption() &&
508
+ tsconfig.options['_useHostForImportGeneration'] === undefined) {
509
+ return createPlainTsProgram(tsHost, tsconfig, optionOverrides);
510
+ }
511
+ return createNgtscProgram(tsHost, tsconfig, optionOverrides);
512
+ }
513
+
454
514
  /**
455
515
  * @private
456
516
  *
@@ -460,9 +520,16 @@ function createNgtscProgram(absoluteTsconfigPath, fs, optionOverrides = {}) {
460
520
  * TypeScript programs, while also allowing migration authors to override.
461
521
  */
462
522
  class TsurgeBaseMigration {
463
- // By default, ngtsc programs are being created.
523
+ /**
524
+ * Advanced Tsurge users can override this method, but most of the time,
525
+ * overriding {@link prepareProgram} is more desirable.
526
+ *
527
+ * By default:
528
+ * - In 3P: Ngtsc programs are being created.
529
+ * - In 1P: Ngtsc or TS programs are created based on the Blaze target.
530
+ */
464
531
  createProgram(tsconfigAbsPath, fs) {
465
- return createNgtscProgram(tsconfigAbsPath, fs);
532
+ return createBaseProgramInfo(tsconfigAbsPath, fs);
466
533
  }
467
534
  // Optional function to prepare the base `ProgramInfo` even further,
468
535
  // for the analyze and migrate phases. E.g. determining source files.
@@ -1544,7 +1611,9 @@ function createFindAllSourceFileReferencesVisitor(programInfo, checker, reflecto
1544
1611
  const currentTimeInMs = () => typeof global.performance !== 'undefined' ? global.performance.now() : Date.now();
1545
1612
  const visitor = (node) => {
1546
1613
  let lastTime = currentTimeInMs();
1547
- if (ts__default["default"].isClassDeclaration(node)) {
1614
+ // Note: If there is no template type checker and resource loader, we aren't processing
1615
+ // an Angular program, and can skip template detection.
1616
+ if (ts__default["default"].isClassDeclaration(node) && templateTypeChecker !== null && resourceLoader !== null) {
1548
1617
  identifyTemplateReferences(programInfo, node, reflector, checker, evaluator, templateTypeChecker, resourceLoader, programInfo.userOptions, result, knownFields, fieldNamesToConsiderForReferenceLookup);
1549
1618
  perfCounters.template += (currentTimeInMs() - lastTime) / 1000;
1550
1619
  lastTime = currentTimeInMs();
@@ -1618,8 +1687,8 @@ exports.TsurgeComplexMigration = TsurgeComplexMigration;
1618
1687
  exports.TsurgeFunnelMigration = TsurgeFunnelMigration;
1619
1688
  exports.applyImportManagerChanges = applyImportManagerChanges;
1620
1689
  exports.confirmAsSerializable = confirmAsSerializable;
1690
+ exports.createBaseProgramInfo = createBaseProgramInfo;
1621
1691
  exports.createFindAllSourceFileReferencesVisitor = createFindAllSourceFileReferencesVisitor;
1622
- exports.createNgtscProgram = createNgtscProgram;
1623
1692
  exports.getBindingElementDeclaration = getBindingElementDeclaration;
1624
1693
  exports.getMemberName = getMemberName;
1625
1694
  exports.groupReplacementsByFile = groupReplacementsByFile;
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
9
  var ts = require('typescript');
10
- var checker = require('./checker-9ca42e51.js');
10
+ var checker = require('./checker-e3da3b0a.js');
11
11
  require('os');
12
12
  var p = require('path');
13
13
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,8 +10,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
- var compiler_host = require('./compiler_host-31afa4ed.js');
14
- var checker = require('./checker-9ca42e51.js');
13
+ var compiler_host = require('./compiler_host-d642e87e.js');
14
+ var checker = require('./checker-e3da3b0a.js');
15
15
  var ts = require('typescript');
16
16
  require('os');
17
17
  require('fs');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -11,11 +11,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
13
  var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
14
- var compiler_host = require('./compiler_host-31afa4ed.js');
14
+ var compiler_host = require('./compiler_host-d642e87e.js');
15
15
  var ts = require('typescript');
16
16
  var imports = require('./imports-4ac08251.js');
17
17
  require('@angular-devkit/core');
18
- require('./checker-9ca42e51.js');
18
+ require('./checker-e3da3b0a.js');
19
19
  require('os');
20
20
  require('fs');
21
21
  require('module');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -10,12 +10,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
 
11
11
  var schematics = require('@angular-devkit/schematics');
12
12
  var p = require('path');
13
- var compiler_host = require('./compiler_host-31afa4ed.js');
13
+ var compiler_host = require('./compiler_host-d642e87e.js');
14
14
  var ts = require('typescript');
15
15
  var nodes = require('./nodes-0e7d45ca.js');
16
16
  var imports = require('./imports-4ac08251.js');
17
17
  var leading_space = require('./leading_space-d190b83b.js');
18
- require('./checker-9ca42e51.js');
18
+ require('./checker-e3da3b0a.js');
19
19
  require('os');
20
20
  require('fs');
21
21
  require('module');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.0.0-rc.1
3
+ * @license Angular v19.0.0-rc.3
4
4
  * (c) 2010-2024 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */