chore: use node: prefix for built-in modules (#4384)

This commit is contained in:
Daniel Roe 2022-04-15 16:19:05 +01:00 committed by GitHub
parent 4e1d38e5fe
commit e0b2a3bfe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 72 additions and 71 deletions

View File

@ -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",

View File

@ -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({

View File

@ -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: {

View File

@ -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)

View File

@ -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)

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'node:path'
import { withDocus } from '@docus/app'
export default withDocus({

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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[] {

View File

@ -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

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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))

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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 {

View File

@ -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: {

View File

@ -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'

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'node:path'
import defu from 'defu'
import type { TestContext, TestOptions, TestRunner } from './types'

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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))

View File

@ -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[] {

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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 () {

View File

@ -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'

View File

@ -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')

View File

@ -1,4 +1,4 @@
import { resolve } from 'path'
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import { isWindows } from 'std-env'