Skip to content

Commit dc6d946

Browse files
committed
fix(@angular-devkit/schematics): remove lazy imports in node tasks
This commit replaces lazy imports with static imports in the node tasks of `@angular-devkit/schematics`. This change fixes an issue where migrations could fail during an update process if the package layout changes on disk (e.g. due to `npm` hoisting changes) after the main module is loaded but before the lazy chunks are requested. By using static imports, we ensure all necessary code is loaded upfront. Closes #31974 (cherry picked from commit 98e10fa)
1 parent 6e25bde commit dc6d946

File tree

1 file changed

+6
-7
lines changed
  • packages/angular_devkit/schematics/tasks/node

1 file changed

+6
-7
lines changed

packages/angular_devkit/schematics/tasks/node/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@
77
*/
88

99
import { TaskExecutor, TaskExecutorFactory } from '../../src';
10+
import NodePackageExecutor from '../package-manager/executor';
1011
import { NodePackageName, NodePackageTaskFactoryOptions } from '../package-manager/options';
12+
import RepositoryInitializerExecutor from '../repo-init/executor';
1113
import {
1214
RepositoryInitializerName,
1315
RepositoryInitializerTaskFactoryOptions,
1416
} from '../repo-init/options';
17+
import RunSchematicExecutor from '../run-schematic/executor';
1518
import { RunSchematicName } from '../run-schematic/options';
1619

1720
export class BuiltinTaskExecutor {
1821
static readonly NodePackage: TaskExecutorFactory<NodePackageTaskFactoryOptions> = {
1922
name: NodePackageName,
20-
create: (options) =>
21-
import('../package-manager/executor').then((mod) => mod.default(options)) as Promise<
22-
TaskExecutor<{}>
23-
>,
23+
create: async (options) => NodePackageExecutor(options) as TaskExecutor<{}>,
2424
};
2525
static readonly RepositoryInitializer: TaskExecutorFactory<RepositoryInitializerTaskFactoryOptions> =
2626
{
2727
name: RepositoryInitializerName,
28-
create: (options) => import('../repo-init/executor').then((mod) => mod.default(options)),
28+
create: async (options) => RepositoryInitializerExecutor(options) as TaskExecutor<{}>,
2929
};
3030
static readonly RunSchematic: TaskExecutorFactory<{}> = {
3131
name: RunSchematicName,
32-
create: () =>
33-
import('../run-schematic/executor').then((mod) => mod.default()) as Promise<TaskExecutor<{}>>,
32+
create: async () => RunSchematicExecutor() as TaskExecutor<{}>,
3433
};
3534
}

0 commit comments

Comments
 (0)