Skip to content

Commit

Permalink
chore: reduce diffs with v6 branch (#17942)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Aug 24, 2024
1 parent 561b940 commit bf9065a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
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,
): WatchOptions {
const { ignored: ignoredList, ...otherOptions } = options ?? {}
const ignored: WatchOptions['ignored'] = [
'**/.git/**',
'**/node_modules/**',
'**/test-results/**', // Playwright
glob.escapePath(config.cacheDir) + '/**',
glob.escapePath(cacheDir) + '/**',
...arraify(ignoredList || []),
]
if (emptyOutDir) {
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'node:path'
import { defineConfig } from 'vitest/config'

const timeout = process.env.CI ? 50000 : 30000
const timeout = process.env.PWDEBUG ? Infinity : process.env.CI ? 50000 : 30000

export default defineConfig({
resolve: {
Expand Down

0 comments on commit bf9065a

Please sign in to comment.