From 649691662cc6ef4e112b80a5e2b12de71cc19d42 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Tue, 24 May 2022 15:15:46 +0200 Subject: [PATCH 1/7] chore: use node prefix --- packages/create-vite/__tests__/cli.spec.ts | 2 +- packages/create-vite/index.js | 6 +++--- packages/plugin-legacy/src/index.ts | 8 ++++---- packages/plugin-react/src/fast-refresh.ts | 6 +++--- packages/plugin-react/src/index.ts | 2 +- packages/plugin-vue-jsx/src/index.ts | 4 ++-- packages/plugin-vue/src/compiler.ts | 2 +- packages/plugin-vue/src/index.ts | 2 +- packages/plugin-vue/src/main.ts | 2 +- packages/plugin-vue/src/template.ts | 2 +- packages/plugin-vue/src/utils/descriptorCache.ts | 6 +++--- packages/vite/bin/vite.js | 2 +- packages/vite/rollup.config.ts | 10 +++++----- packages/vite/scripts/patchTypes.ts | 6 +++--- packages/vite/src/node/__tests__/build.spec.ts | 4 ++-- .../vite/src/node/__tests__/plugins/css.spec.ts | 4 ++-- .../plugins/dynamicImportVar/parse.test.ts | 4 ++-- .../__tests__/plugins/importGlob/fixture.test.ts | 6 +++--- packages/vite/src/node/build.ts | 4 ++-- packages/vite/src/node/cli.ts | 2 +- packages/vite/src/node/config.ts | 10 +++++----- packages/vite/src/node/constants.ts | 4 ++-- packages/vite/src/node/http.ts | 8 ++++---- packages/vite/src/node/logger.ts | 4 ++-- .../vite/src/node/optimizer/esbuildDepPlugin.ts | 4 ++-- packages/vite/src/node/optimizer/index.ts | 6 +++--- packages/vite/src/node/optimizer/scan.ts | 6 +++--- packages/vite/src/node/packages.ts | 4 ++-- packages/vite/src/node/plugins/asset.ts | 6 +++--- .../vite/src/node/plugins/assetImportMetaUrl.ts | 2 +- .../vite/src/node/plugins/clientInjections.ts | 2 +- packages/vite/src/node/plugins/css.ts | 6 +++--- packages/vite/src/node/plugins/dataUri.ts | 2 +- .../vite/src/node/plugins/dynamicImportVars.ts | 2 +- packages/vite/src/node/plugins/esbuild.ts | 2 +- packages/vite/src/node/plugins/html.ts | 2 +- packages/vite/src/node/plugins/importAnalysis.ts | 6 +++--- .../vite/src/node/plugins/importAnalysisBuild.ts | 2 +- packages/vite/src/node/plugins/importMetaGlob.ts | 2 +- packages/vite/src/node/plugins/loadFallback.ts | 2 +- packages/vite/src/node/plugins/manifest.ts | 2 +- packages/vite/src/node/plugins/optimizedDeps.ts | 2 +- packages/vite/src/node/plugins/reporter.ts | 6 +++--- packages/vite/src/node/plugins/resolve.ts | 4 ++-- packages/vite/src/node/plugins/ssrRequireHook.ts | 2 +- packages/vite/src/node/plugins/terser.ts | 4 ++-- packages/vite/src/node/plugins/worker.ts | 2 +- .../vite/src/node/plugins/workerImportMetaUrl.ts | 2 +- packages/vite/src/node/preview.ts | 4 ++-- .../node/server/__tests__/search-root.spec.ts | 4 ++-- packages/vite/src/node/server/hmr.ts | 6 +++--- packages/vite/src/node/server/index.ts | 10 +++++----- .../src/node/server/middlewares/compression.ts | 2 +- .../src/node/server/middlewares/indexHtml.ts | 4 ++-- .../vite/src/node/server/middlewares/proxy.ts | 2 +- .../src/node/server/middlewares/spaFallback.ts | 4 ++-- .../vite/src/node/server/middlewares/static.ts | 4 ++-- .../vite/src/node/server/middlewares/time.ts | 2 +- .../src/node/server/middlewares/transform.ts | 4 ++-- packages/vite/src/node/server/moduleGraph.ts | 4 ++-- packages/vite/src/node/server/openBrowser.ts | 4 ++-- packages/vite/src/node/server/pluginContainer.ts | 8 ++++---- packages/vite/src/node/server/searchRoot.ts | 4 ++-- packages/vite/src/node/server/send.ts | 6 +++++- packages/vite/src/node/server/sourcemap.ts | 4 ++-- .../vite/src/node/server/transformRequest.ts | 6 +++--- packages/vite/src/node/server/ws.ts | 10 +++++----- .../node/ssr/__tests__/ssrModuleLoader.spec.ts | 4 ++-- packages/vite/src/node/ssr/ssrExternal.ts | 6 +++--- packages/vite/src/node/ssr/ssrManifestPlugin.ts | 2 +- packages/vite/src/node/ssr/ssrModuleLoader.ts | 4 ++-- packages/vite/src/node/utils.ts | 16 ++++++++-------- packages/vite/types/chokidar.d.ts | 4 ++-- packages/vite/types/connect.d.ts | 2 +- packages/vite/types/http-proxy.d.ts | 10 +++++----- packages/vite/types/ws.d.ts | 12 ++++++------ vitest.config.e2e.ts | 2 +- 77 files changed, 174 insertions(+), 170 deletions(-) diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index fbfb606f486885..4c96d97bae18f7 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -1,8 +1,8 @@ /* eslint-disable node/no-extraneous-import */ +import { join } from 'node:path' import type { ExecaSyncReturnValue, SyncOptions } from 'execa' import { commandSync } from 'execa' import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra' -import { join } from 'path' import { test, expect, beforeAll, afterEach } from 'vitest' const CLI_PATH = join(__dirname, '..') diff --git a/packages/create-vite/index.js b/packages/create-vite/index.js index 93ddb3c3f027a1..8c68c74d94a8c2 100755 --- a/packages/create-vite/index.js +++ b/packages/create-vite/index.js @@ -1,9 +1,9 @@ #!/usr/bin/env node // @ts-check -import fs from 'fs' -import path from 'path' -import { fileURLToPath } from 'url' +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import minimist from 'minimist' import prompts from 'prompts' import { diff --git a/packages/plugin-legacy/src/index.ts b/packages/plugin-legacy/src/index.ts index ed2c4a24820a61..a3fe55b2ee7a24 100644 --- a/packages/plugin-legacy/src/index.ts +++ b/packages/plugin-legacy/src/index.ts @@ -1,8 +1,8 @@ /* eslint-disable node/no-extraneous-import */ -import path from 'path' -import { createHash } from 'crypto' -import { createRequire } from 'module' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { createHash } from 'node:crypto' +import { createRequire } from 'node:module' +import { fileURLToPath } from 'node:url' import { build } from 'vite' import MagicString from 'magic-string' import type { diff --git a/packages/plugin-react/src/fast-refresh.ts b/packages/plugin-react/src/fast-refresh.ts index 708021f28a2665..6e5019d1e059df 100644 --- a/packages/plugin-react/src/fast-refresh.ts +++ b/packages/plugin-react/src/fast-refresh.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { createRequire } from 'module' +import fs from 'node:fs' +import path from 'node:path' +import { createRequire } from 'node:module' import type { types as t } from '@babel/core' export const runtimePublicPath = '/@react-refresh' diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index e52ad1ba0ba05a..12b96fb842c561 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import type { ParserOptions, TransformOptions, types as t } from '@babel/core' import * as babel from '@babel/core' import { createFilter } from '@rollup/pluginutils' diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts index 302cb323849ad6..a26174fbb3cc11 100644 --- a/packages/plugin-vue-jsx/src/index.ts +++ b/packages/plugin-vue-jsx/src/index.ts @@ -1,5 +1,5 @@ -import { createHash } from 'crypto' -import path from 'path' +import { createHash } from 'node:crypto' +import path from 'node:path' import type { types } from '@babel/core' import * as babel from '@babel/core' import jsx from '@vue/babel-plugin-jsx' diff --git a/packages/plugin-vue/src/compiler.ts b/packages/plugin-vue/src/compiler.ts index f4a24b1ea95005..f9338f525033c9 100644 --- a/packages/plugin-vue/src/compiler.ts +++ b/packages/plugin-vue/src/compiler.ts @@ -5,7 +5,7 @@ declare module 'vue/compiler-sfc' { } } -import { createRequire } from 'module' +import { createRequire } from 'node:module' import type * as _compiler from 'vue/compiler-sfc' export function resolveCompiler(root: string): typeof _compiler { diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 805df6fec674d0..7d80bb52757114 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -1,4 +1,4 @@ -import fs from 'fs' +import fs from 'node:fs' import type { Plugin, ViteDevServer } from 'vite' import { createFilter } from '@rollup/pluginutils' /* eslint-disable import/no-duplicates */ diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index be11de7e33a23a..f81daad0d0bf6e 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import type { SFCBlock, SFCDescriptor } from 'vue/compiler-sfc' import type { PluginContext, SourceMap, TransformPluginContext } from 'rollup' import { normalizePath } from '@rollup/pluginutils' diff --git a/packages/plugin-vue/src/template.ts b/packages/plugin-vue/src/template.ts index 107dfc2d163495..ee88ff0be28657 100644 --- a/packages/plugin-vue/src/template.ts +++ b/packages/plugin-vue/src/template.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import slash from 'slash' import type { CompilerOptions, diff --git a/packages/plugin-vue/src/utils/descriptorCache.ts b/packages/plugin-vue/src/utils/descriptorCache.ts index 890c817a217212..9deae326a5d0d1 100644 --- a/packages/plugin-vue/src/utils/descriptorCache.ts +++ b/packages/plugin-vue/src/utils/descriptorCache.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { createHash } from 'crypto' +import fs from 'node:fs' +import path from 'node:path' +import { createHash } from 'node:crypto' import slash from 'slash' import type { CompilerError, SFCDescriptor } from 'vue/compiler-sfc' import type { ResolvedOptions, VueQuery } from '..' diff --git a/packages/vite/bin/vite.js b/packages/vite/bin/vite.js index 143bb96a5d88bb..5814f260dc427c 100755 --- a/packages/vite/bin/vite.js +++ b/packages/vite/bin/vite.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -import { performance } from 'perf_hooks' +import { performance } from 'node:perf_hooks' if (!import.meta.url.includes('node_modules')) { try { diff --git a/packages/vite/rollup.config.ts b/packages/vite/rollup.config.ts index a8730833917aad..1e979531b2563c 100644 --- a/packages/vite/rollup.config.ts +++ b/packages/vite/rollup.config.ts @@ -1,6 +1,6 @@ /* eslint-disable no-restricted-globals */ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import nodeResolve from '@rollup/plugin-node-resolve' import typescript from '@rollup/plugin-typescript' import commonjs from '@rollup/plugin-commonjs' @@ -431,9 +431,9 @@ function licensePlugin() { */ function cjsPatchPlugin(): Plugin { const cjsPatch = ` -import { fileURLToPath as __cjs_fileURLToPath } from 'url'; -import { dirname as __cjs_dirname } from 'path'; -import { createRequire as __cjs_createRequire } from 'module'; +import { fileURLToPath as __cjs_fileURLToPath } from 'node:url'; +import { dirname as __cjs_dirname } from 'node:path'; +import { createRequire as __cjs_createRequire } from 'node:module'; const __filename = __cjs_fileURLToPath(import.meta.url); const __dirname = __cjs_dirname(__filename); diff --git a/packages/vite/scripts/patchTypes.ts b/packages/vite/scripts/patchTypes.ts index e31f3a39e82325..bdd3953b269aba 100644 --- a/packages/vite/scripts/patchTypes.ts +++ b/packages/vite/scripts/patchTypes.ts @@ -1,6 +1,6 @@ -import { readFileSync, readdirSync, statSync, writeFileSync } from 'fs' -import { dirname, relative, resolve } from 'path' -import { fileURLToPath } from 'url' +import { readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs' +import { dirname, relative, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import type { ParseResult } from '@babel/parser' import { parse } from '@babel/parser' import type { File } from '@babel/types' diff --git a/packages/vite/src/node/__tests__/build.spec.ts b/packages/vite/src/node/__tests__/build.spec.ts index 25423bfb16e99b..a692041b0ba04c 100644 --- a/packages/vite/src/node/__tests__/build.spec.ts +++ b/packages/vite/src/node/__tests__/build.spec.ts @@ -1,5 +1,5 @@ -import { resolve } from 'path' -import { fileURLToPath } from 'url' +import { resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { describe, expect, test } from 'vitest' import type { LibraryFormats, LibraryOptions } from '../build' import { resolveLibFilename } from '../build' diff --git a/packages/vite/src/node/__tests__/plugins/css.spec.ts b/packages/vite/src/node/__tests__/plugins/css.spec.ts index 16a3cbcd8e59e0..efad549a30102f 100644 --- a/packages/vite/src/node/__tests__/plugins/css.spec.ts +++ b/packages/vite/src/node/__tests__/plugins/css.spec.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import { describe, expect, test, vi } from 'vitest' import { resolveConfig } from '../../config' import { cssPlugin, cssUrlRE, hoistAtRules } from '../../plugins/css' diff --git a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts index 5ad8dac1dde3c5..ba619c90e509ef 100644 --- a/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts +++ b/packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.test.ts @@ -1,5 +1,5 @@ -import { resolve } from 'path' -import { fileURLToPath } from 'url' +import { resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' import { transformDynamicImport } from '../../../plugins/dynamicImportVars' diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts index 1de3d5e32dbd15..7b3206df31e82a 100644 --- a/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture.test.ts @@ -1,6 +1,6 @@ -import { resolve } from 'path' -import { promises as fs } from 'fs' -import { fileURLToPath } from 'url' +import { resolve } from 'node:path' +import { promises as fs } from 'node:fs' +import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' import { transformGlobImport } from '../../../plugins/importMetaGlob' import { transformWithEsbuild } from '../../../plugins/esbuild' diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 512f99732ffe8c..68e28d9f19c615 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import colors from 'picocolors' import type { ExternalOption, diff --git a/packages/vite/src/node/cli.ts b/packages/vite/src/node/cli.ts index 00f68bb5ef60b7..2d64d4fdaeb676 100644 --- a/packages/vite/src/node/cli.ts +++ b/packages/vite/src/node/cli.ts @@ -1,4 +1,4 @@ -import { performance } from 'perf_hooks' +import { performance } from 'node:perf_hooks' import { cac } from 'cac' import colors from 'picocolors' import type { BuildOptions } from './build' diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 1601dcbc149ca7..b6c861f57e3453 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -1,8 +1,8 @@ -import fs from 'fs' -import path from 'path' -import { parse as parseUrl, pathToFileURL } from 'url' -import { performance } from 'perf_hooks' -import { createRequire } from 'module' +import fs from 'node:fs' +import path from 'node:path' +import { parse as parseUrl, pathToFileURL } from 'node:url' +import { performance } from 'node:perf_hooks' +import { createRequire } from 'node:module' import colors from 'picocolors' import dotenv from 'dotenv' import dotenvExpand from 'dotenv-expand' diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index 4e5d3da96f50da..ec516e44f439b6 100644 --- a/packages/vite/src/node/constants.ts +++ b/packages/vite/src/node/constants.ts @@ -1,5 +1,5 @@ -import path, { resolve } from 'path' -import { fileURLToPath } from 'url' +import path, { resolve } from 'node:path' +import { fileURLToPath } from 'node:url' // @ts-expect-error import { version } from '../../package.json' diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index 2a1c7c920b8ea9..a735820cb37e2d 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -1,10 +1,10 @@ -import fs, { promises as fsp } from 'fs' -import path from 'path' +import fs, { promises as fsp } from 'node:fs' +import path from 'node:path' import type { Server as HttpServer, OutgoingHttpHeaders as HttpServerHeaders -} from 'http' -import type { ServerOptions as HttpsServerOptions } from 'https' +} from 'node:http' +import type { ServerOptions as HttpsServerOptions } from 'node:https' import type { Connect } from 'types/connect' import { isObject } from './utils' import type { ProxyOptions } from './server/middlewares/proxy' diff --git a/packages/vite/src/node/logger.ts b/packages/vite/src/node/logger.ts index c0f316ffed2698..5dd3553955aae9 100644 --- a/packages/vite/src/node/logger.ts +++ b/packages/vite/src/node/logger.ts @@ -1,7 +1,7 @@ /* eslint no-console: 0 */ -import type { AddressInfo, Server } from 'net' -import os from 'os' +import type { AddressInfo, Server } from 'node:net' +import os from 'node:os' import readline from 'readline' import colors from 'picocolors' import type { RollupError } from 'rollup' diff --git a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts index 4bf5c8b1c2152b..a6faa0932811f3 100644 --- a/packages/vite/src/node/optimizer/esbuildDepPlugin.ts +++ b/packages/vite/src/node/optimizer/esbuildDepPlugin.ts @@ -1,5 +1,5 @@ -import path from 'path' -import { promises as fs } from 'fs' +import path from 'node:path' +import { promises as fs } from 'node:fs' import type { ImportKind, Plugin } from 'esbuild' import { KNOWN_ASSET_TYPES } from '../constants' import type { ResolvedConfig } from '..' diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 0e71ba299e6727..e8fa8218be0232 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { performance } from 'perf_hooks' +import fs from 'node:fs' +import path from 'node:path' +import { performance } from 'node:perf_hooks' import _debug from 'debug' import colors from 'picocolors' import type { BuildOptions as EsbuildBuildOptions } from 'esbuild' diff --git a/packages/vite/src/node/optimizer/scan.ts b/packages/vite/src/node/optimizer/scan.ts index 6f609991ecc7fb..c7c99887452806 100644 --- a/packages/vite/src/node/optimizer/scan.ts +++ b/packages/vite/src/node/optimizer/scan.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { performance } from 'perf_hooks' +import fs from 'node:fs' +import path from 'node:path' +import { performance } from 'node:perf_hooks' import glob from 'fast-glob' import type { Loader, OnLoadResult, Plugin } from 'esbuild' import { build } from 'esbuild' diff --git a/packages/vite/src/node/packages.ts b/packages/vite/src/node/packages.ts index 1fb2e7b4a21c06..8642015d9ba28f 100644 --- a/packages/vite/src/node/packages.ts +++ b/packages/vite/src/node/packages.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import { createFilter } from '@rollup/pluginutils' import { createDebugger, resolveFrom } from './utils' import type { ResolvedConfig } from './config' diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 4c1bcfea0fd50b..223d5aee992bb2 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -1,6 +1,6 @@ -import path from 'path' -import { parse as parseUrl } from 'url' -import fs, { promises as fsp } from 'fs' +import path from 'node:path' +import { parse as parseUrl } from 'node:url' +import fs, { promises as fsp } from 'node:fs' import * as mrmime from 'mrmime' import type { OutputOptions, PluginContext } from 'rollup' import MagicString from 'magic-string' diff --git a/packages/vite/src/node/plugins/assetImportMetaUrl.ts b/packages/vite/src/node/plugins/assetImportMetaUrl.ts index 636234736cc32c..cb5a2b549c707b 100644 --- a/packages/vite/src/node/plugins/assetImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/assetImportMetaUrl.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import MagicString from 'magic-string' import { stripLiteral } from 'strip-literal' import type { Plugin } from '../plugin' diff --git a/packages/vite/src/node/plugins/clientInjections.ts b/packages/vite/src/node/plugins/clientInjections.ts index 84811dfc10df2a..10859c8f75d27d 100644 --- a/packages/vite/src/node/plugins/clientInjections.ts +++ b/packages/vite/src/node/plugins/clientInjections.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import type { Plugin } from '../plugin' import type { ResolvedConfig } from '../config' import { CLIENT_ENTRY, ENV_ENTRY } from '../constants' diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 45ff0525b1042d..8c34acc04019b4 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { createRequire } from 'module' +import fs from 'node:fs' +import path from 'node:path' +import { createRequire } from 'node:module' import glob from 'fast-glob' import postcssrc from 'postcss-load-config' import type { diff --git a/packages/vite/src/node/plugins/dataUri.ts b/packages/vite/src/node/plugins/dataUri.ts index 84999d586c4f34..9bc7f2069e9192 100644 --- a/packages/vite/src/node/plugins/dataUri.ts +++ b/packages/vite/src/node/plugins/dataUri.ts @@ -1,7 +1,7 @@ // This is based on @rollup/plugin-data-uri // MIT Licensed https://github.com/rollup/plugins/blob/master/LICENSE // ref https://github.com/vitejs/vite/issues/1428#issuecomment-757033808 -import { URL } from 'url' +import { URL } from 'node:url' import type { Plugin } from '../plugin' const dataUriRE = /^([^/]+\/[^;,]+)(;base64)?,([\s\S]*)$/ diff --git a/packages/vite/src/node/plugins/dynamicImportVars.ts b/packages/vite/src/node/plugins/dynamicImportVars.ts index a9f0d6fb810333..2b78fa9f2ab77d 100644 --- a/packages/vite/src/node/plugins/dynamicImportVars.ts +++ b/packages/vite/src/node/plugins/dynamicImportVars.ts @@ -1,4 +1,4 @@ -import { posix } from 'path' +import { posix } from 'node:path' import MagicString from 'magic-string' import { init, parse as parseImports } from 'es-module-lexer' import type { ImportSpecifier } from 'es-module-lexer' diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index 22fabf27099c00..15a3e014df3b63 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import colors from 'picocolors' import type { Loader, diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 9d06d6e168f2e1..d398fbe8065035 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import type { OutputAsset, OutputBundle, diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index 4d312636f3e996..7cbdebb8e7644b 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { performance } from 'perf_hooks' +import fs from 'node:fs' +import path from 'node:path' +import { performance } from 'node:perf_hooks' import colors from 'picocolors' import MagicString from 'magic-string' import type { ImportSpecifier } from 'es-module-lexer' diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index c365eae4a38f4e..09e73cd42938fa 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import MagicString from 'magic-string' import type { ImportSpecifier } from 'es-module-lexer' import { init, parse as parseImports } from 'es-module-lexer' diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index b624d7e609bcb1..e8dbcd9fc6293f 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -1,4 +1,4 @@ -import { isAbsolute, posix } from 'path' +import { isAbsolute, posix } from 'node:path' import micromatch from 'micromatch' import { stripLiteral } from 'strip-literal' import type { diff --git a/packages/vite/src/node/plugins/loadFallback.ts b/packages/vite/src/node/plugins/loadFallback.ts index aedd611ec40118..21ff1a352e11c3 100644 --- a/packages/vite/src/node/plugins/loadFallback.ts +++ b/packages/vite/src/node/plugins/loadFallback.ts @@ -1,4 +1,4 @@ -import { promises as fs } from 'fs' +import { promises as fs } from 'node:fs' import type { Plugin } from '..' import { cleanUrl } from '../utils' diff --git a/packages/vite/src/node/plugins/manifest.ts b/packages/vite/src/node/plugins/manifest.ts index 9784597195dc7c..a5712a3ba71f1e 100644 --- a/packages/vite/src/node/plugins/manifest.ts +++ b/packages/vite/src/node/plugins/manifest.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import type { OutputChunk } from 'rollup' import type { ResolvedConfig } from '..' import type { Plugin } from '../plugin' diff --git a/packages/vite/src/node/plugins/optimizedDeps.ts b/packages/vite/src/node/plugins/optimizedDeps.ts index 8d4e98b865bf28..263f0d31bb8dcd 100644 --- a/packages/vite/src/node/plugins/optimizedDeps.ts +++ b/packages/vite/src/node/plugins/optimizedDeps.ts @@ -1,4 +1,4 @@ -import { promises as fs } from 'fs' +import { promises as fs } from 'node:fs' import colors from 'picocolors' import type { Plugin } from '../plugin' import { DEP_VERSION_RE } from '../constants' diff --git a/packages/vite/src/node/plugins/reporter.ts b/packages/vite/src/node/plugins/reporter.ts index da6da4b8a349e3..ec673425306346 100644 --- a/packages/vite/src/node/plugins/reporter.ts +++ b/packages/vite/src/node/plugins/reporter.ts @@ -1,6 +1,6 @@ -import path from 'path' -import { gzip } from 'zlib' -import { promisify } from 'util' +import path from 'node:path' +import { gzip } from 'node:zlib' +import { promisify } from 'node:util' import colors from 'picocolors' import type { Plugin } from 'rollup' import type { ResolvedConfig } from '../config' diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 33675d3645483c..3dfa3fe5f6bc05 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import colors from 'picocolors' import type { PartialResolvedId } from 'rollup' import { resolve as _resolveExports } from 'resolve.exports' diff --git a/packages/vite/src/node/plugins/ssrRequireHook.ts b/packages/vite/src/node/plugins/ssrRequireHook.ts index 5dbeb77180cb36..62d87ff6b4f64e 100644 --- a/packages/vite/src/node/plugins/ssrRequireHook.ts +++ b/packages/vite/src/node/plugins/ssrRequireHook.ts @@ -1,4 +1,4 @@ -import { createRequire } from 'module' +import { createRequire } from 'node:module' import MagicString from 'magic-string' import type { ResolvedConfig } from '..' import type { Plugin } from '../plugin' diff --git a/packages/vite/src/node/plugins/terser.ts b/packages/vite/src/node/plugins/terser.ts index 4e6b7b681a2cea..5efb90afaebe21 100644 --- a/packages/vite/src/node/plugins/terser.ts +++ b/packages/vite/src/node/plugins/terser.ts @@ -1,5 +1,5 @@ -import { dirname } from 'path' -import { fileURLToPath } from 'url' +import { dirname } from 'node:path' +import { fileURLToPath } from 'node:url' import { Worker } from 'okie' import type { Terser } from 'types/terser' import type { Plugin } from '../plugin' diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 5fa6311e820100..148765baf1db1d 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import MagicString from 'magic-string' import type { EmittedAsset, OutputChunk } from 'rollup' import type { ResolvedConfig } from '../config' diff --git a/packages/vite/src/node/plugins/workerImportMetaUrl.ts b/packages/vite/src/node/plugins/workerImportMetaUrl.ts index 3b8300296f0520..0a5cfa63aa8ebb 100644 --- a/packages/vite/src/node/plugins/workerImportMetaUrl.ts +++ b/packages/vite/src/node/plugins/workerImportMetaUrl.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import JSON5 from 'json5' import MagicString from 'magic-string' import type { RollupError } from 'rollup' diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index a8cb533e35ad19..cdca7696ae3637 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -1,5 +1,5 @@ -import path from 'path' -import type * as http from 'http' +import path from 'node:path' +import type * as http from 'node:http' import sirv from 'sirv' import connect from 'connect' import type { Connect } from 'types/connect' diff --git a/packages/vite/src/node/server/__tests__/search-root.spec.ts b/packages/vite/src/node/server/__tests__/search-root.spec.ts index 06bc8ab0947173..e5ee6a523c13b0 100644 --- a/packages/vite/src/node/server/__tests__/search-root.spec.ts +++ b/packages/vite/src/node/server/__tests__/search-root.spec.ts @@ -1,5 +1,5 @@ -import { dirname, resolve } from 'path' -import { fileURLToPath } from 'url' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { describe, expect, test } from 'vitest' import { searchForWorkspaceRoot } from '../searchRoot' diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 23ed627a79f3e6..e21b77302b2453 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import type { Server } from 'http' +import fs from 'node:fs' +import path from 'node:path' +import type { Server } from 'node:http' import colors from 'picocolors' import type { Update } from 'types/hmrPayload' import type { RollupError } from 'rollup' diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index a8e16b2b5cf9e5..22635d7b56794f 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -1,8 +1,8 @@ -import fs from 'fs' -import path from 'path' -import type * as net from 'net' -import type * as http from 'http' -import { performance } from 'perf_hooks' +import fs from 'node:fs' +import path from 'node:path' +import type * as net from 'node:net' +import type * as http from 'node:http' +import { performance } from 'node:perf_hooks' import connect from 'connect' import corsMiddleware from 'cors' import colors from 'picocolors' diff --git a/packages/vite/src/node/server/middlewares/compression.ts b/packages/vite/src/node/server/middlewares/compression.ts index bafae7ef2023c6..f0715133aea167 100644 --- a/packages/vite/src/node/server/middlewares/compression.ts +++ b/packages/vite/src/node/server/middlewares/compression.ts @@ -4,7 +4,7 @@ // This is based on https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/polkompress.js // MIT Licensed https://github.com/preactjs/wmr/blob/main/LICENSE -import zlib from 'zlib' +import zlib from 'node:zlib' /* global Buffer */ diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index 161c2c9065924d..d160de1fe975de 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import MagicString from 'magic-string' import type { SourceMapInput } from 'rollup' import type { AttributeNode, ElementNode, TextNode } from '@vue/compiler-dom' diff --git a/packages/vite/src/node/server/middlewares/proxy.ts b/packages/vite/src/node/server/middlewares/proxy.ts index 5c447435911ecd..6ce76710fa758e 100644 --- a/packages/vite/src/node/server/middlewares/proxy.ts +++ b/packages/vite/src/node/server/middlewares/proxy.ts @@ -1,4 +1,4 @@ -import type * as http from 'http' +import type * as http from 'node:http' import httpProxy from 'http-proxy' import type { Connect } from 'types/connect' import type { HttpProxy } from 'types/http-proxy' diff --git a/packages/vite/src/node/server/middlewares/spaFallback.ts b/packages/vite/src/node/server/middlewares/spaFallback.ts index 450d188651b6e8..6970eef9df5706 100644 --- a/packages/vite/src/node/server/middlewares/spaFallback.ts +++ b/packages/vite/src/node/server/middlewares/spaFallback.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import history from 'connect-history-api-fallback' import type { Connect } from 'types/connect' import { createDebugger } from '../../utils' diff --git a/packages/vite/src/node/server/middlewares/static.ts b/packages/vite/src/node/server/middlewares/static.ts index 5d4a948885baa3..b821807be34fbe 100644 --- a/packages/vite/src/node/server/middlewares/static.ts +++ b/packages/vite/src/node/server/middlewares/static.ts @@ -1,5 +1,5 @@ -import path from 'path' -import type { ServerResponse } from 'http' +import path from 'node:path' +import type { ServerResponse } from 'node:http' import type { Options } from 'sirv' import sirv from 'sirv' import type { Connect } from 'types/connect' diff --git a/packages/vite/src/node/server/middlewares/time.ts b/packages/vite/src/node/server/middlewares/time.ts index 64124ab58c70c7..41a42f63270e50 100644 --- a/packages/vite/src/node/server/middlewares/time.ts +++ b/packages/vite/src/node/server/middlewares/time.ts @@ -1,4 +1,4 @@ -import { performance } from 'perf_hooks' +import { performance } from 'node:perf_hooks' import type { Connect } from 'types/connect' import { createDebugger, prettifyUrl, timeFrom } from '../../utils' diff --git a/packages/vite/src/node/server/middlewares/transform.ts b/packages/vite/src/node/server/middlewares/transform.ts index 89022bf93bb4b2..fe32f367ad2135 100644 --- a/packages/vite/src/node/server/middlewares/transform.ts +++ b/packages/vite/src/node/server/middlewares/transform.ts @@ -1,5 +1,5 @@ -import { promises as fs } from 'fs' -import path from 'path' +import { promises as fs } from 'node:fs' +import path from 'node:path' import type { Connect } from 'types/connect' import colors from 'picocolors' import type { ViteDevServer } from '..' diff --git a/packages/vite/src/node/server/moduleGraph.ts b/packages/vite/src/node/server/moduleGraph.ts index 4c98b83a7e74ca..19a58107ba8aa6 100644 --- a/packages/vite/src/node/server/moduleGraph.ts +++ b/packages/vite/src/node/server/moduleGraph.ts @@ -1,5 +1,5 @@ -import { extname } from 'path' -import { parse as parseUrl } from 'url' +import { extname } from 'node:path' +import { parse as parseUrl } from 'node:url' import type { ModuleInfo, PartialResolvedId } from 'rollup' import { isDirectCSSRequest } from '../plugins/css' import { isHTMLRequest } from '../plugins/html' diff --git a/packages/vite/src/node/server/openBrowser.ts b/packages/vite/src/node/server/openBrowser.ts index 94349af970f1fb..319cb4431f4583 100644 --- a/packages/vite/src/node/server/openBrowser.ts +++ b/packages/vite/src/node/server/openBrowser.ts @@ -8,8 +8,8 @@ * */ -import { join } from 'path' -import { execSync } from 'child_process' +import { join } from 'node:path' +import { execSync } from 'node:child_process' import open from 'open' import spawn from 'cross-spawn' import colors from 'picocolors' diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index 4d124759af0afa..8e74f669616acd 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -29,10 +29,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import fs from 'fs' -import { join, resolve } from 'path' -import { performance } from 'perf_hooks' -import { createRequire } from 'module' +import fs from 'node:fs' +import { join, resolve } from 'node:path' +import { performance } from 'node:perf_hooks' +import { createRequire } from 'node:module' import type { EmittedFile, InputOptions, diff --git a/packages/vite/src/node/server/searchRoot.ts b/packages/vite/src/node/server/searchRoot.ts index 1fa63eff4e024d..b40226f4a53e38 100644 --- a/packages/vite/src/node/server/searchRoot.ts +++ b/packages/vite/src/node/server/searchRoot.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import { dirname, join } from 'path' +import fs from 'node:fs' +import { dirname, join } from 'node:path' import { isFileReadable } from '../utils' // https://github.com/vitejs/vite/issues/2820#issuecomment-812495079 diff --git a/packages/vite/src/node/server/send.ts b/packages/vite/src/node/server/send.ts index a52d17d17458ba..51f1fa65afed25 100644 --- a/packages/vite/src/node/server/send.ts +++ b/packages/vite/src/node/server/send.ts @@ -1,4 +1,8 @@ -import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'http' +import type { + IncomingMessage, + OutgoingHttpHeaders, + ServerResponse +} from 'node:http' import getEtag from 'etag' import type { SourceMap } from 'rollup' import { getCodeWithSourcemap } from './sourcemap' diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index 97ee26668d741c..5894895869919c 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -1,5 +1,5 @@ -import path from 'path' -import { promises as fs } from 'fs' +import path from 'node:path' +import { promises as fs } from 'node:fs' import type { SourceMap } from 'rollup' import type { Logger } from '../logger' import { createDebugger } from '../utils' diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 5402bb21093d59..c131463a6abe08 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -1,6 +1,6 @@ -import { promises as fs } from 'fs' -import path from 'path' -import { performance } from 'perf_hooks' +import { promises as fs } from 'node:fs' +import path from 'node:path' +import { performance } from 'node:perf_hooks' import getEtag from 'etag' import * as convertSourceMap from 'convert-source-map' import type { SourceDescription, SourceMap } from 'rollup' diff --git a/packages/vite/src/node/server/ws.ts b/packages/vite/src/node/server/ws.ts index fa6f2b1cdeb25c..0d787a79157d6b 100644 --- a/packages/vite/src/node/server/ws.ts +++ b/packages/vite/src/node/server/ws.ts @@ -1,8 +1,8 @@ -import type { Server } from 'http' -import { STATUS_CODES } from 'http' -import type { ServerOptions as HttpsServerOptions } from 'https' -import { createServer as createHttpsServer } from 'https' -import type { Socket } from 'net' +import type { Server } from 'node:http' +import { STATUS_CODES } from 'node:http' +import type { ServerOptions as HttpsServerOptions } from 'node:https' +import { createServer as createHttpsServer } from 'node:https' +import type { Socket } from 'node:net' import colors from 'picocolors' import type { ServerOptions, WebSocket as WebSocketRaw } from 'ws' import { WebSocketServer as WebSocketServerRaw } from 'ws' diff --git a/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts index aecf64b3586faf..8451be5b3af745 100644 --- a/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts +++ b/packages/vite/src/node/ssr/__tests__/ssrModuleLoader.spec.ts @@ -1,5 +1,5 @@ -import { resolve } from 'path' -import { fileURLToPath } from 'url' +import { resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import { expect, test, vi } from 'vitest' import { createServer } from '../../index' diff --git a/packages/vite/src/node/ssr/ssrExternal.ts b/packages/vite/src/node/ssr/ssrExternal.ts index 52b7a47566ba2a..b256187c9d03e4 100644 --- a/packages/vite/src/node/ssr/ssrExternal.ts +++ b/packages/vite/src/node/ssr/ssrExternal.ts @@ -1,6 +1,6 @@ -import fs from 'fs' -import path from 'path' -import { createRequire } from 'module' +import fs from 'node:fs' +import path from 'node:path' +import { createRequire } from 'node:module' import { createFilter } from '@rollup/pluginutils' import type { InternalResolveOptions } from '../plugins/resolve' import { tryNodeResolve } from '../plugins/resolve' diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index 993fae1632ed5d..40dca87f4d79ed 100644 --- a/packages/vite/src/node/ssr/ssrManifestPlugin.ts +++ b/packages/vite/src/node/ssr/ssrManifestPlugin.ts @@ -1,4 +1,4 @@ -import { basename, dirname, join, relative } from 'path' +import { basename, dirname, join, relative } from 'node:path' import { parse as parseImports } from 'es-module-lexer' import type { ImportSpecifier } from 'es-module-lexer' import type { OutputChunk } from 'rollup' diff --git a/packages/vite/src/node/ssr/ssrModuleLoader.ts b/packages/vite/src/node/ssr/ssrModuleLoader.ts index 7f9731c417c566..a2e30b2a6ccf5e 100644 --- a/packages/vite/src/node/ssr/ssrModuleLoader.ts +++ b/packages/vite/src/node/ssr/ssrModuleLoader.ts @@ -1,5 +1,5 @@ -import path from 'path' -import { pathToFileURL } from 'url' +import path from 'node:path' +import { pathToFileURL } from 'node:url' import type { ViteDevServer } from '../server' import { bareImportRE, diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 258551b838f271..4567fe16af9455 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1,11 +1,11 @@ -import fs from 'fs' -import os from 'os' -import path from 'path' -import { createHash } from 'crypto' -import { promisify } from 'util' -import { URL, URLSearchParams, pathToFileURL } from 'url' -import { builtinModules, createRequire } from 'module' -import { performance } from 'perf_hooks' +import fs from 'node:fs' +import os from 'node:os' +import path from 'node:path' +import { createHash } from 'node:crypto' +import { promisify } from 'node:util' +import { URL, URLSearchParams, pathToFileURL } from 'node:url' +import { builtinModules, createRequire } from 'node:module' +import { performance } from 'node:perf_hooks' import resolve from 'resolve' import type { FSWatcher } from 'chokidar' import remapping from '@ampproject/remapping' diff --git a/packages/vite/types/chokidar.d.ts b/packages/vite/types/chokidar.d.ts index e83e8e8d4b0166..51ac89b8e98d1f 100644 --- a/packages/vite/types/chokidar.d.ts +++ b/packages/vite/types/chokidar.d.ts @@ -28,8 +28,8 @@ THE SOFTWARE. */ /// -import type * as fs from 'fs' -import { EventEmitter } from 'events' +import type * as fs from 'node:fs' +import { EventEmitter } from 'node:events' import type { Matcher } from './anymatch' export class FSWatcher extends EventEmitter implements fs.FSWatcher { diff --git a/packages/vite/types/connect.d.ts b/packages/vite/types/connect.d.ts index 753569ccbe13c5..2fb97ebeb494ab 100644 --- a/packages/vite/types/connect.d.ts +++ b/packages/vite/types/connect.d.ts @@ -8,7 +8,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -import * as http from 'http' +import * as http from 'node:http' export namespace Connect { export type ServerHandle = HandleFunction | http.Server diff --git a/packages/vite/types/http-proxy.d.ts b/packages/vite/types/http-proxy.d.ts index 5a681cc1e3f170..81b9226a4db669 100644 --- a/packages/vite/types/http-proxy.d.ts +++ b/packages/vite/types/http-proxy.d.ts @@ -13,11 +13,11 @@ /// -import type * as net from 'net' -import type * as http from 'http' -import * as events from 'events' -import type * as url from 'url' -import type * as stream from 'stream' +import type * as net from 'node:net' +import type * as http from 'node:http' +import * as events from 'node:events' +import type * as url from 'node:url' +import type * as stream from 'node:stream' export namespace HttpProxy { export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed diff --git a/packages/vite/types/ws.d.ts b/packages/vite/types/ws.d.ts index a7620ad5470a1d..4a03058d0eeaa2 100644 --- a/packages/vite/types/ws.d.ts +++ b/packages/vite/types/ws.d.ts @@ -15,7 +15,7 @@ /// -import { EventEmitter } from 'events' +import { EventEmitter } from 'node:events' import type { Agent, ClientRequest, @@ -23,12 +23,12 @@ import type { Server as HTTPServer, IncomingMessage, OutgoingHttpHeaders -} from 'http' -import type { Server as HTTPSServer } from 'https' -import type { Duplex, DuplexOptions } from 'stream' +} from 'node:http' +import type { Server as HTTPSServer } from 'node:https' +import type { Duplex, DuplexOptions } from 'node:stream' import type { SecureContextOptions } from 'tls' -import type { URL } from 'url' -import type { ZlibOptions } from 'zlib' +import type { URL } from 'node:url' +import type { ZlibOptions } from 'node:zlib' // WebSocket socket. declare class WebSocket extends EventEmitter { diff --git a/vitest.config.e2e.ts b/vitest.config.e2e.ts index 9539997c4a14ba..4bed40a9a46e69 100644 --- a/vitest.config.e2e.ts +++ b/vitest.config.e2e.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path' +import { resolve } from 'node:path' import { defineConfig } from 'vitest/config' const timeout = process.env.CI ? 50000 : 30000 From 1f75678affd9cf0ca1687702409bd3145c6fb5de Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Tue, 24 May 2022 15:18:24 +0200 Subject: [PATCH 2/7] chore: use node prefix in scripts --- scripts/patchCJS.ts | 2 +- scripts/releaseUtils.ts | 4 ++-- scripts/verifyCommit.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/patchCJS.ts b/scripts/patchCJS.ts index e225d9455e98dc..7f0dfa1449dc3d 100644 --- a/scripts/patchCJS.ts +++ b/scripts/patchCJS.ts @@ -16,7 +16,7 @@ module.exports.parseVueRequest = parseVueRequest; ``` */ -import { readFileSync, writeFileSync } from 'fs' +import { readFileSync, writeFileSync } from 'node:fs' import colors from 'picocolors' const indexPath = 'dist/index.cjs' diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts index 272ab799fbc732..74e35be9acdc31 100644 --- a/scripts/releaseUtils.ts +++ b/scripts/releaseUtils.ts @@ -1,8 +1,8 @@ /** * modified from https://github.com/vuejs/core/blob/master/scripts/release.js */ -import { existsSync, readdirSync, writeFileSync } from 'fs' -import path from 'path' +import { existsSync, readdirSync, writeFileSync } from 'node:fs' +import path from 'node:path' import colors from 'picocolors' import type { Options as ExecaOptions } from 'execa' import execa from 'execa' diff --git a/scripts/verifyCommit.ts b/scripts/verifyCommit.ts index 226b514437d555..848295ddf72925 100644 --- a/scripts/verifyCommit.ts +++ b/scripts/verifyCommit.ts @@ -1,6 +1,6 @@ // Invoked on the commit-msg git hook by simple-git-hooks. -import { readFileSync } from 'fs' +import { readFileSync } from 'node:fs' import colors from 'picocolors' // get $1 from commit-msg script From 8c87831078be94141afe5412ba755f95e433c99e Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Tue, 24 May 2022 15:24:32 +0200 Subject: [PATCH 3/7] chore: use node prefix in playground --- playground/alias/index.html | 2 +- playground/css-sourcemap/__tests__/serve.spec.ts | 2 +- playground/css/__tests__/css.spec.ts | 2 +- .../postcss-plugins-different-dir.spec.ts | 2 +- playground/css/postcss-caching/css.spec.ts | 4 ++-- playground/glob-import/vite.config.ts | 2 +- playground/js-sourcemap/__tests__/serve.spec.ts | 2 +- playground/json/__tests__/json.spec.ts | 2 +- playground/legacy/__tests__/ssr/serve.ts | 2 +- playground/lib/__tests__/lib.spec.ts | 4 ++-- playground/lib/__tests__/serve.ts | 4 ++-- .../optimize-deps/dep-linked-include/index.mjs | 6 +++--- .../__test__/optimize-missing-deps.spec.ts | 4 ++-- .../optimize-missing-deps/__test__/serve.ts | 2 +- .../__tests__/resolve-config.spec.ts | 4 ++-- playground/resolve-config/__tests__/serve.ts | 2 +- playground/ssr-deps/__tests__/serve.ts | 2 +- playground/ssr-deps/src/app.js | 2 +- playground/ssr-html/__tests__/serve.ts | 2 +- playground/ssr-pug/__tests__/serve.ts | 2 +- playground/ssr-react/__tests__/serve.ts | 2 +- playground/ssr-vue/__tests__/serve.ts | 2 +- playground/ssr-vue/__tests__/ssr-vue.spec.ts | 2 +- playground/ssr-vue/src/entry-server.js | 4 ++-- playground/ssr-webworker/__tests__/serve.ts | 2 +- playground/test-utils.ts | 4 ++-- .../tsconfig-json/__tests__/tsconfig-json.spec.ts | 4 ++-- playground/vitestGlobalSetup.ts | 4 ++-- playground/vitestSetup.ts | 15 +++++++-------- playground/vue-lib/__tests__/vue-lib.spec.ts | 2 +- playground/vue-lib/vite.config.lib.ts | 2 +- playground/vue-sourcemap/__tests__/serve.spec.ts | 2 +- playground/worker/__tests__/es/es-worker.spec.ts | 4 ++-- playground/worker/__tests__/iife/worker.spec.ts | 4 ++-- .../relative-base/relative-base-worker.spec.ts | 4 ++-- .../sourcemap-hidden-worker.spec.ts | 4 ++-- .../sourcemap-inline-worker.spec.ts | 4 ++-- .../__tests__/sourcemap/sourcemap-worker.spec.ts | 4 ++-- 38 files changed, 61 insertions(+), 62 deletions(-) diff --git a/playground/alias/index.html b/playground/alias/index.html index 274e8ae635b71e..fa118d81542728 100644 --- a/playground/alias/index.html +++ b/playground/alias/index.html @@ -11,7 +11,7 @@

Alias