Skip to content

Commit 64574d1

Browse files
author
Angular Builds
committed
1e137ca feat(@schematics/angular): add migration to update moduleResolution to bundler
1 parent 25eefa3 commit 64574d1

File tree

6 files changed

+73
-7
lines changed

6 files changed

+73
-7
lines changed

migrations/migration-collection.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"factory": "./replace-provide-server-routing/migration",
1111
"description": "Migrate 'provideServerRendering' to use 'withRoutes' and remove 'provideServerRouting' from '@angular/ssr'."
1212
},
13+
"update-module-resolution": {
14+
"version": "20.0.0",
15+
"factory": "./update-module-resolution/migration",
16+
"description": "Update 'moduleResolution' to 'bundler' in TypeScript configurations. You can read more about this, here: https://www.typescriptlang.org/tsconfig/#moduleResolution"
17+
},
1318
"use-application-builder": {
1419
"version": "20.0.0",
1520
"factory": "./use-application-builder/migration",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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 { Rule } from '@angular-devkit/schematics';
9+
export default function (): Rule;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.default = default_1;
11+
const json_file_1 = require("../../utility/json-file");
12+
const workspace_1 = require("../../utility/workspace");
13+
function default_1() {
14+
return async (host) => {
15+
const uniqueTsConfigs = new Set();
16+
if (host.exists('tsconfig.json')) {
17+
// Workspace level tsconfig
18+
uniqueTsConfigs.add('tsconfig.json');
19+
}
20+
const workspace = await (0, workspace_1.getWorkspace)(host);
21+
for (const [, target] of (0, workspace_1.allWorkspaceTargets)(workspace)) {
22+
for (const [, opt] of (0, workspace_1.allTargetOptions)(target)) {
23+
if (typeof opt?.tsConfig === 'string') {
24+
uniqueTsConfigs.add(opt.tsConfig);
25+
}
26+
}
27+
}
28+
for (const tsConfig of uniqueTsConfigs) {
29+
if (host.exists(tsConfig)) {
30+
updateModuleResolution(host, tsConfig);
31+
}
32+
}
33+
};
34+
}
35+
function updateModuleResolution(host, tsConfigPath) {
36+
const json = new json_file_1.JSONFile(host, tsConfigPath);
37+
const jsonPath = ['compilerOptions'];
38+
const compilerOptions = json.get(jsonPath);
39+
if (compilerOptions && typeof compilerOptions === 'object') {
40+
const { moduleResolution, module } = compilerOptions;
41+
if (typeof moduleResolution !== 'string' || moduleResolution.toLowerCase() === 'bundler') {
42+
return;
43+
}
44+
if (typeof module === 'string' && module.toLowerCase() === 'preserve') {
45+
return;
46+
}
47+
json.modify(jsonPath, {
48+
...compilerOptions,
49+
'moduleResolution': 'bundler',
50+
});
51+
}
52+
}

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@schematics/angular",
3-
"version": "20.0.0-next.3+sha-296873c",
3+
"version": "20.0.0-next.3+sha-1e137ca",
44
"description": "Schematics specific to Angular",
55
"homepage": "https://github.com/angular/angular-cli",
66
"keywords": [
@@ -22,8 +22,8 @@
2222
},
2323
"schematics": "./collection.json",
2424
"dependencies": {
25-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#296873c",
26-
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#296873c",
25+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#1e137ca",
26+
"@angular-devkit/schematics": "github:angular/angular-devkit-schematics-builds#1e137ca",
2727
"jsonc-parser": "3.3.1"
2828
},
2929
"repository": {

uniqueId

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Wed Apr 02 2025 13:33:57 GMT+0000 (Coordinated Universal Time)
1+
Wed Apr 02 2025 14:27:24 GMT+0000 (Coordinated Universal Time)

utility/latest-versions.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports.latestVersions = {
1616
// As Angular CLI works with same minor versions of Angular Framework, a tilde match for the current
1717
Angular: '^20.0.0-next.0',
1818
NgPackagr: '^20.0.0-next.0',
19-
DevkitBuildAngular: '^20.0.0-next.3+sha-296873c',
20-
AngularBuild: '^20.0.0-next.3+sha-296873c',
21-
AngularSSR: '^20.0.0-next.3+sha-296873c',
19+
DevkitBuildAngular: '^20.0.0-next.3+sha-1e137ca',
20+
AngularBuild: '^20.0.0-next.3+sha-1e137ca',
21+
AngularSSR: '^20.0.0-next.3+sha-1e137ca',
2222
};

0 commit comments

Comments
 (0)