mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
chore: use node:
prefix for built-in modules (#4384)
This commit is contained in:
parent
4e1d38e5fe
commit
e0b2a3bfe4
@ -12,6 +12,7 @@
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"rules": {
|
||||
"unicorn/prefer-node-protocol": "error",
|
||||
"no-console": "off",
|
||||
"vue/multi-word-component-names": "off",
|
||||
"vue/one-component-per-file": "off",
|
||||
|
@ -193,7 +193,7 @@ Imagine a directory structure like this:
|
||||
Then in `awesome-ui/nuxt.js` you can use the `components:dirs` hook:
|
||||
|
||||
```js
|
||||
import { join } from 'path'
|
||||
import { join } from 'node:path'
|
||||
import { defineNuxtModule } from '@nuxt/kit'
|
||||
|
||||
export default defineNuxtModule({
|
||||
|
@ -45,7 +45,7 @@ export default myPreset
|
||||
Then in your `nuxt.config` you can specify that Nitro should use your custom preset:
|
||||
|
||||
```ts [nuxt.config.js|ts]
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
export default {
|
||||
nitro: {
|
||||
|
@ -56,7 +56,7 @@ app.listen(3000)
|
||||
### Node server
|
||||
|
||||
```js
|
||||
import { createServer } from 'http'
|
||||
import { createServer } from 'node:http'
|
||||
import handler from './.output/server'
|
||||
|
||||
const server = createServer(handler)
|
||||
|
@ -263,9 +263,9 @@ const { __dirname, __filename, require } = createCommonJS(import.meta.url)
|
||||
```
|
||||
|
||||
```js [manual]
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname } from 'path'
|
||||
import { createRequire } from 'module'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname } from 'node:path'
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
import { withDocus } from '@docus/app'
|
||||
|
||||
export default withDocus({
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { readFile, writeFile, mkdir } from 'fs/promises'
|
||||
import { dirname } from 'path'
|
||||
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
||||
import { dirname } from 'node:path'
|
||||
import type { Schema } from 'untyped'
|
||||
import { resolve } from 'pathe'
|
||||
import { upperFirst } from 'scule'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { setup, $fetch, isDev } from '@nuxt/test-utils'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import ignore from 'ignore'
|
||||
import { join, relative } from 'pathe'
|
||||
import { tryUseNuxt } from './context'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pathToFileURL } from 'url'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { join, normalize } from 'pathe'
|
||||
import { interopDefault } from 'mlly'
|
||||
import jiti from 'jiti'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import lodashTemplate from 'lodash.template'
|
||||
import hash from 'hash-sum'
|
||||
import { camelCase } from 'scule'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import defu from 'defu'
|
||||
import { applyDefaults } from 'untyped'
|
||||
import { dirname } from 'pathe'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { promises as fsp, existsSync } from 'fs'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { promises as fsp, existsSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { basename, dirname, resolve, join, normalize, isAbsolute } from 'pathe'
|
||||
import { globby } from 'globby'
|
||||
import { tryUseNuxt, useNuxt } from './context'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync } from 'fs'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { basename, parse, resolve } from 'pathe'
|
||||
import hash from 'hash-sum'
|
||||
import type { NuxtTemplate } from '@nuxt/schema'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync, promises as fsp } from 'fs'
|
||||
import { existsSync, promises as fsp } from 'node:fs'
|
||||
import { resolve, dirname } from 'pathe'
|
||||
import consola from 'consola'
|
||||
import { loadKit } from '../utils/kit'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import { join, resolve } from 'pathe'
|
||||
import { createApp, lazyHandle } from 'h3'
|
||||
import { listen } from 'listhen'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import os from 'os'
|
||||
import { existsSync, readFileSync } from 'fs'
|
||||
import { createRequire } from 'module'
|
||||
import os from 'node:os'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { createRequire } from 'node:module'
|
||||
import { resolve } from 'pathe'
|
||||
import jiti from 'jiti'
|
||||
import destr from 'destr'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync, readdirSync } from 'fs'
|
||||
import { existsSync, readdirSync } from 'node:fs'
|
||||
import createTiged from 'tiged'
|
||||
import { relative, resolve } from 'pathe'
|
||||
import superb from 'superb'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { existsSync, promises as fsp } from 'fs'
|
||||
import { dirname, relative } from 'path'
|
||||
import { existsSync, promises as fsp } from 'node:fs'
|
||||
import { dirname, relative } from 'node:path'
|
||||
import { execa } from 'execa'
|
||||
import { loadDotenv } from 'c12'
|
||||
import { resolve } from 'pathe'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { promises as fsp, existsSync } from 'fs'
|
||||
import { execSync } from 'node:child_process'
|
||||
import { promises as fsp, existsSync } from 'node:fs'
|
||||
import consola from 'consola'
|
||||
import { resolve } from 'pathe'
|
||||
import { resolveModule } from '../utils/cjs'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createRequire } from 'module'
|
||||
import { pathToFileURL } from 'url'
|
||||
import { createRequire } from 'node:module'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { normalize, dirname } from 'pathe'
|
||||
|
||||
export function getModulePaths (paths?: string | string[]): string[] {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import { dirname } from 'pathe'
|
||||
|
||||
// Check if a file exists
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { execSync } from 'child_process'
|
||||
import { existsSync } from 'fs'
|
||||
import { execSync } from 'node:child_process'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { resolve } from 'pathe'
|
||||
import { findup } from './fs'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import { isAbsolute, join, relative, resolve } from 'pathe'
|
||||
import { Nuxt, TSReference } from '@nuxt/schema'
|
||||
import defu from 'defu'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http'
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http'
|
||||
import type { App } from 'vue'
|
||||
import type { Component } from '@vue/runtime-core'
|
||||
import mockContext from 'unenv/runtime/mock/proxy'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp, existsSync } from 'fs'
|
||||
import { promises as fsp, existsSync } from 'node:fs'
|
||||
import { parse as parsePath } from 'pathe'
|
||||
import { findExports } from 'mlly'
|
||||
import { camelCase } from 'scule'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pathToFileURL } from 'url'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { createUnplugin } from 'unplugin'
|
||||
import { parseQuery, parseURL } from 'ufo'
|
||||
import { Unimport } from 'unimport'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pathToFileURL } from 'url'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { createUnplugin } from 'unplugin'
|
||||
import { parseQuery, parseURL } from 'ufo'
|
||||
import { Component } from '@nuxt/schema'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { statSync } from 'fs'
|
||||
import { statSync } from 'node:fs'
|
||||
import { resolve, basename } from 'pathe'
|
||||
import { defineNuxtModule, resolveAlias, addVitePlugin, addWebpackPlugin, addTemplate, addPluginTemplate } from '@nuxt/kit'
|
||||
import type { Component, ComponentsDir, ComponentsOptions } from '@nuxt/schema'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import { dirname, resolve, basename, extname } from 'pathe'
|
||||
import defu from 'defu'
|
||||
import { kebabCase } from 'scule'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync } from 'fs'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { resolve, join } from 'pathe'
|
||||
import { createNitro, createDevServer, build, prepare, copyPublicAssets, writeTypes, scanHandlers, prerender } from 'nitropack'
|
||||
import type { NitroEventHandler, NitroDevEventHandler, NitroConfig } from 'nitropack'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createRequire } from 'module'
|
||||
import { createRequire } from 'node:module'
|
||||
import { createUnplugin } from 'unplugin'
|
||||
import { logger } from '@nuxt/kit'
|
||||
import { isAbsolute, relative, resolve } from 'pathe'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, resolve } from 'pathe'
|
||||
|
||||
let _distDir = dirname(fileURLToPath(import.meta.url))
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { pathToFileURL } from 'url'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { createUnplugin } from 'unplugin'
|
||||
import { parseQuery, parseURL, withQuery } from 'ufo'
|
||||
import { findStaticImports, findExports } from 'mlly'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { existsSync } from 'fs'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { defineNuxtModule, addTemplate, addPlugin, addVitePlugin, addWebpackPlugin, findPath } from '@nuxt/kit'
|
||||
import { resolve } from 'pathe'
|
||||
import { genDynamicImport, genString, genArrayFromRaw, genImport, genObjectFromRawEntries } from 'knitwork'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { readFileSync } from 'fs'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { expect, describe, it } from 'vitest'
|
||||
import { join } from 'pathe'
|
||||
import { createCommonJS, findExports } from 'mlly'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
import { ComponentsDir } from '@nuxt/schema'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
import { scanComponents } from '../src/components/scan'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { resolve, join } from 'pathe'
|
||||
import { existsSync, readdirSync } from 'fs'
|
||||
import { existsSync, readdirSync } from 'node:fs'
|
||||
import defu from 'defu'
|
||||
|
||||
export default {
|
||||
|
@ -670,9 +670,9 @@ export default {
|
||||
* object in `nuxt.config` (as below).
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import fs from 'fs'
|
||||
* import path from 'path'
|
||||
* ```js'node:fs'
|
||||
* import fs from 'node:fs'
|
||||
* import path from 'node:path'
|
||||
* export default {
|
||||
* hooks: {
|
||||
* build: {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'http'
|
||||
import type { Server as HttpsServer } from 'https'
|
||||
import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'node:http'
|
||||
import type { Server as HttpsServer } from 'node:https'
|
||||
import type { Compiler, Configuration, Stats } from 'webpack'
|
||||
import type { TSConfig } from 'pkg-types'
|
||||
import type { ModuleContainer } from './module'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
import defu from 'defu'
|
||||
import type { TestContext, TestOptions, TestRunner } from './types'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { existsSync, promises as fsp } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
import { existsSync, promises as fsp } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import * as _kit from '@nuxt/kit'
|
||||
import { useTestContext } from './context'
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
import { execa } from 'execa'
|
||||
import { getRandomPort, waitForPort } from 'get-port-please'
|
||||
import { fetch as _fetch, $fetch as _$fetch, FetchOptions } from 'ohmyfetch'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { pathToFileURL } from 'url'
|
||||
import { existsSync } from 'fs'
|
||||
import { builtinModules } from 'module'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { builtinModules } from 'node:module'
|
||||
import { resolve } from 'pathe'
|
||||
import * as vite from 'vite'
|
||||
import { ExternalsOptions, isExternal as _isExternal, ExternalsDefaults } from 'externality'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { dirname, resolve } from 'pathe'
|
||||
|
||||
export const distDir = dirname(fileURLToPath(import.meta.url))
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createHash } from 'crypto'
|
||||
import { promises as fsp, readdirSync, statSync } from 'fs'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { promises as fsp, readdirSync, statSync } from 'node:fs'
|
||||
import { join } from 'pathe'
|
||||
|
||||
export function uniq<T> (arr: T[]): T[] {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import querystring from 'querystring'
|
||||
import querystring from 'node:querystring'
|
||||
import { resolve } from 'pathe'
|
||||
import webpack from 'webpack'
|
||||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http'
|
||||
import type { IncomingMessage, ServerResponse } from 'node:http'
|
||||
import pify from 'pify'
|
||||
import webpack from 'webpack'
|
||||
import webpackDevMiddleware, { API } from 'webpack-dev-middleware'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { execSync } from 'child_process'
|
||||
import { promises as fsp } from 'node:fs'
|
||||
import { execSync } from 'node:child_process'
|
||||
import { resolve } from 'pathe'
|
||||
import { globby } from 'globby'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { promises as fs } from 'fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { promises as fs } from 'node:fs'
|
||||
import { resolve } from 'pathe'
|
||||
|
||||
async function run () {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { fileURLToPath } from 'url'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
// import { isWindows } from 'std-env'
|
||||
import { setup, fetch, $fetch, startServer } from '@nuxt/test-utils'
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { ServerResponse } from 'http'
|
||||
import type { ServerResponse } from 'node:http'
|
||||
|
||||
export default (_, res: ServerResponse, next) => {
|
||||
res.setHeader('injected-header', 'foo')
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { resolve } from 'path'
|
||||
import { resolve } from 'node:path'
|
||||
import { defineConfig } from 'vite'
|
||||
import { isWindows } from 'std-env'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user