@angular/core 19.0.0-rc.1 → 19.0.0-rc.2
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/fesm2022/core.mjs +12971 -12926
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -2
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +13 -12
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/{checker-9ca42e51.js → checker-cd95ebda.js} +31 -22
- package/schematics/bundles/{combine_units-a16385aa.js → combine_units-528c4a5d.js} +97 -28
- package/schematics/bundles/{compiler_host-31afa4ed.js → compiler_host-40e8d55f.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +3 -3
- package/schematics/bundles/imports-4ac08251.js +1 -1
- package/schematics/bundles/inject-migration.js +3 -3
- package/schematics/bundles/leading_space-d190b83b.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-b2a28742.js → migrate_ts_type_references-0bcee7cb.js} +527 -31
- package/schematics/bundles/nodes-0e7d45ca.js +1 -1
- package/schematics/bundles/output-migration.js +10 -11
- package/schematics/bundles/pending-tasks.js +3 -3
- package/schematics/bundles/{program-71beec0b.js → program-8f30df93.js} +45 -52
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/provide-initializer.js +3 -3
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/signal-input-migration.js +48 -35
- package/schematics/bundles/signal-queries-migration.js +21 -14
- package/schematics/bundles/signals.js +5 -5
- package/schematics/bundles/standalone-migration.js +159 -75
- package/schematics/ng-generate/signals/schema.json +1 -0
- package/testing/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-rc.
|
|
2
|
+
* @license Angular v19.0.0-rc.2
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
|
|
|
175
175
|
throw e;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.
|
|
179
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.
|
|
178
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.2", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
179
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.2", ngImport: i0, type: TestBedApplicationErrorHandler });
|
|
180
180
|
}
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.2", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
|
|
182
182
|
type: Injectable
|
|
183
183
|
}] });
|
|
184
184
|
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-rc.
|
|
2
|
+
* @license Angular v19.0.0-rc.2
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -3041,16 +3041,6 @@ declare const DEFER_BLOCK_ID = "di";
|
|
|
3041
3041
|
|
|
3042
3042
|
declare const DEFER_BLOCK_STATE = "s";
|
|
3043
3043
|
|
|
3044
|
-
/**
|
|
3045
|
-
* Basic set of data structures used for identifying a defer block
|
|
3046
|
-
* and triggering defer blocks
|
|
3047
|
-
*/
|
|
3048
|
-
declare interface DeferBlock {
|
|
3049
|
-
lView: LView;
|
|
3050
|
-
tNode: TNode;
|
|
3051
|
-
lContainer: LContainer;
|
|
3052
|
-
}
|
|
3053
|
-
|
|
3054
3044
|
/**
|
|
3055
3045
|
* Represents defer trigger types.
|
|
3056
3046
|
*/
|
|
@@ -3110,6 +3100,16 @@ declare interface DehydratedContainerView extends DehydratedView {
|
|
|
3110
3100
|
data: Readonly<SerializedContainerView>;
|
|
3111
3101
|
}
|
|
3112
3102
|
|
|
3103
|
+
/**
|
|
3104
|
+
* Basic set of data structures used for identifying a defer block
|
|
3105
|
+
* and triggering defer blocks
|
|
3106
|
+
*/
|
|
3107
|
+
declare interface DehydratedDeferBlock {
|
|
3108
|
+
lView: LView;
|
|
3109
|
+
tNode: TNode;
|
|
3110
|
+
lContainer: LContainer;
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
3113
|
/**
|
|
3114
3114
|
* An object that contains information about a dehydrated ICU case,
|
|
3115
3115
|
* to facilitate cleaning up ICU cases that were active during
|
|
@@ -13170,7 +13170,7 @@ export declare interface ɵDeferBlockDependencyInterceptor {
|
|
|
13170
13170
|
/**
|
|
13171
13171
|
* Defer block instance for testing.
|
|
13172
13172
|
*/
|
|
13173
|
-
export declare interface ɵDeferBlockDetails extends
|
|
13173
|
+
export declare interface ɵDeferBlockDetails extends DehydratedDeferBlock {
|
|
13174
13174
|
tDetails: TDeferBlockDetails;
|
|
13175
13175
|
}
|
|
13176
13176
|
|
|
@@ -14263,6 +14263,7 @@ export declare class ɵRender3NgModuleRef<T> extends NgModuleRef<T> implements I
|
|
|
14263
14263
|
onDestroy(callback: () => void): void;
|
|
14264
14264
|
}
|
|
14265
14265
|
|
|
14266
|
+
/** Rendering Helpers */
|
|
14266
14267
|
/**
|
|
14267
14268
|
* Transitions a defer block to the new state. Updates the necessary
|
|
14268
14269
|
* data structures and renders corresponding block.
|
package/package.json
CHANGED
package/rxjs-interop/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-rc.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -25876,15 +25876,16 @@ function convertSourceSpan(span, baseSourceSpan) {
|
|
|
25876
25876
|
* workaround, because it'll include an additional text node as the first child. We can work
|
|
25877
25877
|
* around it here, but in a discussion it was decided not to, because the user explicitly opted
|
|
25878
25878
|
* into preserving the whitespace and we would have to drop it from the generated code.
|
|
25879
|
-
* The diagnostic mentioned point #1 will flag such cases to users.
|
|
25879
|
+
* The diagnostic mentioned point in #1 will flag such cases to users.
|
|
25880
25880
|
*
|
|
25881
25881
|
* @returns Tag name to be used for the control flow template.
|
|
25882
25882
|
*/
|
|
25883
25883
|
function ingestControlFlowInsertionPoint(unit, xref, node) {
|
|
25884
25884
|
let root = null;
|
|
25885
25885
|
for (const child of node.children) {
|
|
25886
|
-
// Skip over comment nodes
|
|
25887
|
-
|
|
25886
|
+
// Skip over comment nodes and @let declarations since
|
|
25887
|
+
// it doesn't matter where they end up in the DOM.
|
|
25888
|
+
if (child instanceof Comment$1 || child instanceof LetDeclaration$1) {
|
|
25888
25889
|
continue;
|
|
25889
25890
|
}
|
|
25890
25891
|
// We can only infer the tag name/attributes if there's a single root node.
|
|
@@ -25895,6 +25896,9 @@ function ingestControlFlowInsertionPoint(unit, xref, node) {
|
|
|
25895
25896
|
if (child instanceof Element$1 || (child instanceof Template && child.tagName !== null)) {
|
|
25896
25897
|
root = child;
|
|
25897
25898
|
}
|
|
25899
|
+
else {
|
|
25900
|
+
return null;
|
|
25901
|
+
}
|
|
25898
25902
|
}
|
|
25899
25903
|
// If we've found a single root node, its tag name and attributes can be
|
|
25900
25904
|
// copied to the surrounding template to be used for content projection.
|
|
@@ -30274,7 +30278,7 @@ function publishFacade(global) {
|
|
|
30274
30278
|
* @description
|
|
30275
30279
|
* Entry point for all public APIs of the compiler package.
|
|
30276
30280
|
*/
|
|
30277
|
-
new Version('19.0.0-rc.
|
|
30281
|
+
new Version('19.0.0-rc.2');
|
|
30278
30282
|
|
|
30279
30283
|
const _I18N_ATTR = 'i18n';
|
|
30280
30284
|
const _I18N_ATTR_PREFIX = 'i18n-';
|
|
@@ -31682,7 +31686,7 @@ class NodeJSPathManipulation {
|
|
|
31682
31686
|
// G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
|
|
31683
31687
|
// CommonJS/ESM interop for determining the current file name and containing dir.
|
|
31684
31688
|
const isCommonJS = typeof __filename !== 'undefined';
|
|
31685
|
-
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('checker-
|
|
31689
|
+
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('checker-cd95ebda.js', document.baseURI).href));
|
|
31686
31690
|
const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
|
|
31687
31691
|
/**
|
|
31688
31692
|
* A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
|
|
@@ -31948,6 +31952,11 @@ exports.ImportFlags = void 0;
|
|
|
31948
31952
|
*/
|
|
31949
31953
|
ImportFlags[ImportFlags["AllowAmbientReferences"] = 16] = "AllowAmbientReferences";
|
|
31950
31954
|
})(exports.ImportFlags || (exports.ImportFlags = {}));
|
|
31955
|
+
exports.ReferenceEmitKind = void 0;
|
|
31956
|
+
(function (ReferenceEmitKind) {
|
|
31957
|
+
ReferenceEmitKind[ReferenceEmitKind["Success"] = 0] = "Success";
|
|
31958
|
+
ReferenceEmitKind[ReferenceEmitKind["Failed"] = 1] = "Failed";
|
|
31959
|
+
})(exports.ReferenceEmitKind || (exports.ReferenceEmitKind = {}));
|
|
31951
31960
|
/**
|
|
31952
31961
|
* Verifies that a reference was emitted successfully, or raises a `FatalDiagnosticError` otherwise.
|
|
31953
31962
|
* @param result The emit result that should have been successful.
|
|
@@ -31956,7 +31965,7 @@ exports.ImportFlags = void 0;
|
|
|
31956
31965
|
* 'class'.
|
|
31957
31966
|
*/
|
|
31958
31967
|
function assertSuccessfulReferenceEmit(result, origin, typeKind) {
|
|
31959
|
-
if (result.kind ===
|
|
31968
|
+
if (result.kind === exports.ReferenceEmitKind.Success) {
|
|
31960
31969
|
return;
|
|
31961
31970
|
}
|
|
31962
31971
|
const message = makeDiagnosticChain(`Unable to import ${typeKind} ${nodeNameForError(result.ref.node)}.`, [makeDiagnosticChain(result.reason)]);
|
|
@@ -31983,7 +31992,7 @@ class ReferenceEmitter {
|
|
|
31983
31992
|
}
|
|
31984
31993
|
}
|
|
31985
31994
|
return {
|
|
31986
|
-
kind:
|
|
31995
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
31987
31996
|
ref,
|
|
31988
31997
|
context,
|
|
31989
31998
|
reason: `Unable to write a reference to ${nodeNameForError(ref.node)}.`,
|
|
@@ -32009,7 +32018,7 @@ class LocalIdentifierStrategy {
|
|
|
32009
32018
|
// invalid emission of a free-standing `foo` identifier, rather than `exports.foo`.
|
|
32010
32019
|
if (!isDeclaration(ref.node) && refSf === context) {
|
|
32011
32020
|
return {
|
|
32012
|
-
kind:
|
|
32021
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32013
32022
|
expression: new WrappedNodeExpr(ref.node),
|
|
32014
32023
|
importedFile: null,
|
|
32015
32024
|
};
|
|
@@ -32019,7 +32028,7 @@ class LocalIdentifierStrategy {
|
|
|
32019
32028
|
const identifier = identifierOfNode(ref.node);
|
|
32020
32029
|
if (identifier !== null) {
|
|
32021
32030
|
return {
|
|
32022
|
-
kind:
|
|
32031
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32023
32032
|
expression: new WrappedNodeExpr(identifier),
|
|
32024
32033
|
importedFile: null,
|
|
32025
32034
|
};
|
|
@@ -32033,7 +32042,7 @@ class LocalIdentifierStrategy {
|
|
|
32033
32042
|
const identifier = ref.getIdentityIn(context);
|
|
32034
32043
|
if (identifier !== null) {
|
|
32035
32044
|
return {
|
|
32036
|
-
kind:
|
|
32045
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32037
32046
|
expression: new WrappedNodeExpr(identifier),
|
|
32038
32047
|
importedFile: null,
|
|
32039
32048
|
};
|
|
@@ -32086,7 +32095,7 @@ class AbsoluteModuleStrategy {
|
|
|
32086
32095
|
const exports$1 = this.getExportsOfModule(specifier, resolutionContext);
|
|
32087
32096
|
if (exports$1.module === null) {
|
|
32088
32097
|
return {
|
|
32089
|
-
kind:
|
|
32098
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
32090
32099
|
ref,
|
|
32091
32100
|
context,
|
|
32092
32101
|
reason: `The module '${specifier}' could not be found.`,
|
|
@@ -32094,7 +32103,7 @@ class AbsoluteModuleStrategy {
|
|
|
32094
32103
|
}
|
|
32095
32104
|
else if (exports$1.exportMap === null || !exports$1.exportMap.has(ref.node)) {
|
|
32096
32105
|
return {
|
|
32097
|
-
kind:
|
|
32106
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
32098
32107
|
ref,
|
|
32099
32108
|
context,
|
|
32100
32109
|
reason: `The symbol is not exported from ${exports$1.module.fileName} (module '${specifier}').`,
|
|
@@ -32102,7 +32111,7 @@ class AbsoluteModuleStrategy {
|
|
|
32102
32111
|
}
|
|
32103
32112
|
const symbolName = exports$1.exportMap.get(ref.node);
|
|
32104
32113
|
return {
|
|
32105
|
-
kind:
|
|
32114
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32106
32115
|
expression: new ExternalExpr(new ExternalReference(specifier, symbolName)),
|
|
32107
32116
|
importedFile: exports$1.module,
|
|
32108
32117
|
};
|
|
@@ -32173,7 +32182,7 @@ class LogicalProjectStrategy {
|
|
|
32173
32182
|
// Note: this error is analogous to `TS6059: File is not under 'rootDir'` that TypeScript
|
|
32174
32183
|
// reports.
|
|
32175
32184
|
return {
|
|
32176
|
-
kind:
|
|
32185
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
32177
32186
|
ref,
|
|
32178
32187
|
context,
|
|
32179
32188
|
reason: `The file ${destSf.fileName} is outside of the configured 'rootDir'.`,
|
|
@@ -32191,7 +32200,7 @@ class LogicalProjectStrategy {
|
|
|
32191
32200
|
if (name === null) {
|
|
32192
32201
|
// The target declaration isn't exported from the file it's declared in. This is an issue!
|
|
32193
32202
|
return {
|
|
32194
|
-
kind:
|
|
32203
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
32195
32204
|
ref,
|
|
32196
32205
|
context,
|
|
32197
32206
|
reason: `The symbol is not exported from ${destSf.fileName}.`,
|
|
@@ -32201,7 +32210,7 @@ class LogicalProjectStrategy {
|
|
|
32201
32210
|
// path is now straightforward.
|
|
32202
32211
|
const moduleName = LogicalProjectPath.relativePathBetween(originPath, destPath);
|
|
32203
32212
|
return {
|
|
32204
|
-
kind:
|
|
32213
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32205
32214
|
expression: new ExternalExpr({ moduleName, name }),
|
|
32206
32215
|
importedFile: destSf,
|
|
32207
32216
|
};
|
|
@@ -32225,14 +32234,14 @@ class RelativePathStrategy {
|
|
|
32225
32234
|
const name = findExportedNameOfNode(ref.node, destSf, this.reflector);
|
|
32226
32235
|
if (name === null) {
|
|
32227
32236
|
return {
|
|
32228
|
-
kind:
|
|
32237
|
+
kind: exports.ReferenceEmitKind.Failed,
|
|
32229
32238
|
ref,
|
|
32230
32239
|
context,
|
|
32231
32240
|
reason: `The symbol is not exported from ${destSf.fileName}.`,
|
|
32232
32241
|
};
|
|
32233
32242
|
}
|
|
32234
32243
|
return {
|
|
32235
|
-
kind:
|
|
32244
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32236
32245
|
expression: new ExternalExpr({ moduleName, name }),
|
|
32237
32246
|
importedFile: destSf,
|
|
32238
32247
|
};
|
|
@@ -32257,7 +32266,7 @@ class UnifiedModulesStrategy {
|
|
|
32257
32266
|
}
|
|
32258
32267
|
const moduleName = this.unifiedModulesHost.fileNameToModuleName(destSf.fileName, context.fileName);
|
|
32259
32268
|
return {
|
|
32260
|
-
kind:
|
|
32269
|
+
kind: exports.ReferenceEmitKind.Success,
|
|
32261
32270
|
expression: new ExternalExpr({ moduleName, name }),
|
|
32262
32271
|
importedFile: destSf,
|
|
32263
32272
|
};
|
|
@@ -39583,7 +39592,7 @@ class ReferenceEmitEnvironment {
|
|
|
39583
39592
|
exports.ImportFlags.AllowTypeImports |
|
|
39584
39593
|
exports.ImportFlags.AllowRelativeDtsImports) {
|
|
39585
39594
|
const result = this.refEmitter.emit(ref, this.contextFile, flags);
|
|
39586
|
-
return result.kind ===
|
|
39595
|
+
return result.kind === exports.ReferenceEmitKind.Success;
|
|
39587
39596
|
}
|
|
39588
39597
|
/**
|
|
39589
39598
|
* Generate a `ts.TypeNode` that references the given node as a type.
|
|
@@ -45489,7 +45498,7 @@ class TemplateTypeCheckerImpl {
|
|
|
45489
45498
|
}
|
|
45490
45499
|
emit(kind, refTo, inContext) {
|
|
45491
45500
|
const emittedRef = this.refEmitter.emit(refTo, inContext.getSourceFile());
|
|
45492
|
-
if (emittedRef.kind ===
|
|
45501
|
+
if (emittedRef.kind === exports.ReferenceEmitKind.Failed) {
|
|
45493
45502
|
return null;
|
|
45494
45503
|
}
|
|
45495
45504
|
const emitted = emittedRef.expression;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-rc.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
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-
|
|
14
|
-
var program = require('./program-
|
|
13
|
+
var checker = require('./checker-cd95ebda.js');
|
|
14
|
+
var program = require('./program-8f30df93.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 = { ...
|
|
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
|
-
/**
|
|
414
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
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-
|
|
10
|
+
var checker = require('./checker-cd95ebda.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.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
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-
|
|
14
|
-
var checker = require('./checker-
|
|
13
|
+
var compiler_host = require('./compiler_host-40e8d55f.js');
|
|
14
|
+
var checker = require('./checker-cd95ebda.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.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
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-
|
|
14
|
+
var compiler_host = require('./compiler_host-40e8d55f.js');
|
|
15
15
|
var ts = require('typescript');
|
|
16
16
|
var imports = require('./imports-4ac08251.js');
|
|
17
17
|
require('@angular-devkit/core');
|
|
18
|
-
require('./checker-
|
|
18
|
+
require('./checker-cd95ebda.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.
|
|
3
|
+
* @license Angular v19.0.0-rc.2
|
|
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-
|
|
13
|
+
var compiler_host = require('./compiler_host-40e8d55f.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-
|
|
18
|
+
require('./checker-cd95ebda.js');
|
|
19
19
|
require('os');
|
|
20
20
|
require('fs');
|
|
21
21
|
require('module');
|