Skip to content

Commit 3169493

Browse files
clydinfilipesilva
authored andcommitted
refactor(@angular/cli): convert Node.js module builtin require to import statement
Now that the TypeScript `esModuleInterop` option is enabled, the Node.js `module` builtin can be used with an import statement.
1 parent a2cecf0 commit 3169493

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/angular/cli/models/schematic-engine-host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { RuleFactory, SchematicsException, Tree } from '@angular-devkit/schemati
1010
import { NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
1111
import { readFileSync } from 'fs';
1212
import { parse as parseJson } from 'jsonc-parser';
13+
import nodeModule from 'module';
1314
import { dirname, resolve } from 'path';
1415
import { Script } from 'vm';
1516

@@ -120,8 +121,7 @@ function wrap(
120121
moduleCache: Map<string, unknown>,
121122
exportName?: string,
122123
): () => unknown {
123-
const { createRequire } = require('module');
124-
const scopedRequire = createRequire(schematicFile);
124+
const scopedRequire = nodeModule.createRequire(schematicFile);
125125

126126
const customRequire = function (id: string) {
127127
if (legacyModules[id]) {

0 commit comments

Comments
 (0)