Skip to content

Commit cf00471

Browse files
clydinfilipesilva
authored andcommitted
fix(@angular/cli): support update migration packages with no entry points
Some schematic only packages may not have entry points defined (`main`/`exports`). These type of packages will now be correctly resolved when attempting to locate update migrations. Fixes #20032 (cherry picked from commit 3d99468)
1 parent 8629da4 commit cf00471

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/angular/cli/commands/update-impl.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,21 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
665665
`Resolving migration package '${migration.package}' from '${this.context.root}'...`,
666666
);
667667
try {
668-
packagePath = require.resolve(migration.package, { paths: [this.context.root] });
668+
try {
669+
packagePath = path.dirname(
670+
// This may fail if the `package.json` is not exported as an entry point
671+
require.resolve(path.join(migration.package, 'package.json'), {
672+
paths: [this.context.root],
673+
}),
674+
);
675+
} catch (e) {
676+
if (e.code === 'MODULE_NOT_FOUND') {
677+
// Fallback to trying to resolve the package's main entry point
678+
packagePath = require.resolve(migration.package, { paths: [this.context.root] });
679+
} else {
680+
throw e;
681+
}
682+
}
669683
} catch (e) {
670684
if (e.code === 'MODULE_NOT_FOUND') {
671685
logVerbose(e.toString());

0 commit comments

Comments
 (0)