mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 04:26:01 +08:00
fix(@angular/cli): avoid redirecting @angular/core in Angular migrations
Files should not redirect `@angular/core` and instead use the direct dependency of the `@schematics/angular` package. This allows old major version migrations to continue to function even though the latest major version may have breaking changes in `@angular/core`.
This commit is contained in:
parent
3a89358d33
commit
4a5ca162c3
@ -129,10 +129,21 @@ function wrap(
|
|||||||
// Provide compatibility modules for older versions of @angular/cdk
|
// Provide compatibility modules for older versions of @angular/cdk
|
||||||
return legacyModules[id];
|
return legacyModules[id];
|
||||||
} else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
|
} else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
|
||||||
// Resolve from inside the `@angular/cli` project
|
// Files should not redirect `@angular/core` and instead use the direct
|
||||||
const packagePath = require.resolve(id);
|
// dependency if available. This allows old major version migrations to continue to function
|
||||||
|
// even though the latest major version may have breaking changes in `@angular/core`.
|
||||||
|
if (id.startsWith('@angular-devkit/core')) {
|
||||||
|
try {
|
||||||
|
return schematicRequire(id);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hostRequire(packagePath);
|
// Resolve from inside the `@angular/cli` project
|
||||||
|
return hostRequire(id);
|
||||||
} else if (id.startsWith('.') || id.startsWith('@angular/cdk')) {
|
} else if (id.startsWith('.') || id.startsWith('@angular/cdk')) {
|
||||||
// Wrap relative files inside the schematic collection
|
// Wrap relative files inside the schematic collection
|
||||||
// Also wrap `@angular/cdk`, it contains helper utilities that import core schematic packages
|
// Also wrap `@angular/cdk`, it contains helper utilities that import core schematic packages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user