Skip to content

Commit 12c6cb9

Browse files
committed
refactor: use bare imports for Node.js built-ins
Replace all "node:" prefixed imports with bare imports across src/ for better compatibility and consistency. Changed: - "node:fs" → "fs" - "node:path" → "path" - "node:crypto" → "crypto" - "node:os" → "os" - "node:async_hooks" → "async_hooks" - "node:child_process" → "child_process" - "node:events" → "events" - "node:http" → "http" - "node:readline" → "readline" - "node:stream" → "stream" - "node:tty" → "tty" Affected files (17): - src/constants/platform.ts - src/cover/code.ts - src/dlx-binary.ts - src/dlx-package.ts - src/dlx.ts - src/download-lock.ts - src/env/rewire.ts - src/fs.ts - src/git.ts - src/http-request.ts - src/ipc.ts - src/packages/isolation.ts - src/paths.ts - src/process-lock.ts - src/spinner.ts - src/stdio/mask.ts - src/stdio/stdout.ts Benefits: - Consistent import style across the codebase - Better compatibility with older bundlers - Matches existing patterns in getFs(), getPath() helpers
1 parent 299b2ca commit 12c6cb9

File tree

17 files changed

+28
-28
lines changed

17 files changed

+28
-28
lines changed

src/constants/platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Platform detection and OS-specific constants.
33
*/
44

5-
import { platform } from 'node:os'
5+
import { platform } from 'os'
66

77
// Platform detection.
88
const _platform = platform()

src/cover/code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @fileoverview Code coverage utilities for parsing v8 coverage data.
33
*/
44

5-
import { promises as fs } from 'node:fs'
5+
import { promises as fs } from 'fs'
66

77
import { readJson } from '../fs'
88
import { isObjectObject } from '../objects'

src/dlx-binary.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @fileoverview DLX binary execution utilities for Socket ecosystem. */
22

3-
import { createHash } from 'node:crypto'
4-
import os from 'node:os'
5-
import path from 'node:path'
3+
import { createHash } from 'crypto'
4+
import os from 'os'
5+
import path from 'path'
66

77
import { WIN32 } from '#constants/platform'
88

src/dlx-package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* - dlxPackage() combines both for convenience
3131
*/
3232

33-
import path from 'node:path'
33+
import path from 'path'
3434

3535
import { WIN32 } from './constants/platform'
3636
import { getPacoteCachePath } from './constants/packages'

src/dlx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @fileoverview DLX (execute package) utilities for Socket ecosystem shared installations. */
22

3-
import { createHash } from 'node:crypto'
3+
import { createHash } from 'crypto'
44

55
import { readDirNamesSync, safeDelete, safeMkdir, safeMkdirSync } from './fs'
66
import { normalizePath } from './path'

src/download-lock.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* `downloadWithLock()` from this module.
1010
*/
1111

12-
import { existsSync } from 'node:fs'
13-
import { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises'
14-
import { dirname, join } from 'node:path'
12+
import { existsSync } from 'fs'
13+
import { mkdir, readFile, rm, stat, writeFile } from 'fs/promises'
14+
import { dirname, join } from 'path'
1515
import type { HttpDownloadOptions, HttpDownloadResult } from './http-request'
1616
import { httpDownload } from './http-request'
1717

src/env/rewire.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* - Thread-safe for concurrent test execution
1010
*/
1111

12-
import { AsyncLocalStorage } from 'node:async_hooks'
12+
import { AsyncLocalStorage } from 'async_hooks'
1313

1414
type EnvOverrides = Map<string, string | undefined>
1515

src/fs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Provides enhanced fs operations, glob matching, and directory traversal functions.
44
*/
55

6-
import type { Abortable } from 'node:events'
6+
import type { Abortable } from 'events'
77
import type {
88
Dirent,
99
MakeDirectoryOptions,
@@ -12,7 +12,7 @@ import type {
1212
PathLike,
1313
StatSyncOptions,
1414
WriteFileOptions,
15-
} from 'node:fs'
15+
} from 'fs'
1616

1717
import { getAbortSignal } from '#constants/process'
1818

src/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'node:path'
1+
import path from 'path'
22

33
import { WIN32 } from '#constants/platform'
44
import { debugNs } from './debug'

src/http-request.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
* - Zero dependencies on external HTTP libraries.
1515
*/
1616

17-
import { createWriteStream } from 'node:fs'
17+
import { createWriteStream } from 'fs'
1818

19-
import type { IncomingMessage } from 'node:http'
19+
import type { IncomingMessage } from 'http'
2020

2121
let _http: typeof import('http') | undefined
2222
let _https: typeof import('https') | undefined

0 commit comments

Comments
 (0)