Skip to content

Commit 0f8d529

Browse files
authored
build: prepare framework peer dependency and migration collection for v14 (#24492)
* build: prepare framework peer dependency and migration collection for v14 Prepares the framework peer dependency and migration collection for v14, ensuring the release checks will not fail when we get closer to publishing the first RC. * build: fix chalk runtime errors due to esmodule interop The chalk usages in the `tools/` folder seems to fail at runtime given the `esModuleInterop` flag being enabled for the tools folder. We need to switch the namespace imports to default imports to work with the interop, and to follow the TS language-service recommendation (which actually proposes switching these imports to `import c from 'chalk'`) We should likely turn on the esmoduleinterop flag for the scripts folder as well to have consistent imports, and to prepare for future ESM consumption as the ecosystem moves forward. * build: enable esmoduleinterop option in `scripts` and `.ng-dev` Similar to the `/tsconfig.json` and the `tools/tsconfig.json`, we should enable the `esModuleInterop` from TypeScript in the `scripts/` directory. This is necessary to ensure that scripts part of both compilations. e.g. when a file in `scripts/` imports from `tools/` are compatible without needing two coordinated compilations (using e.g TS project references..). In general enabling the interop means more consistency in the repo. Then only remaining exception are the schematics which we can clean-up in the future when we ship them as ES modules.
1 parent 6c7cc8a commit 0f8d529

32 files changed

+73
-33
lines changed

.ng-dev/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"strict": true,
44
"target": "es2015",
55
"module": "commonjs",
6+
"esModuleInterop": true,
67
"noEmit": true,
78
"skipLibCheck": true,
89
"types": []

packages.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Each individual package uses a placeholder for the version of Angular to ensure they're
22
# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate
33
# version for the placeholders.
4-
ANGULAR_PACKAGE_VERSION = "^13.0.0 || ^14.0.0"
4+
ANGULAR_PACKAGE_VERSION = "^14.0.0-0 || ^15.0.0"
55
MDC_PACKAGE_VERSION = "14.0.0-canary.9736ddce9.0"
66
TSLIB_PACKAGE_VERSION = "^2.3.0"
77
RXJS_PACKAGE_VERSION = "^6.5.3 || ^7.4.0"

scripts/breaking-changes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join, relative} from 'path';
22
import {readFileSync} from 'fs';
3-
import * as chalk from 'chalk';
4-
import * as ts from 'typescript';
3+
import chalk from 'chalk';
4+
import ts from 'typescript';
55
import * as tsutils from 'tsutils';
66

77
const projectRoot = process.cwd();

scripts/check-mdc-exports.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join} from 'path';
22
import {readdirSync, existsSync} from 'fs';
3-
import * as ts from 'typescript';
4-
import * as chalk from 'chalk';
3+
import ts from 'typescript';
4+
import chalk from 'chalk';
55
import {config} from './check-mdc-exports-config';
66

77
// Script which ensures that a particular MDC package exports all of the same symbols as its

scripts/check-mdc-tests.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {readdirSync, readFileSync} from 'fs';
22
import {join, basename} from 'path';
33
import {sync as glob} from 'glob';
4-
import * as chalk from 'chalk';
5-
import * as ts from 'typescript';
4+
import chalk from 'chalk';
5+
import ts from 'typescript';
66
import {config} from './check-mdc-tests-config';
77

88
const srcDirectory = join(__dirname, '../src');

scripts/check-package-externals.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* be passed to this script to ensure that the list is up-to-date.
99
*/
1010

11-
import * as chalk from 'chalk';
11+
import chalk from 'chalk';
1212
import {readFileSync} from 'fs';
13-
import * as minimatch from 'minimatch';
13+
import minimatch from 'minimatch';
1414
import {join, relative} from 'path';
15-
import * as ts from 'typescript';
15+
import ts from 'typescript';
1616

1717
const projectRoot = join(__dirname, '../');
1818
const args = process.argv.slice(2);

scripts/ownerslint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as chalk from 'chalk';
1+
import chalk from 'chalk';
22
import {readdirSync, readFileSync, statSync} from 'fs';
33
import {IMinimatch, Minimatch} from 'minimatch';
44
import {join} from 'path';

scripts/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"strict": true,
99
"noEmit": true,
1010
"skipLibCheck": true,
11-
"downlevelIteration": true
11+
"downlevelIteration": true,
12+
"esModuleInterop": true
1213
},
1314
// The `firebase-functions` folder has its own `package.json` and does
1415
// not pass type-checking. This excludes it from being checked.

src/cdk/schematics/migration.json

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"description": "Updates the Angular CDK to v13",
4242
"factory": "./ng-update/index#updateToV13"
4343
},
44+
"migration-v14": {
45+
"version": "14.0.0-0",
46+
"description": "Updates the Angular CDK to v14",
47+
"factory": "./ng-update/index#updateToV14"
48+
},
4449
"ng-post-update": {
4550
"description": "Prints out results after ng-update.",
4651
"factory": "./ng-update/index#postUpdate",

src/cdk/schematics/ng-update/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ export function updateToV13(): Rule {
9494
);
9595
}
9696

97+
/** Entry point for the migration schematics with target of Angular CDK 14.0.0 */
98+
export function updateToV14(): Rule {
99+
return createMigrationSchematicRule(
100+
TargetVersion.V14,
101+
cdkMigrations,
102+
cdkUpgradeData,
103+
onMigrationComplete,
104+
);
105+
}
106+
97107
/** Function that will be called when the migration completed. */
98108
function onMigrationComplete(
99109
context: SchematicContext,

src/cdk/schematics/update-tool/target-version.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export enum TargetVersion {
1818
V11 = 'version 11',
1919
V12 = 'version 12',
2020
V13 = 'version 13',
21+
V14 = 'version 14',
2122
}
2223

2324
/**

src/material/schematics/migration.json

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
"description": "Updates Angular Material to v13",
4242
"factory": "./ng-update/index#updateToV13"
4343
},
44+
"migration-v14": {
45+
"version": "14.0.0-0",
46+
"description": "Updates the Angular Material to v14",
47+
"factory": "./ng-update/index#updateToV14"
48+
},
4449
"ng-post-update": {
4550
"description": "Prints out results after ng-update.",
4651
"factory": "./ng-update/index#postUpdate",

src/material/schematics/ng-update/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ export function updateToV13(): Rule {
116116
);
117117
}
118118

119+
/** Entry point for the migration schematics with target of Angular Material v14 */
120+
export function updateToV14(): Rule {
121+
return createMigrationSchematicRule(
122+
TargetVersion.V14,
123+
materialMigrations,
124+
materialUpgradeData,
125+
onMigrationComplete,
126+
);
127+
}
128+
119129
/** Function that will be called when the migration completed. */
120130
function onMigrationComplete(
121131
context: SchematicContext,

tools/dgeni/common/class-inheritance.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';
44
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
55
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
66
import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc';
7-
import * as ts from 'typescript';
87
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
98

9+
import ts from 'typescript';
10+
1011
/** Type describing class like documents which have been created through inheritance. */
1112
export type InheritanceCreatedClassLikeDoc = ClassLikeExportDoc & {
1213
_inheritanceCreated?: true;

tools/dgeni/processors/async-functions.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {DocCollection, Processor} from 'dgeni';
22
import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';
33
import {FunctionExportDoc} from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc';
44
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
5-
import * as ts from 'typescript';
5+
6+
import ts from 'typescript';
67

78
/** Type describing a function-like API doc (i.e. a function, or a class method member). */
89
type FunctionLikeDoc = (FunctionExportDoc | MethodMemberDoc) & {

tools/dgeni/processors/categorizer.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import ts from 'typescript';
2+
13
import {DocCollection, Processor} from 'dgeni';
24
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
35
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
4-
import * as ts from 'typescript';
56
import {getInheritedDocsOfClass} from '../common/class-inheritance';
67
import {
78
decorateDeprecatedDoc,

tools/dgeni/processors/merge-inherited-properties.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {DocCollection, Processor} from 'dgeni';
22
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
33
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
44
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
5-
import * as ts from 'typescript';
5+
import ts from 'typescript';
66
import {getInheritedDocsOfClass} from '../common/class-inheritance';
77

88
/**

tools/dgeni/processors/resolve-inherited-docs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {DocCollection, Document, Processor} from 'dgeni';
22
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
3-
import * as ts from 'typescript';
3+
import ts from 'typescript';
44
import {getInheritedDocsOfClass, isInheritanceCreatedDoc} from '../common/class-inheritance';
55
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
66
import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';

tools/example-module/parse-example-file.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22

33
interface ParsedMetadata {
44
isPrimary: boolean;

tools/example-module/parse-example-module-file.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as ts from 'typescript';
21
import * as fs from 'fs';
32

3+
import ts from 'typescript';
4+
45
/** Parses an example module file by returning all module names within the given file. */
56
export function parseExampleModuleFile(filePath: string) {
67
const fileContent = fs.readFileSync(filePath, 'utf8');

tools/release-checks/check-framework-peer-dependency.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {error} from '@angular/dev-infra-private/ng-dev/utils/console';
33
import {SemVer} from 'semver';
44
import {join} from 'path';
55
import {existsSync, readFileSync} from 'fs';
6-
import * as chalk from 'chalk';
6+
import chalk from 'chalk';
77

88
/** Path to the Bazel file that configures the release output. */
99
const bzlConfigPath = join(__dirname, '../../packages.bzl');

tools/release-checks/check-migration-collections.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {error} from '@angular/dev-infra-private/ng-dev/utils/console';
22
import {dirname, join} from 'path';
3-
import * as chalk from 'chalk';
3+
import chalk from 'chalk';
44
import {releasePackages} from '../../.ng-dev/release';
55
import {readFileSync} from 'fs';
6-
import * as semver from 'semver';
6+
import semver from 'semver';
77

88
/** Path to the directory containing all package sources. */
99
const packagesDir = join(__dirname, '../../src');

tools/release-checks/npm-package-output/check-package.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {error} from '@angular/dev-infra-private/ng-dev/utils/console';
2-
import * as chalk from 'chalk';
2+
import chalk from 'chalk';
33
import {existsSync} from 'fs';
44
import {sync as glob} from 'glob';
55
import {basename, dirname, join} from 'path';

tools/release-checks/npm-package-output/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {SemVer} from 'semver';
22
import {checkReleasePackage} from './check-package';
33
import {BuiltPackage} from '@angular/dev-infra-private/ng-dev/release/config';
44
import {error} from '@angular/dev-infra-private/ng-dev/utils/console';
5-
import * as chalk from 'chalk';
5+
import chalk from 'chalk';
66

77
/** Asserts that the given built packages are valid for public consumption. */
88
export async function assertValidNpmPackageOutput(

tools/release-checks/npm-package-output/output-validations.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {existsSync, readFileSync} from 'fs';
22
import {sync as glob} from 'glob';
33
import {basename, dirname, isAbsolute, join} from 'path';
44
import * as semver from 'semver';
5-
import * as ts from 'typescript';
5+
6+
import ts from 'typescript';
67

78
/** RegExp that matches Angular component inline styles that contain a sourcemap reference. */
89
const inlineStylesSourcemapRegex = /styles: ?\[["'].*sourceMappingURL=.*["']/;

tools/tslint-rules/lightweightTokensRule.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import ts from 'typescript';
12
import minimatch from 'minimatch';
3+
24
import * as path from 'path';
35
import * as Lint from 'tslint';
4-
import * as ts from 'typescript';
56

67
/** Arguments this rule supports. */
78
type RuleArguments = [

tools/tslint-rules/memberNamingRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as tsutils from 'tsutils';
33
import * as Lint from 'tslint';
44

tools/tslint-rules/ngOnChangesPropertyAccessRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as Lint from 'tslint';
33

44
/**

tools/tslint-rules/noCoercionMembersRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as Lint from 'tslint';
33

44
/** Lint rule that disallows coercion class members. */

tools/tslint-rules/noCrossEntryPointRelativeImportsRule.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {existsSync} from 'fs';
1+
import ts from 'typescript';
22
import minimatch from 'minimatch';
3+
4+
import {existsSync} from 'fs';
35
import {dirname, join, normalize, relative, resolve} from 'path';
46
import * as Lint from 'tslint';
5-
import * as ts from 'typescript';
67

78
const BUILD_BAZEL_FILE = 'BUILD.bazel';
89

tools/tslint-rules/requireLicenseBannerRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
2-
import * as ts from 'typescript';
32
import * as Lint from 'tslint';
43
import minimatch from 'minimatch';
4+
import ts from 'typescript';
55

66
/** License banner that is placed at the top of every public TypeScript file. */
77
const licenseBanner = `/**

tools/tslint-rules/validateDecoratorsRule.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
2-
import * as ts from 'typescript';
32
import * as Lint from 'tslint';
3+
import ts from 'typescript';
44
import minimatch from 'minimatch';
55

66
/**

0 commit comments

Comments
 (0)