Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use node prefix #8309

Merged
merged 8 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/create-vite/__tests__/cli.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions packages/create-vite/index.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-legacy/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-react/src/fast-refresh.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue-jsx/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import slash from 'slash'
import type {
CompilerOptions,
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/utils/descriptorCache.ts
Original file line number Diff line number Diff line change
@@ -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 '..'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/bin/vite.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/scripts/patchTypes.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/plugins/css.spec.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/constants.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/env.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/node/http.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/logger.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Original file line number Diff line number Diff line change
@@ -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 '..'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/packages.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/assetImportMetaUrl.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/dataUri.ts
Original file line number Diff line number Diff line change
@@ -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]*)$/
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/dynamicImportVars.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import colors from 'picocolors'
import type {
Loader,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import path from 'node:path'
import type {
OutputAsset,
OutputBundle,
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
3 changes: 1 addition & 2 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importMetaGlob.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/loadFallback.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/manifest.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/optimizedDeps.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/reporter.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/ssrRequireHook.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/worker.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Loading