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: reduce diffs with v6 branch #17942

Merged
merged 2 commits into from
Aug 24, 2024
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
17 changes: 8 additions & 9 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export async function build(
'production',
)
const options = config.build
const { logger } = config
const { root, logger, packageCache } = config
const ssr = !!options.ssr
const libOptions = options.lib

Expand All @@ -486,7 +486,7 @@ export async function build(
),
)

const resolve = (p: string) => path.resolve(config.root, p)
const resolve = (p: string) => path.resolve(root, p)
const input = libOptions
? options.rollupOptions?.input ||
(typeof libOptions.entry === 'string'
Expand Down Expand Up @@ -641,8 +641,7 @@ export async function build(
ssrNodeBuild || libOptions
? resolveOutputJsExtension(
format,
findNearestPackageData(config.root, config.packageCache)?.data
.type,
findNearestPackageData(root, packageCache)?.data.type,
)
: 'js'
return {
Expand All @@ -665,9 +664,9 @@ export async function build(
libOptions,
format,
name,
config.root,
root,
jsExt,
config.packageCache,
packageCache,
)
: path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
chunkFileNames: libOptions
Expand Down Expand Up @@ -702,13 +701,13 @@ export async function build(
}

const resolvedOutDirs = getResolvedOutDirs(
config.root,
root,
options.outDir,
options.rollupOptions?.output,
)
const emptyOutDir = resolveEmptyOutDir(
options.emptyOutDir,
config.root,
root,
resolvedOutDirs,
logger,
)
Expand All @@ -718,10 +717,10 @@ export async function build(
logger.info(colors.cyan(`\nwatching for file changes...`))

const resolvedChokidarOptions = resolveChokidarOptions(
config,
config.build.watch.chokidar,
resolvedOutDirs,
emptyOutDir,
config.cacheDir,
)

const { watch } = await import('rollup')
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,13 @@ export async function _createServer(
resolvedOutDirs,
)
const resolvedWatchOptions = resolveChokidarOptions(
config,
{
disableGlobbing: true,
...serverConfig.watch,
},
resolvedOutDirs,
emptyOutDir,
config.cacheDir,
)

const middlewares = connect() as Connect.Server
Expand Down
5 changes: 2 additions & 3 deletions packages/vite/src/node/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { OutputOptions } from 'rollup'
import colors from 'picocolors'
import { withTrailingSlash } from '../shared/utils'
import { arraify, normalizePath } from './utils'
import type { ResolvedConfig } from './config'
import type { Logger } from './logger'

export function getResolvedOutDirs(
Expand Down Expand Up @@ -50,17 +49,17 @@ export function resolveEmptyOutDir(
}

export function resolveChokidarOptions(
config: ResolvedConfig,
options: WatchOptions | undefined,
resolvedOutDirs: Set<string>,
emptyOutDir: boolean,
cacheDir: string,