Skip to content
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 eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default defineConfig(
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'off', // prefer indexed access for better performance
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/require-await': 'off', // does not handle inferred required async functions well
'@typescript-eslint/restrict-template-expressions': 'off', // does not matter for us
'@typescript-eslint/unbound-method': 'off',

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/rolldown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function enableSourceMapsInWatchModePlugin(): Plugin {
function writeTypesPlugin(): Plugin {
return {
name: 'write-types',
async writeBundle() {
writeBundle() {
if (this.meta.watchMode) {
writeFileSync(
'dist/node/index.d.ts',
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ export function resolveBuildEnvironmentOptions(
return resolved
}

export async function resolveBuildPlugins(config: ResolvedConfig): Promise<{
export function resolveBuildPlugins(config: ResolvedConfig): {
pre: Plugin[]
post: Plugin[]
}> {
} {
const isBuild = config.command === 'build'
return {
pre: [
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ async function bundleConfigFile(
name: 'externalize-deps',
resolveId: {
filter: { id: /^[^.#].*/ },
async handler(id, importer, { kind }) {
handler(id, importer, { kind }) {
if (!importer || path.isAbsolute(id) || isNodeBuiltin(id)) {
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ export function createDepsOptimizer(
})
}

async function rerun() {
function rerun() {
// debounce time to wait for new missing deps finished, issue a new
// optimization of deps (both old and newly found) once the previous
// optimizeDeps processing is finished
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/rolldownDepPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export function rolldownDepPlugin(
filter: {
code: assetImportMetaUrlRE,
},
async handler(code, id) {
handler(code, id) {
let s: MagicString | undefined
const re = new RegExp(assetImportMetaUrlRE)
const cleanString = stripLiteral(code)
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
async buildStart() {
injectConfigValues = await createClientConfigValueReplacer(config)
},
async transform(code, id) {
transform(code, id) {
const ssr = this.environment.config.consumer === 'server'
const cleanId = cleanUrl(id)
if (cleanId === normalizedClientEntry || cleanId === normalizedEnvEntry) {
Expand All @@ -50,7 +50,7 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {
const nodeEnv =
this.environment.config.define?.['process.env.NODE_ENV'] ||
JSON.stringify(process.env.NODE_ENV || config.mode)
return await replaceDefine(this.environment, code, id, {
return replaceDefine(this.environment, code, id, {
'process.env.NODE_ENV': nodeEnv,
'global.process.env.NODE_ENV': nodeEnv,
'globalThis.process.env.NODE_ENV': nodeEnv,
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
filter: {
id: CSS_LANGS_RE,
},
async handler(id) {
handler(id) {
if (urlRE.test(id)) {
if (isModuleCSSRequest(id)) {
throw new Error(
Expand Down Expand Up @@ -1182,7 +1182,7 @@ export function cssAnalysisPlugin(config: ResolvedConfig): Plugin {
exclude: [commonjsProxyRE, SPECIAL_QUERY_RE],
},
},
async handler(_, id) {
handler(_, id) {
const { moduleGraph } = this.environment as DevEnvironment
const thisModule = moduleGraph.getModuleById(id)

Expand Down Expand Up @@ -1904,7 +1904,7 @@ const viteHashUpdateMarkerRE = /\/\*\$vite\$:\d+\*\//
async function finalizeCss(css: string, config: ResolvedConfig) {
// hoist external @imports and @charset to the top of the CSS chunk per spec (#1845 and #6333)
if (css.includes('@import') || css.includes('@charset')) {
css = await hoistAtRules(css)
css = hoistAtRules(css)
}
if (config.build.cssMinify) {
css = await minifyCSS(css, config, false)
Expand Down Expand Up @@ -2310,7 +2310,7 @@ const atImportRE =
const atCharsetRE =
/@charset(?:\s*(?:"(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*').*?|[^;]*);/g

export async function hoistAtRules(css: string): Promise<string> {
export function hoistAtRules(css: string): string {
const s = new MagicString(css)
const cleanCss = emptyCssComments(css)
let match: RegExpExecArray | null
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/src/node/plugins/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function definePlugin(config: ResolvedConfig): Plugin {
name: 'vite:define',

transform: {
async handler(code, id) {
handler(code, id) {
if (this.environment.config.consumer === 'client') {
// for dev we inject actual global defines in the vite client to
// avoid the transform cost. see the `clientInjection` and
Expand All @@ -157,22 +157,22 @@ export function definePlugin(config: ResolvedConfig): Plugin {
pattern.lastIndex = 0
if (!pattern.test(code)) return

const result = await replaceDefine(this.environment, code, id, define)
const result = replaceDefine(this.environment, code, id, define)
return result
},
},
}
}

export async function replaceDefine(
export function replaceDefine(
environment: Environment,
code: string,
id: string,
define: Record<string, string>,
): Promise<{
): {
code: string
map: ReturnType<typeof transformSync>['map'] | null
}> {
} {
const result = transformSync(id, code, {
lang: 'js',
sourceType: 'module',
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ export function getTSConfigResolutionCache(
return cache
}

export async function reloadOnTsconfigChange(
export function reloadOnTsconfigChange(
server: ViteDevServer,
changedFile: string,
): Promise<void> {
): void {
// any tsconfig.json that's added in the workspace could be closer to a code file than a previously cached one
// any json file in the tsconfig cache could have been used to compile ts
if (changedFile.endsWith('.json')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function resolvePlugins(
const isBundled = config.isBundled
const isWorker = config.isWorker
const buildPlugins = isBundled
? await (await import('../build')).resolveBuildPlugins(config)
? (await import('../build')).resolveBuildPlugins(config)
: { pre: [], post: [] }
const { modulePreload } = config.build

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function licensePlugin(): Plugin {
return {
name: 'vite:license',

async generateBundle(_, bundle) {
generateBundle(_, bundle) {
const licenseOption = this.environment.config.build.license
if (licenseOption === false) return

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default ${wasmHelperCode}
env.config.consumer === 'server'
? {
filter: { code: wasmInitUrlRE },
async handler(code, chunk, opts, meta) {
handler(code, chunk, opts, meta) {
const toRelativeRuntime =
createToImportMetaURLBasedRelativeRuntime(
opts.format,
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
Expand Up @@ -515,7 +515,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {

transform: {
filter: { id: workerFileRE },
async handler(raw, id) {
handler(raw, id) {
const workerFileMatch = workerFileRE.exec(id)
if (workerFileMatch) {
// if import worker by worker constructor will have query.type
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class DevEnvironment extends BaseEnvironment {

this.hot.on(
'vite:invalidate',
async ({ path, message, firstInvalidatedBy }, client) => {
({ path, message, firstInvalidatedBy }, client) => {
this.invalidateModule(
{
path,
Expand Down Expand Up @@ -401,7 +401,7 @@ function setupOnCrawlEnd(): CrawlEndFinder {
callCrawlEndIfIdleAfterMs,
)
}
async function callOnCrawlEndWhenIdle() {
function callOnCrawlEndWhenIdle() {
if (cancelled || registeredIds.size > 0) return
onCrawlEndPromiseWithResolvers.resolve()
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export async function ssrTransform(
return ssrTransformScript(code, inMap, url, originalCode)
}

async function ssrTransformJSON(
function ssrTransformJSON(
code: string,
inMap: SourceMap | { mappings: '' } | null,
): Promise<TransformResult> {
): TransformResult {
return {
code: code.replace('export default', `${ssrModuleExportsKey}.default =`),
map: inMap,
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/shared/moduleRunnerTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const createWebSocketModuleRunnerTransport = (options: {
return {
async connect({ onMessage, onDisconnection }) {
const socket = options.createConnection()
socket.addEventListener('message', async ({ data }) => {
socket.addEventListener('message', ({ data }) => {
onMessage(JSON.parse(data))
})

Expand All @@ -285,7 +285,7 @@ export const createWebSocketModuleRunnerTransport = (options: {
},
{ once: true },
)
socket.addEventListener('close', async () => {
socket.addEventListener('close', () => {
if (!isOpened) {
reject(new Error('WebSocket closed without opened.'))
return
Expand Down
Loading