Skip to content

Commit b0d91a9

Browse files
committed
chore: fix lint
1 parent 3561dce commit b0d91a9

File tree

16 files changed

+267
-247
lines changed

16 files changed

+267
-247
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"overrides": {
101101
"vitest>vite": "npm:vite@^6.2.6",
102102
"vite": "workspace:rolldown-vite@*"
103-
},
103+
},
104104
"patchedDependencies": {
105105
"http-proxy@1.18.1": "patches/http-proxy@1.18.1.patch",
106106
"sirv@3.0.1": "patches/sirv@3.0.1.patch",

packages/vite/src/node/build.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ function resolveConfigToBuild(
568568
**/
569569
async function buildEnvironment(
570570
environment: BuildEnvironment,
571-
server?: ViteDevServer
571+
server?: ViteDevServer,
572572
): Promise<RolldownOutput | RolldownOutput[] /* | RollupWatcher */> {
573573
const { root, packageCache, mode } = environment.config
574574
const options = environment.config.build
@@ -655,12 +655,12 @@ async function buildEnvironment(
655655
'.css': 'js',
656656
},
657657
experimental: {
658-
hmr: true
658+
hmr: true,
659659
// hmr: server ? {
660660
// host: server._currentServerHost!,
661661
// port: server._currentServerPort!,
662662
// } : false,
663-
}
663+
},
664664
}
665665

666666
/**
@@ -803,13 +803,14 @@ async function buildEnvironment(
803803
output.format === 'iife' ||
804804
(isSsrTargetWebworkerEnvironment &&
805805
(typeof input === 'string' || Object.keys(input).length === 1)),
806-
minify: mode === 'production' ?
807-
options.minify === 'oxc'
808-
? true
809-
: options.minify === false
810-
? 'dce-only'
811-
: false
812-
: false,
806+
minify:
807+
mode === 'production'
808+
? options.minify === 'oxc'
809+
? true
810+
: options.minify === false
811+
? 'dce-only'
812+
: false
813+
: false,
813814
...output,
814815
}
815816
}
@@ -901,7 +902,7 @@ async function buildEnvironment(
901902
// TODO(underfin): using the generate at development build could be improve performance.
902903
res.push(await bundle![options.write ? 'write' : 'generate'](output))
903904
}
904-
905+
905906
if (server) {
906907
// watching the files
907908
for (const file of bundle!.watchFiles) {
@@ -911,34 +912,34 @@ async function buildEnvironment(
911912
}
912913

913914
// Write the output files to memory
914-
for(const output of res) {
915+
for (const output of res) {
915916
for (const outputFile of output.output) {
916-
server.memoryFiles[outputFile.fileName] = outputFile.type === 'chunk' ? outputFile.code : outputFile.source;
917+
server.memoryFiles[outputFile.fileName] =
918+
outputFile.type === 'chunk' ? outputFile.code : outputFile.source
917919
}
918920
}
919921
}
920922
return res
921923
}
922924

923-
924925
if (server) {
925926
server.watcher.on('change', async (file) => {
926927
const startTime = Date.now()
927-
const patch = await bundle!.generateHmrPatch([file]);
928+
const patch = await bundle!.generateHmrPatch([file])
928929
if (patch) {
929-
const url = `${Date.now()}.js`;
930-
server.memoryFiles[url] = patch;
930+
const url = `${Date.now()}.js`
931+
server.memoryFiles[url] = patch
931932
// TODO(underfin): fix ws msg typing
932-
// @ts-expect-error
933+
// @ts-expect-error fix ws msg typing
933934
server.ws.send({
934935
type: 'update',
935-
url
936-
});
936+
url,
937+
})
937938
logger.info(
938939
`${colors.green(`✓ Found ${path.relative(root, file)} changed, rebuilt in ${displayTime(Date.now() - startTime)}`)}`,
939940
)
940941

941-
await build();
942+
await build()
942943
}
943944
})
944945
}
@@ -1673,7 +1674,7 @@ export interface ViteBuilder {
16731674
buildApp(server?: ViteDevServer): Promise<void>
16741675
build(
16751676
environment: BuildEnvironment,
1676-
server?: ViteDevServer
1677+
server?: ViteDevServer,
16771678
): Promise<RolldownOutput | RolldownOutput[] /* | RollupWatcher */>
16781679
}
16791680

@@ -1695,7 +1696,10 @@ export interface BuilderOptions {
16951696
buildApp?: (builder: ViteBuilder, server?: ViteDevServer) => Promise<void>
16961697
}
16971698

1698-
async function defaultBuildApp(builder: ViteBuilder, server?: ViteDevServer): Promise<void> {
1699+
async function defaultBuildApp(
1700+
builder: ViteBuilder,
1701+
server?: ViteDevServer,
1702+
): Promise<void> {
16991703
for (const environment of Object.values(builder.environments)) {
17001704
await builder.build(environment, server)
17011705
}

packages/vite/src/node/cli.ts

Lines changed: 103 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -176,111 +176,123 @@ cli
176176
`[boolean] force the optimizer to ignore the cache and re-bundle`,
177177
)
178178
// TODO(underfin): Consider how to merge the build option into dev command.
179-
.action(async (root: string, options: BuildEnvironmentOptions & BuilderCLIOptions & ServerOptions & GlobalCLIOptions) => {
180-
filterDuplicateOptions(options)
181-
// output structure is preserved even after bundling so require()
182-
// is ok here
183-
const { createServer } = await import('./server')
184-
try {
185-
const server = await createServer({
186-
root,
187-
base: options.base,
188-
mode: options.mode,
189-
configFile: options.config,
190-
configLoader: options.configLoader,
191-
logLevel: options.logLevel,
192-
clearScreen: options.clearScreen,
193-
server: cleanGlobalCLIOptions(options),
194-
forceOptimizeDeps: options.force,
195-
})
179+
.action(
180+
async (
181+
root: string,
182+
options: BuildEnvironmentOptions &
183+
BuilderCLIOptions &
184+
ServerOptions &
185+
GlobalCLIOptions,
186+
) => {
187+
filterDuplicateOptions(options)
188+
// output structure is preserved even after bundling so require()
189+
// is ok here
190+
const { createServer } = await import('./server')
191+
try {
192+
const server = await createServer({
193+
root,
194+
base: options.base,
195+
mode: options.mode,
196+
configFile: options.config,
197+
configLoader: options.configLoader,
198+
logLevel: options.logLevel,
199+
clearScreen: options.clearScreen,
200+
server: cleanGlobalCLIOptions(options),
201+
forceOptimizeDeps: options.force,
202+
})
196203

197-
if (!server.httpServer) {
198-
throw new Error('HTTP server not available')
199-
}
204+
if (!server.httpServer) {
205+
throw new Error('HTTP server not available')
206+
}
200207

201-
const { createBuilder } = await import('./build')
208+
const { createBuilder } = await import('./build')
202209

203-
const buildOptions: BuildEnvironmentOptions = cleanBuilderCLIOptions(options)
210+
const buildOptions: BuildEnvironmentOptions =
211+
cleanBuilderCLIOptions(options)
204212

205-
const inlineConfig: InlineConfig = {
206-
root,
207-
base: options.base,
208-
mode: options.mode,
209-
configFile: options.config,
210-
configLoader: options.configLoader,
211-
logLevel: options.logLevel,
212-
clearScreen: options.clearScreen,
213-
build: buildOptions,
214-
...(options.app ? { builder: {} } : {}),
215-
}
216-
const builder = await createBuilder(inlineConfig, null, 'serve')
217-
await builder.buildApp(server)
213+
const inlineConfig: InlineConfig = {
214+
root,
215+
base: options.base,
216+
mode: options.mode,
217+
configFile: options.config,
218+
configLoader: options.configLoader,
219+
logLevel: options.logLevel,
220+
clearScreen: options.clearScreen,
221+
build: buildOptions,
222+
...(options.app ? { builder: {} } : {}),
223+
}
224+
const builder = await createBuilder(inlineConfig, null, 'serve')
225+
await builder.buildApp(server)
218226

219-
await server.listen()
227+
await server.listen()
220228

221-
const info = server.config.logger.info
229+
const info = server.config.logger.info
222230

223-
const modeString =
224-
options.mode && options.mode !== 'development'
225-
? ` ${colors.bgGreen(` ${colors.bold(options.mode)} `)}`
231+
const modeString =
232+
options.mode && options.mode !== 'development'
233+
? ` ${colors.bgGreen(` ${colors.bold(options.mode)} `)}`
234+
: ''
235+
const viteStartTime = global.__vite_start_time ?? false
236+
const startupDurationString = viteStartTime
237+
? colors.dim(
238+
`ready in ${colors.reset(
239+
colors.bold(Math.ceil(performance.now() - viteStartTime)),
240+
)} ms`,
241+
)
226242
: ''
227-
const viteStartTime = global.__vite_start_time ?? false
228-
const startupDurationString = viteStartTime
229-
? colors.dim(
230-
`ready in ${colors.reset(
231-
colors.bold(Math.ceil(performance.now() - viteStartTime)),
232-
)} ms`,
233-
)
234-
: ''
235-
const hasExistingLogs =
236-
process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0
243+
const hasExistingLogs =
244+
process.stdout.bytesWritten > 0 || process.stderr.bytesWritten > 0
237245

238-
info(
239-
`\n ${colors.green(
240-
`${colors.bold('VITE')} v${VERSION}`,
241-
)}${modeString} ${startupDurationString}\n`,
242-
{
243-
clear: !hasExistingLogs,
244-
},
245-
)
246+
info(
247+
`\n ${colors.green(
248+
`${colors.bold('VITE')} v${VERSION}`,
249+
)}${modeString} ${startupDurationString}\n`,
250+
{
251+
clear: !hasExistingLogs,
252+
},
253+
)
246254

247-
server.printUrls()
248-
const customShortcuts: CLIShortcut<typeof server>[] = []
249-
if (profileSession) {
250-
customShortcuts.push({
251-
key: 'p',
252-
description: 'start/stop the profiler',
253-
async action(server) {
254-
if (profileSession) {
255-
await stopProfiler(server.config.logger.info)
256-
} else {
257-
const inspector = await import('node:inspector').then(
258-
(r) => r.default,
259-
)
260-
await new Promise<void>((res) => {
261-
profileSession = new inspector.Session()
262-
profileSession.connect()
263-
profileSession.post('Profiler.enable', () => {
264-
profileSession!.post('Profiler.start', () => {
265-
server.config.logger.info('Profiler started')
266-
res()
255+
server.printUrls()
256+
const customShortcuts: CLIShortcut<typeof server>[] = []
257+
if (profileSession) {
258+
customShortcuts.push({
259+
key: 'p',
260+
description: 'start/stop the profiler',
261+
async action(server) {
262+
if (profileSession) {
263+
await stopProfiler(server.config.logger.info)
264+
} else {
265+
const inspector = await import('node:inspector').then(
266+
(r) => r.default,
267+
)
268+
await new Promise<void>((res) => {
269+
profileSession = new inspector.Session()
270+
profileSession.connect()
271+
profileSession.post('Profiler.enable', () => {
272+
profileSession!.post('Profiler.start', () => {
273+
server.config.logger.info('Profiler started')
274+
res()
275+
})
267276
})
268277
})
269-
})
270-
}
278+
}
279+
},
280+
})
281+
}
282+
server.bindCLIShortcuts({ print: true, customShortcuts })
283+
} catch (e) {
284+
const logger = createLogger(options.logLevel)
285+
logger.error(
286+
colors.red(`error when starting dev server:\n${e.stack}`),
287+
{
288+
error: e,
271289
},
272-
})
290+
)
291+
stopProfiler(logger.info)
292+
process.exit(1)
273293
}
274-
server.bindCLIShortcuts({ print: true, customShortcuts })
275-
} catch (e) {
276-
const logger = createLogger(options.logLevel)
277-
logger.error(colors.red(`error when starting dev server:\n${e.stack}`), {
278-
error: e,
279-
})
280-
stopProfiler(logger.info)
281-
process.exit(1)
282-
}
283-
})
294+
},
295+
)
284296

285297
// build
286298
cli

packages/vite/src/node/plugins/asset.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
204204
// Force rollup to keep this module from being shared between other entry points if it's an entrypoint.
205205
// If the resulting chunk is empty, it will be removed in generateBundle.
206206
moduleSideEffects:
207-
// config.command === 'build' &&
208-
this.getModuleInfo(id)?.isEntry
209-
? 'no-treeshake'
210-
: false,
211-
meta: /* config.command === 'build' ? */ { 'vite:asset': true } /* : undefined */,
207+
// config.command === 'build' &&
208+
this.getModuleInfo(id)?.isEntry ? 'no-treeshake' : false,
209+
meta: /* config.command === 'build' ? */ {
210+
'vite:asset': true,
211+
} /* : undefined */,
212212
moduleType: 'js', // NOTE: needs to be set to avoid double `export default` in `.txt`s
213213
}
214214
},
@@ -288,7 +288,7 @@ export async function fileToUrl(
288288
// if (environment.config.command === 'serve') {
289289
// return fileToDevUrl(environment, id)
290290
// } else {
291-
return fileToBuiltUrl(pluginContext, id)
291+
return fileToBuiltUrl(pluginContext, id)
292292
// }
293293
}
294294

packages/vite/src/node/plugins/assetImportMetaUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
3737
...config.resolve,
3838
root: config.root,
3939
isProduction: config.isProduction,
40-
isBuild: true , // config.command === 'build'
40+
isBuild: true, // config.command === 'build'
4141
packageCache: config.packageCache,
4242
asSrc: true,
4343
}

0 commit comments

Comments
 (0)