From da90b2f4f73036acf2a87c3f74d9cc90bcbaab0e Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Fri, 12 Aug 2022 08:46:44 +0900 Subject: [PATCH] fix: remove warning --- packages/vite/src/node/build.ts | 4 +--- packages/vite/src/node/server/index.ts | 9 ++++----- packages/vite/src/node/utils.ts | 19 ------------------- packages/vite/src/node/watch.ts | 19 +------------------ 4 files changed, 6 insertions(+), 45 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index be4ce76dfe0c6a..174e5a33d9169a 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -506,9 +506,7 @@ async function doBuild( } const resolvedChokidarOptions = resolveChokidarOptions( - config.logger, - config.build.watch.chokidar, - 'build.watch.chokidar' + config.build.watch.chokidar ) const { watch } = await import('rollup') diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index c3451069d96790..ee58ca6564753c 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -301,11 +301,10 @@ export async function createServer( ) const { middlewareMode } = serverConfig - const resolvedWatchOptions = resolveChokidarOptions( - config.logger, - { disableGlobbing: true, ...serverConfig.watch }, - 'server.watch' - ) + const resolvedWatchOptions = resolveChokidarOptions({ + disableGlobbing: true, + ...serverConfig.watch + }) const middlewares = connect() as Connect.Server const httpServer = middlewareMode diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 930efec8e2dbf8..85f85adf3cf550 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -1144,22 +1144,3 @@ export const isNonDriveRelativeAbsolutePath = (p: string): boolean => { if (!isWindows) return p.startsWith('/') return windowsDrivePathPrefixRE.test(p) } - -/** - * returns `true` for WSL2 including docker running on WSL2 - * - * https://github.com/microsoft/WSL/issues/423#issuecomment-844418910 - */ -export const isWSL2 = (() => { - const release = os.release() - // Example: `5.10.102.1-microsoft-standard-WSL2` - if (release.includes('WSL2')) { - // "Docker Desktop for Windows with WSL2 backend" and "Docker installed in WSL" comes here too - return true - } - - // Windows Example: `10.0.19044` - // WSL1 Example: `4.4.0-19041-Microsoft` - // Docker Desktop for Windows with WSL2 backend Example: `5.10.76-linuxkit` - return false -})() diff --git a/packages/vite/src/node/watch.ts b/packages/vite/src/node/watch.ts index 1d0bcf762772ef..378610e28f3799 100644 --- a/packages/vite/src/node/watch.ts +++ b/packages/vite/src/node/watch.ts @@ -1,12 +1,7 @@ import type { WatchOptions } from 'types/chokidar' -import colors from 'picocolors' -import type { Logger } from './logger' -import { isWSL2 } from './utils' export function resolveChokidarOptions( - logger: Logger, - options: WatchOptions | undefined, - optionName: string + options: WatchOptions | undefined ): WatchOptions { const { ignored = [], ...otherOptions } = options ?? {} @@ -22,17 +17,5 @@ export function resolveChokidarOptions( ...otherOptions } - if (isWSL2 && resolvedWatchOptions.usePolling === undefined) { - logger.warn( - colors.yellow( - colors.bold(`(!) `) + - 'Default file system watching might not work with your setup due to a limitation of WSL2. ' + - 'HMR and other features will not work when file system watching is not working. ' + - `To suppress this warning, set true or false to "${optionName}.usePolling". ` + - 'More information: https://vitejs.dev/config/server-options.html#server-watch' - ) - ) - } - return resolvedWatchOptions }