Skip to content

Commit 1860222

Browse files
committed
refactor(@angular/cli): use static import for Module in update command
Replace the inline dynamic require('node:module') call with a top-level static import of Module in UpdateCommandModule. Also update the _pathCache check to use the 'in' operator for safer property access and cleaner type narrowing.
1 parent 1627ccb commit 1860222

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • packages/angular/cli/src/commands/update

packages/angular/cli/src/commands/update/cli.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
1010
import { Listr } from 'listr2';
1111
import { existsSync, promises as fs } from 'node:fs';
12-
import { createRequire } from 'node:module';
12+
import { Module, createRequire } from 'node:module';
1313
import * as path from 'node:path';
1414
import npa from 'npm-package-arg';
1515
import { Argv } from 'yargs';
@@ -607,8 +607,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
607607
await tasks.run();
608608
// Clear Node's module resolution path cache to prevent stale lookups
609609
// when resolving migration package paths.
610-
const Module = require('node:module');
611-
if (Module && Module._pathCache) {
610+
if ('_pathCache' in Module) {
612611
Module._pathCache = Object.create(null);
613612
}
614613
} catch (e) {

0 commit comments

Comments
 (0)