diff --git a/docs/modules/cli-builders.md b/docs/modules/cli-builders.md index 949e000b..1159b47f 100644 --- a/docs/modules/cli-builders.md +++ b/docs/modules/cli-builders.md @@ -9,6 +9,7 @@ description: Modern alternatives to packages for building CLI applications [`sade`](https://github.com/lukeed/sade) is a small but powerful tool for building CLI applications for Node.js ```ts +import process from 'node:process' import sade from 'sade' const prog = sade('my-cli') diff --git a/docs/modules/dotenv.md b/docs/modules/dotenv.md index cda27969..c2c1c804 100644 --- a/docs/modules/dotenv.md +++ b/docs/modules/dotenv.md @@ -12,6 +12,7 @@ It throws if the file is missing. Defaults to `.env` in the current working dire ```ts import dotenv from 'dotenv' // [!code --] +import process from 'node:process' // [!code ++] dotenv.config({ path: '.env' }) // [!code --] process.loadEnvFile('.env') // [!code ++] diff --git a/docs/modules/fast-glob.md b/docs/modules/fast-glob.md index 870a714d..376bb2d3 100644 --- a/docs/modules/fast-glob.md +++ b/docs/modules/fast-glob.md @@ -15,6 +15,7 @@ Example: ```ts import fg from 'fast-glob' // [!code --] import { glob } from 'tinyglobby' // [!code ++] +import process from 'node:process' const files = await fg('**/*.ts', { // [!code --] const files = await glob('**/*.ts', { // [!code ++] diff --git a/docs/modules/get-stream.md b/docs/modules/get-stream.md index e1809a1c..91b910da 100644 --- a/docs/modules/get-stream.md +++ b/docs/modules/get-stream.md @@ -9,6 +9,8 @@ description: Modern alternatives to the get-stream package You can convert a stream to a string by using `Buffer.from` and a `for await`: ```ts +import { Buffer } from 'node:buffer' + async function streamToString(stream) { const chunks = [] for await (const chunk of stream) { @@ -41,6 +43,8 @@ async function streamToArray(stream) { You can convert a stream to a `Buffer` using [`Array.fromAsync`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync) with a mapper: ```ts +import { Buffer } from 'node:buffer' + async function streamToBuffer(stream) { const chunks = await Array.fromAsync(stream, (chunk) => Buffer.from(chunk)) return Buffer.concat(chunks) diff --git a/docs/modules/globby.md b/docs/modules/globby.md index 950319ad..3001d4b0 100644 --- a/docs/modules/globby.md +++ b/docs/modules/globby.md @@ -14,6 +14,7 @@ If you don’t need `.gitignore` handling, prefer [`tinyglobby`](https://github. ```ts import { execSync } from 'node:child_process' +import process from 'node:process' import { glob, escapePath } from 'tinyglobby' async function globWithGitignore(patterns, options = {}) { diff --git a/docs/modules/is-path-in-cwd.md b/docs/modules/is-path-in-cwd.md index 24d7ff41..0e38962a 100644 --- a/docs/modules/is-path-in-cwd.md +++ b/docs/modules/is-path-in-cwd.md @@ -8,6 +8,7 @@ description: Native alternatives to the is-path-in-cwd package for checking whet ```ts import path from 'node:path' +import process from 'node:process' const isPathInside = (childPath, parentPath) => { const relation = path.relative(parentPath, childPath) diff --git a/docs/modules/node-telegram-bot-api.md b/docs/modules/node-telegram-bot-api.md index a4546ff0..200f7a47 100644 --- a/docs/modules/node-telegram-bot-api.md +++ b/docs/modules/node-telegram-bot-api.md @@ -11,6 +11,7 @@ description: Modern alternatives to the node-telegram-bot-api package Example: ```ts +import process from 'node:process' import { Bot } from 'grammy' const bot = new Bot(process.env.TOKEN) diff --git a/docs/modules/parseargs.md b/docs/modules/parseargs.md index c3a942d4..d9ca943d 100644 --- a/docs/modules/parseargs.md +++ b/docs/modules/parseargs.md @@ -11,6 +11,7 @@ description: Modern alternatives to CLI argument parsing packages using Node.js Example: ```ts +import process from 'node:process' import { parseArgs } from 'node:util' const { values, positionals } = parseArgs({ @@ -33,6 +34,7 @@ const { values, positionals } = parseArgs({ Example: ```ts +import process from 'node:process' import mri from 'mri' const options = mri(process.argv.slice(2), { diff --git a/docs/modules/resolve.md b/docs/modules/resolve.md index b1203382..24f36ec3 100644 --- a/docs/modules/resolve.md +++ b/docs/modules/resolve.md @@ -29,6 +29,7 @@ const path = resolveModulePath('my-module') [`oxc-resolver`](https://github.com/oxc-project/oxc-resolver) ```ts +import process from 'node:process' import { ResolverFactory } from 'oxc-resolver' const resolver = new ResolverFactory() diff --git a/docs/modules/stream-buffers.md b/docs/modules/stream-buffers.md index 35e065ff..516a5324 100644 --- a/docs/modules/stream-buffers.md +++ b/docs/modules/stream-buffers.md @@ -43,6 +43,7 @@ Push data over time example: ```ts import streamBuffers from 'stream-buffers' // [!code --] +import { Buffer } from 'node:buffer' import { Readable } from 'node:stream' // [!code ++] const rs = new streamBuffers.ReadableStreamBuffer() // [!code --] @@ -62,6 +63,7 @@ Control chunk size and frequency example: ```ts +import { Buffer } from 'node:buffer' import streamBuffers from 'stream-buffers' // [!code --] import { Readable } from 'node:stream' // [!code ++] import { setTimeout } from 'node:timers/promises' // [!code ++] diff --git a/manifests/preferred.json b/manifests/preferred.json index d2a7ce40..e8671446 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -3666,6 +3666,10 @@ "process.loadEnvFile": { "id": "process.loadEnvFile", "type": "native", + "nodeFeatureId": { + "moduleName": "node:process", + "exportName": "loadEnvFile" + }, "url": {"type": "node", "id": "api/process.html#processloadenvfilepath"} }, "react-helmet-async": {