Skip to content

Commit

Permalink
refactor: move builtin module imports to use node: prefix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
josephperrott authored and dgp1130 committed Feb 14, 2025
1 parent c0c1670 commit 33ed6e8
Show file tree
Hide file tree
Showing 200 changed files with 311 additions and 312 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```ts

import * as fs from 'fs';
import * as fs from 'node:fs';
import { Observable } from 'rxjs';

// @public
Expand Down
2 changes: 1 addition & 1 deletion goldens/public-api/angular_devkit/schematics/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { PathFragment } from '@angular-devkit/core';
import { schema } from '@angular-devkit/core';
import { strings } from '@angular-devkit/core';
import { Subject } from 'rxjs';
import { Url } from 'url';
import { Url } from 'node:url';
import { virtualFs } from '@angular-devkit/core';

// @public (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { logging } from '@angular-devkit/core';
import { Observable } from 'rxjs';
import { Path } from '@angular-devkit/core';
import { PathFragment } from '@angular-devkit/core';
import { Url } from 'url';
import { Url } from 'node:url';

// @public (undocumented)
export class SchematicTestRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Path } from '@angular-devkit/core';
import { PathFragment } from '@angular-devkit/core';
import { schema } from '@angular-devkit/core';
import { Subject } from 'rxjs';
import { Url } from 'url';
import { Url } from 'node:url';
import { virtualFs } from '@angular-devkit/core';

// @public (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion modules/testing/builder/src/jasmine-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { BuilderHandlerFn } from '@angular-devkit/architect';
import { json } from '@angular-devkit/core';
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';
import { concatMap, count, firstValueFrom, take, timeout } from 'rxjs';
import { BuilderHarness, BuilderHarnessExecutionResult } from './builder-harness';
import { host } from './test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* eslint-disable max-len */
import { concatMap, count, take, timeout } from 'rxjs';
import { URL } from 'url';
import { URL } from 'node:url';
import { executeDevServer } from '../../index';
import { describeServeBuilder } from '../jasmine-helpers';
import { BASE_OPTIONS, BUILD_TIMEOUT, DEV_SERVER_BUILDER_INFO } from '../setup';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

/* eslint-disable import/no-extraneous-dependencies */
import { tags } from '@angular-devkit/core';
import { createServer } from 'http';
import { createServer } from 'node:http';
import { createProxyServer } from 'http-proxy';
import { AddressInfo } from 'net';
import { AddressInfo } from 'node:net';
import puppeteer, { Browser, Page } from 'puppeteer';
import { count, debounceTime, finalize, switchMap, take, timeout } from 'rxjs';
import { executeDevServer } from '../../index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { URL } from 'url';
import { URL } from 'node:url';
import { executeDevServer } from '../../index';
import { executeOnceAndFetch } from '../execute-fetch';
import { describeServeBuilder } from '../jasmine-helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { URL } from 'url';
import { URL } from 'node:url';
import { executeDevServer } from '../../index';
import { executeOnceAndFetch } from '../execute-fetch';
import { describeServeBuilder } from '../jasmine-helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export function createCompilerPlugin(
const replacement = pluginOptions.fileReplacements?.[path.normalize(args.path)];
if (replacement) {
return {
contents: await import('fs/promises').then(({ readFile }) =>
contents: await import('node:fs/promises').then(({ readFile }) =>
readFile(path.normalize(replacement)),
),
loader: 'json' as const,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/build/src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import assert from 'assert';
import assert from 'node:assert';

export function assertIsError(value: unknown): asserts value is Error & { code?: string } {
const isError =
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/build/src/utils/load-translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

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

export type TranslationLoader = (path: string) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/build/src/utils/normalize-asset-patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { statSync } from 'fs';
import assert from 'node:assert';
import * as path from 'path';
import { statSync } from 'node:fs';
import * as path from 'node:path';
import { AssetPattern, AssetPatternClass } from '../builders/application/schema';

export class MissingAssetSourceRootException extends Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import assert from 'node:assert';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { fileURLToPath } from 'url';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { JavaScriptTransformer } from '../../../tools/esbuild/javascript-transformer';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { workerData } from 'worker_threads';
import { workerData } from 'node:worker_threads';
import type { OutputMode } from '../../builders/application/schema';
import type { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
import { patchFetchToLoadInMemoryAssets } from './fetch-patch';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { workerData } from 'worker_threads';
import { workerData } from 'node:worker_threads';
import { OutputMode } from '../../builders/application/schema';
import { ESMInMemoryFileLoaderWorkerData } from './esm-in-memory-loader/loader-hooks';
import { patchFetchToLoadInMemoryAssets } from './fetch-patch';
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/build/src/utils/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import type { Config, Filesystem } from '@angular/service-worker/config';
import * as crypto from 'crypto';
import * as crypto from 'node:crypto';
import { existsSync, constants as fsConstants, promises as fsPromises } from 'node:fs';
import * as path from 'path';
import * as path from 'node:path';
import { BuildOutputFile, BuildOutputFileType } from '../tools/esbuild/bundler-context';
import { BuildOutputAsset } from '../tools/esbuild/bundler-execution-result';
import { assertIsError } from './error';
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import 'symbol-observable';
// symbol polyfill must go first
import { promises as fs } from 'fs';
import { createRequire } from 'module';
import * as path from 'path';
import { promises as fs } from 'node:fs';
import { createRequire } from 'node:module';
import * as path from 'node:path';
import { SemVer, major } from 'semver';
import { colors } from '../src/utilities/color';
import { isWarningEnabled } from '../src/utilities/config';
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/cli/src/analytics/analytics-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { randomUUID } from 'crypto';
import * as https from 'https';
import * as os from 'os';
import * as querystring from 'querystring';
import { randomUUID } from 'node:crypto';
import * as https from 'node:https';
import * as os from 'node:os';
import * as querystring from 'node:querystring';
import * as semver from 'semver';
import type { CommandContext } from '../command-builder/command-module';
import { ngDebug } from '../utilities/environment-options';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { json, tags } from '@angular-devkit/core';
import { randomUUID } from 'crypto';
import { randomUUID } from 'node:crypto';
import type { CommandContext } from '../command-builder/command-module';
import { colors } from '../utilities/color';
import { getWorkspace } from '../utilities/config';
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/command-builder/command-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { logging, schema } from '@angular-devkit/core';
import { readFileSync } from 'fs';
import * as path from 'path';
import { readFileSync } from 'node:fs';
import * as path from 'node:path';
import yargs, {
ArgumentsCamelCase,
Argv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
FileSystemSchematicDescription,
NodeWorkflow,
} from '@angular-devkit/schematics/tools';
import { relative } from 'path';
import { relative } from 'node:path';
import { Argv } from 'yargs';
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
import { EventCustomDimension } from '../analytics/analytics-parameters';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import { RuleFactory, SchematicsException, Tree } from '@angular-devkit/schematics';
import { FileSystemCollectionDesc, NodeModulesEngineHost } from '@angular-devkit/schematics/tools';
import { readFileSync } from 'fs';
import { parse as parseJson } from 'jsonc-parser';
import { Module, createRequire } from 'module';
import { dirname, resolve } from 'path';
import { Script } from 'vm';
import { readFileSync } from 'node:fs';
import { Module, createRequire } from 'node:module';
import { dirname, resolve } from 'node:path';
import { Script } from 'node:vm';
import { assertIsError } from '../../utilities/error';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/commands/add/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
import { Listr, color, figures } from 'listr2';
import { createRequire } from 'module';
import assert from 'node:assert';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import npa from 'npm-package-arg';
import { dirname, join } from 'path';
import { Range, compare, intersects, prerelease, satisfies, valid } from 'semver';
import { Argv } from 'yargs';
import { PackageManager } from '../../../lib/config/workspace-schema';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { join } from 'path';
import { join } from 'node:path';
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
import { CommandModuleImplementation } from '../../command-builder/command-module';
import { RootCommands } from '../command-config';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/cache/clean/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { promises as fs } from 'fs';
import { promises as fs } from 'node:fs';
import { Argv } from 'yargs';
import {
CommandModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/cache/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { join } from 'path';
import { join } from 'node:path';
import { Argv } from 'yargs';
import {
CommandModule,
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/commands/cache/info/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { tags } from '@angular-devkit/core';
import { promises as fs } from 'fs';
import { join } from 'path';
import { promises as fs } from 'node:fs';
import { join } from 'node:path';
import { Argv } from 'yargs';
import {
CommandModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/cache/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

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

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/completion/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { join } from 'path';
import { join } from 'node:path';
import yargs, { Argv } from 'yargs';
import { CommandModule, CommandModuleImplementation } from '../../command-builder/command-module';
import { addCommandModuleToYargs } from '../../command-builder/utilities/command';
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/commands/config/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import { JsonValue } from '@angular-devkit/core';
import { randomUUID } from 'crypto';
import { join } from 'path';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
import { Argv } from 'yargs';
import {
CommandModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/lint/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { join } from 'path';
import { join } from 'node:path';
import { MissingTargetChoice } from '../../command-builder/architect-base-command-module';
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
import { CommandModuleImplementation } from '../../command-builder/command-module';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/run/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Target } from '@angular-devkit/architect';
import { join } from 'path';
import { join } from 'node:path';
import { Argv } from 'yargs';
import { ArchitectBaseCommandModule } from '../../command-builder/architect-base-command-module';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/test/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { join } from 'path';
import { join } from 'node:path';
import { ArchitectCommandModule } from '../../command-builder/architect-command-module';
import { CommandModuleImplementation } from '../../command-builder/command-module';
import { RootCommands } from '../command-config';
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { Listr } from 'listr2';
import { SpawnSyncReturns, execSync, spawnSync } from 'node:child_process';
import { existsSync, promises as fs } from 'node:fs';
import { createRequire } from 'node:module';
import * as path from 'node:path';
import { join, resolve } from 'node:path';
import npa from 'npm-package-arg';
import pickManifest from 'npm-pick-manifest';
import * as path from 'path';
import { join, resolve } from 'path';
import * as semver from 'semver';
import { Argv } from 'yargs';
import { PackageManager } from '../../../lib/config/workspace-schema';
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/cli/src/utilities/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/

import { json, logging } from '@angular-devkit/core';
import { execFile } from 'child_process';
import { promises as fs } from 'fs';
import * as path from 'path';
import { env } from 'process';
import { execFile } from 'node:child_process';
import { promises as fs } from 'node:fs';
import * as path from 'node:path';
import { env } from 'node:process';
import { colors } from '../utilities/color';
import { getWorkspace } from '../utilities/config';
import { forceAutocomplete } from '../utilities/environment-options';
Expand Down
6 changes: 3 additions & 3 deletions packages/angular/cli/src/utilities/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

import { json, workspaces } from '@angular-devkit/core';
import { existsSync, promises as fs } from 'fs';
import * as os from 'os';
import * as path from 'path';
import { existsSync, promises as fs } from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import { PackageManager } from '../../lib/config/workspace-schema';
import { findUp } from './find-up';
import { JSONFile, readAndParseJson } from './json-file';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/utilities/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import assert from 'assert';
import assert from 'node:assert';

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

0 comments on commit 33ed6e8

Please sign in to comment.