Skip to content

Commit 415c02e

Browse files
josephperrottdgp1130
authored andcommitted
refactor: move builtin module imports to use node: prefix imports
(cherry picked from commit 33ed6e8)
1 parent c54b999 commit 415c02e

File tree

200 files changed

+311
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+311
-312
lines changed

goldens/public-api/angular_devkit/core/node/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```ts
66

7-
import * as fs from 'fs';
7+
import * as fs from 'node:fs';
88
import { Observable } from 'rxjs';
99

1010
// @public

goldens/public-api/angular_devkit/schematics/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { PathFragment } from '@angular-devkit/core';
1313
import { schema } from '@angular-devkit/core';
1414
import { strings } from '@angular-devkit/core';
1515
import { Subject } from 'rxjs';
16-
import { Url } from 'url';
16+
import { Url } from 'node:url';
1717
import { virtualFs } from '@angular-devkit/core';
1818

1919
// @public (undocumented)

goldens/public-api/angular_devkit/schematics/testing/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { logging } from '@angular-devkit/core';
99
import { Observable } from 'rxjs';
1010
import { Path } from '@angular-devkit/core';
1111
import { PathFragment } from '@angular-devkit/core';
12-
import { Url } from 'url';
12+
import { Url } from 'node:url';
1313

1414
// @public (undocumented)
1515
export class SchematicTestRunner {

goldens/public-api/angular_devkit/schematics/tools/index.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Path } from '@angular-devkit/core';
1313
import { PathFragment } from '@angular-devkit/core';
1414
import { schema } from '@angular-devkit/core';
1515
import { Subject } from 'rxjs';
16-
import { Url } from 'url';
16+
import { Url } from 'node:url';
1717
import { virtualFs } from '@angular-devkit/core';
1818

1919
// @public (undocumented)

modules/testing/builder/src/jasmine-helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { BuilderHandlerFn } from '@angular-devkit/architect';
1010
import { json } from '@angular-devkit/core';
11-
import { readFileSync } from 'fs';
11+
import { readFileSync } from 'node:fs';
1212
import { concatMap, count, firstValueFrom, take, timeout } from 'rxjs';
1313
import { BuilderHarness, BuilderHarnessExecutionResult } from './builder-harness';
1414
import { host } from './test-utils';

packages/angular/build/src/builders/dev-server/tests/behavior/build_translation_watch_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* eslint-disable max-len */
1010
import { concatMap, count, take, timeout } from 'rxjs';
11-
import { URL } from 'url';
11+
import { URL } from 'node:url';
1212
import { executeDevServer } from '../../index';
1313
import { describeServeBuilder } from '../jasmine-helpers';
1414
import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup';

packages/angular/build/src/builders/dev-server/tests/behavior/serve-live-reload-proxies_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
/* eslint-disable import/no-extraneous-dependencies */
1010
import { tags } from '@angular-devkit/core';
11-
import { createServer } from 'http';
11+
import { createServer } from 'node:http';
1212
import { createProxyServer } from 'http-proxy';
13-
import { AddressInfo } from 'net';
13+
import { AddressInfo } from 'node:net';
1414
import puppeteer, { Browser, Page } from 'puppeteer';
1515
import { count, debounceTime, finalize, switchMap, take, timeout } from 'rxjs';
1616
import { executeDevServer } from '../../index';

packages/angular/build/src/builders/dev-server/tests/options/port_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { URL } from 'url';
9+
import { URL } from 'node:url';
1010
import { executeDevServer } from '../../index';
1111
import { executeOnceAndFetch } from '../execute-fetch';
1212
import { describeServeBuilder } from '../jasmine-helpers';

packages/angular/build/src/builders/dev-server/tests/options/serve-path_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { URL } from 'url';
9+
import { URL } from 'node:url';
1010
import { executeDevServer } from '../../index';
1111
import { executeOnceAndFetch } from '../execute-fetch';
1212
import { describeServeBuilder } from '../jasmine-helpers';

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ export function createCompilerPlugin(
516516
const replacement = pluginOptions.fileReplacements?.[path.normalize(args.path)];
517517
if (replacement) {
518518
return {
519-
contents: await import('fs/promises').then(({ readFile }) =>
519+
contents: await import('node:fs/promises').then(({ readFile }) =>
520520
readFile(path.normalize(replacement)),
521521
),
522522
loader: 'json' as const,

packages/angular/build/src/utils/error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import assert from 'assert';
9+
import assert from 'node:assert';
1010

1111
export function assertIsError(value: unknown): asserts value is Error & { code?: string } {
1212
const isError =

packages/angular/build/src/utils/load-translations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import type { Diagnostics } from '@angular/localize/tools';
10-
import { createHash } from 'crypto';
11-
import * as fs from 'fs';
10+
import { createHash } from 'node:crypto';
11+
import * as fs from 'node:fs';
1212
import { loadEsmModule } from './load-esm';
1313

1414
export type TranslationLoader = (path: string) => {

packages/angular/build/src/utils/normalize-asset-patterns.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { statSync } from 'fs';
109
import assert from 'node:assert';
11-
import * as path from 'path';
10+
import { statSync } from 'node:fs';
11+
import * as path from 'node:path';
1212
import { AssetPattern, AssetPatternClass } from '../builders/application/schema';
1313

1414
export class MissingAssetSourceRootException extends Error {

packages/angular/build/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import assert from 'node:assert';
1010
import { randomUUID } from 'node:crypto';
1111
import { join } from 'node:path';
12-
import { pathToFileURL } from 'node:url';
13-
import { fileURLToPath } from 'url';
12+
import { fileURLToPath, pathToFileURL } from 'node:url';
1413
import { JavaScriptTransformer } from '../../../tools/esbuild/javascript-transformer';
1514

1615
/**

packages/angular/build/src/utils/server-rendering/render-worker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { workerData } from 'worker_threads';
9+
import { workerData } from 'node:worker_threads';
1010
import type { OutputMode } from '../../builders/application/schema';
1111
import type { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
1212
import { patchFetchToLoadInMemoryAssets } from './fetch-patch';

packages/angular/build/src/utils/server-rendering/routes-extractor-worker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { workerData } from 'worker_threads';
9+
import { workerData } from 'node:worker_threads';
1010
import { OutputMode } from '../../builders/application/schema';
1111
import { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
1212
import { patchFetchToLoadInMemoryAssets } from './fetch-patch';

packages/angular/build/src/utils/service-worker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
import type { Config, Filesystem } from '@angular/service-worker/config';
10-
import * as crypto from 'crypto';
10+
import * as crypto from 'node:crypto';
1111
import { existsSync, constants as fsConstants, promises as fsPromises } from 'node:fs';
12-
import * as path from 'path';
12+
import * as path from 'node:path';
1313
import { BuildOutputFile, BuildOutputFileType } from '../tools/esbuild/bundler-context';
1414
import { BuildOutputAsset } from '../tools/esbuild/bundler-execution-result';
1515
import { assertIsError } from './error';

packages/angular/cli/lib/init.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import 'symbol-observable';
1010
// symbol polyfill must go first
11-
import { promises as fs } from 'fs';
12-
import { createRequire } from 'module';
13-
import * as path from 'path';
11+
import { promises as fs } from 'node:fs';
12+
import { createRequire } from 'node:module';
13+
import * as path from 'node:path';
1414
import { SemVer, major } from 'semver';
1515
import { colors } from '../src/utilities/color';
1616
import { isWarningEnabled } from '../src/utilities/config';

packages/angular/cli/src/analytics/analytics-collector.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { randomUUID } from 'crypto';
10-
import * as https from 'https';
11-
import * as os from 'os';
12-
import * as querystring from 'querystring';
9+
import { randomUUID } from 'node:crypto';
10+
import * as https from 'node:https';
11+
import * as os from 'node:os';
12+
import * as querystring from 'node:querystring';
1313
import * as semver from 'semver';
1414
import type { CommandContext } from '../command-builder/command-module';
1515
import { ngDebug } from '../utilities/environment-options';

packages/angular/cli/src/analytics/analytics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { json, tags } from '@angular-devkit/core';
10-
import { randomUUID } from 'crypto';
10+
import { randomUUID } from 'node:crypto';
1111
import type { CommandContext } from '../command-builder/command-module';
1212
import { colors } from '../utilities/color';
1313
import { getWorkspace } from '../utilities/config';

packages/angular/cli/src/command-builder/command-module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { logging, schema } from '@angular-devkit/core';
10-
import { readFileSync } from 'fs';
11-
import * as path from 'path';
10+
import { readFileSync } from 'node:fs';
11+
import * as path from 'node:path';
1212
import yargs, {
1313
ArgumentsCamelCase,
1414
Argv,

packages/angular/cli/src/command-builder/schematics-command-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
FileSystemSchematicDescription,
1414
NodeWorkflow,
1515
} from '@angular-devkit/schematics/tools';
16-
import { relative } from 'path';
16+
import { relative } from 'node:path';
1717
import { Argv } from 'yargs';
1818
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
1919
import { EventCustomDimension } from '../analytics/analytics-parameters';

packages/angular/cli/src/command-builder/utilities/schematic-engine-host.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88

99
import { RuleFactory, SchematicsException, Tree } from '@angular-devkit/schematics';
1010
import { FileSystemCollectionDesc, NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
11-
import { readFileSync } from 'fs';
1211
import { parse as parseJson } from 'jsonc-parser';
13-
import { Module, createRequire } from 'module';
14-
import { dirname, resolve } from 'path';
15-
import { Script } from 'vm';
12+
import { readFileSync } from 'node:fs';
13+
import { Module, createRequire } from 'node:module';
14+
import { dirname, resolve } from 'node:path';
15+
import { Script } from 'node:vm';
1616
import { assertIsError } from '../../utilities/error';
1717

1818
/**

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
1010
import { Listr, color, figures } from 'listr2';
11-
import { createRequire } from 'module';
1211
import assert from 'node:assert';
12+
import { createRequire } from 'node:module';
13+
import { dirname, join } from 'node:path';
1314
import npa from 'npm-package-arg';
14-
import { dirname, join } from 'path';
1515
import { Range, compare, intersects, prerelease, satisfies, valid } from 'semver';
1616
import { Argv } from 'yargs';
1717
import { PackageManager } from '../../../lib/config/workspace-schema';

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join } from 'path';
9+
import { join } from 'node:path';
1010
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
1111
import { CommandModuleImplementation } from '../../command-builder/command-module';
1212
import { RootCommands } from '../command-config';

packages/angular/cli/src/commands/cache/clean/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { promises as fs } from 'fs';
9+
import { promises as fs } from 'node:fs';
1010
import { Argv } from 'yargs';
1111
import {
1212
CommandModule,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join } from 'path';
9+
import { join } from 'node:path';
1010
import { Argv } from 'yargs';
1111
import {
1212
CommandModule,

packages/angular/cli/src/commands/cache/info/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { tags } from '@angular-devkit/core';
10-
import { promises as fs } from 'fs';
11-
import { join } from 'path';
10+
import { promises as fs } from 'node:fs';
11+
import { join } from 'node:path';
1212
import { Argv } from 'yargs';
1313
import {
1414
CommandModule,

packages/angular/cli/src/commands/cache/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { isJsonObject } from '@angular-devkit/core';
10-
import { resolve } from 'path';
10+
import { resolve } from 'node:path';
1111
import { Cache, Environment } from '../../../lib/config/workspace-schema';
1212
import { AngularWorkspace } from '../../utilities/config';
1313

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join } from 'path';
9+
import { join } from 'node:path';
1010
import yargs, { Argv } from 'yargs';
1111
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
1212
import { addCommandModuleToYargs } from '../../command-builder/utilities/command';

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { JsonValue } from '@angular-devkit/core';
10-
import { randomUUID } from 'crypto';
11-
import { join } from 'path';
10+
import { randomUUID } from 'node:crypto';
11+
import { join } from 'node:path';
1212
import { Argv } from 'yargs';
1313
import {
1414
CommandModule,

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join } from 'path';
9+
import { join } from 'node:path';
1010
import { MissingTargetChoice } from '../../command-builder/architect-base-command-module';
1111
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
1212
import { CommandModuleImplementation } from '../../command-builder/command-module';

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { Target } from '@angular-devkit/architect';
10-
import { join } from 'path';
10+
import { join } from 'node:path';
1111
import { Argv } from 'yargs';
1212
import { ArchitectBaseCommandModule } from '../../command-builder/architect-base-command-module';
1313
import {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join } from 'path';
9+
import { join } from 'node:path';
1010
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
1111
import { CommandModuleImplementation } from '../../command-builder/command-module';
1212
import { RootCommands } from '../command-config';

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import { Listr } from 'listr2';
1616
import { SpawnSyncReturns, execSync, spawnSync } from 'node:child_process';
1717
import { existsSync, promises as fs } from 'node:fs';
1818
import { createRequire } from 'node:module';
19+
import * as path from 'node:path';
20+
import { join, resolve } from 'node:path';
1921
import npa from 'npm-package-arg';
2022
import pickManifest from 'npm-pick-manifest';
21-
import * as path from 'path';
22-
import { join, resolve } from 'path';
2323
import * as semver from 'semver';
2424
import { Argv } from 'yargs';
2525
import { PackageManager } from '../../../lib/config/workspace-schema';

packages/angular/cli/src/utilities/completion.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*/
88

99
import { json, logging } from '@angular-devkit/core';
10-
import { execFile } from 'child_process';
11-
import { promises as fs } from 'fs';
12-
import * as path from 'path';
13-
import { env } from 'process';
10+
import { execFile } from 'node:child_process';
11+
import { promises as fs } from 'node:fs';
12+
import * as path from 'node:path';
13+
import { env } from 'node:process';
1414
import { colors } from '../utilities/color';
1515
import { getWorkspace } from '../utilities/config';
1616
import { forceAutocomplete } from '../utilities/environment-options';

packages/angular/cli/src/utilities/config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88

99
import { json, workspaces } from '@angular-devkit/core';
10-
import { existsSync, promises as fs } from 'fs';
11-
import * as os from 'os';
12-
import * as path from 'path';
10+
import { existsSync, promises as fs } from 'node:fs';
11+
import * as os from 'node:os';
12+
import * as path from 'node:path';
1313
import { PackageManager } from '../../lib/config/workspace-schema';
1414
import { findUp } from './find-up';
1515
import { JSONFile, readAndParseJson } from './json-file';

packages/angular/cli/src/utilities/error.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import assert from 'assert';
9+
import assert from 'node:assert';
1010

1111
export function assertIsError(value: unknown): asserts value is Error & { code?: string } {
1212
const isError =

0 commit comments

Comments
 (0)