diff --git a/packages/create-vite/__tests__/cli.spec.ts b/packages/create-vite/__tests__/cli.spec.ts index 39ac7e1e547a36..4f5d9aa0dbaa15 100644 --- a/packages/create-vite/__tests__/cli.spec.ts +++ b/packages/create-vite/__tests__/cli.spec.ts @@ -1,4 +1,4 @@ -import { join } from 'path' +import { join } from 'node:path' import type { ExecaSyncReturnValue, SyncOptions } from 'execa' import { execaCommandSync } from 'execa' import { mkdirpSync, readdirSync, remove, writeFileSync } from 'fs-extra' diff --git a/packages/create-vite/index.js b/packages/create-vite/index.js index ec084e8327d603..40d0aa583124d3 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 1a5e86e46019be..add2384935d836 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 77ce68a630f631..7fa602c5e1e9af 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, normalizePath } from 'vite' diff --git a/packages/plugin-vue-jsx/src/index.ts b/packages/plugin-vue-jsx/src/index.ts index 48de3da46448ce..803c7fd7fd1a97 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 3e1b2c3be1b7f5..6bc0db06fe2b10 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 'vite' /* eslint-disable import/no-duplicates */ diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index e92c48673a680e..76f8892a07cb5b 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, TransformPluginContext } from 'rollup' import type { RawSourceMap } from 'source-map' diff --git a/packages/plugin-vue/src/template.ts b/packages/plugin-vue/src/template.ts index 6fcbefa056fefe..d603debe042b9c 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 0e321956a0d287..fc51e94c299e3c 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' @@ -401,9 +401,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 710c7218513018..d1694c295638bf 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 4922a7ec518a18..86ae76bba12215 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 d8f04aef0610fe..d6ba20fb610d08 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 type { Alias, AliasOptions } from 'types/alias' import aliasPlugin from '@rollup/plugin-alias' diff --git a/packages/vite/src/node/constants.ts b/packages/vite/src/node/constants.ts index 3b4d496e30bd3c..d45bfa088f80f1 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/env.ts b/packages/vite/src/node/env.ts index 5f204488c67efd..0472f6fc829d49 100644 --- a/packages/vite/src/node/env.ts +++ b/packages/vite/src/node/env.ts @@ -1,4 +1,4 @@ -import fs from 'fs' +import fs from 'node:fs' import dotenv from 'dotenv' import dotenvExpand from 'dotenv-expand' import { arraify, lookupFile } from './utils' diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index 8710c274fd83d1..d34e67d62aeb36 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 8133f7bb584bbc..d2b33397fbfd9e 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 aacabbdf9b1a3c..09866eb300c2a3 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 6043a0fcd9452a..1ef86c6aad9b2f 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 63d2d265e10e27..36eb0229c6fcc0 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, transform } from 'esbuild' diff --git a/packages/vite/src/node/packages.ts b/packages/vite/src/node/packages.ts index e1c0c18eb5a119..e1a85bff441212 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 { createDebugger, createFilter, resolveFrom } from './utils' import type { ResolvedConfig } from './config' import type { Plugin } from './plugin' diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 8f1f3516c36387..3b4554daff02ca 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, PreRenderedAsset } 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 1d1401dd8b44a9..af3fa325bfce03 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 0d057fa4750238..f868f290c36834 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 ff20c5725dc341..7093ded9253a39 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 c423edca92f9c1..16c165bf288a98 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 a66a6288f8e8c2..d387fd99a658ab 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 f0afb794060ef3..99275492fa642e 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 f56d2a4194ca84..0ad5051dd29ffa 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -1,5 +1,4 @@ -// import fs from 'fs' -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 e6499425fc6637..c52f3843dbaaad 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 b496caf4dbae96..a0e231a3e034fb 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 { OutputAsset, 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 3a3f541adce3bc..3eff36bd1bc13e 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 { ResolvedConfig } from '..' import type { Plugin } from '../plugin' 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 f552b19a08a21a..df688b5749563a 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 6d2efa3c58b183..dc51f9114c5ef2 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/worker.ts b/packages/vite/src/node/plugins/worker.ts index 848d118ba0eb64..cc70cde1b10792 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 510ae644a1a11b..c88046465f0f42 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 dde12ef377bb41..feb106ad086709 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 5a0616dbb643e7..fe7a60cbf421f9 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 6397891a2ffe00..7ef5d2f341920e 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 9cd529a0dbba7b..7fc576ba91252c 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 3d0f453971803e..b5eb087b7b467c 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 { OutgoingHttpHeaders, ServerResponse } from 'http' +import path from 'node:path' +import type { OutgoingHttpHeaders, 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 d286e44cd86cd9..f41a29f512f2ac 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 ec051205eee379..86dcefe024542f 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 d38c992f7155a2..a6f344ea56292c 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 daad169ff6fc2f..59d396d2c78a55 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 type { InternalResolveOptions } from '../plugins/resolve' import { tryNodeResolve } from '../plugins/resolve' import { diff --git a/packages/vite/src/node/ssr/ssrManifestPlugin.ts b/packages/vite/src/node/ssr/ssrManifestPlugin.ts index 8bb9a8bcff75dc..472e6da5ab201c 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 02611dcfffae01..4583147628903f 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/playground/alias/index.html b/playground/alias/index.html index 274e8ae635b71e..947db06127ed41 100644 --- a/playground/alias/index.html +++ b/playground/alias/index.html @@ -11,6 +11,7 @@

Alias