From 26ae37dab1759db9c59578f5740e23a541c0ce06 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Thu, 20 Apr 2023 17:52:12 +0800 Subject: [PATCH 1/5] fix(build): make output warning message clearer --- packages/vite/src/node/build.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index f7285332671b91..5d022a36ed379c 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -1,5 +1,6 @@ import fs from 'node:fs' import path from 'node:path' +import readLine from 'node:readline' import colors from 'picocolors' import type { ExternalOption, @@ -907,6 +908,8 @@ export function onRollupWarning( return } + readLine.clearLine(process.stdout, 0) + readLine.cursorTo(process.stdout, 0) warn(warning) } From 207883653fcb2ead95be714b4a6d42cb34899d03 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 21 Apr 2023 09:44:28 +0800 Subject: [PATCH 2/5] fix: clear line before calling userOnWarn --- packages/vite/src/node/build.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index 5d022a36ed379c..abc65464c9c934 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -908,11 +908,11 @@ export function onRollupWarning( return } - readLine.clearLine(process.stdout, 0) - readLine.cursorTo(process.stdout, 0) warn(warning) } + readLine.clearLine(process.stdout, 0) + readLine.cursorTo(process.stdout, 0) const userOnWarn = config.build.rollupOptions?.onwarn if (userOnWarn) { userOnWarn(warning, viteWarn) From 2971038059e79a5408886adff82f91422a28c76c Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 7 Jun 2023 21:46:07 +0800 Subject: [PATCH 3/5] fix: use process.stdout --- packages/vite/src/node/build.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index abc65464c9c934..ff93f79087e876 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -1,6 +1,5 @@ import fs from 'node:fs' import path from 'node:path' -import readLine from 'node:readline' import colors from 'picocolors' import type { ExternalOption, @@ -911,8 +910,8 @@ export function onRollupWarning( warn(warning) } - readLine.clearLine(process.stdout, 0) - readLine.cursorTo(process.stdout, 0) + process.stdout.clearLine(0) + process.stdout.cursorTo(0) const userOnWarn = config.build.rollupOptions?.onwarn if (userOnWarn) { userOnWarn(warning, viteWarn) From 7ca5d067070f040a43509f10e3894b35db0ba2b8 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 7 Jun 2023 22:09:22 +0800 Subject: [PATCH 4/5] fix: add tty judge --- packages/vite/src/node/build.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index ff93f79087e876..b9f9895a07dfa3 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -865,6 +865,7 @@ const dynamicImportWarningIgnoreList = [ `statically analyzed`, ] +const tty = process.stdout.isTTY && !process.env.CI export function onRollupWarning( warning: RollupWarning, warn: WarningHandler, @@ -910,8 +911,10 @@ export function onRollupWarning( warn(warning) } - process.stdout.clearLine(0) - process.stdout.cursorTo(0) + if (tty) { + process.stdout.clearLine(0) + process.stdout.cursorTo(0) + } const userOnWarn = config.build.rollupOptions?.onwarn if (userOnWarn) { userOnWarn(warning, viteWarn) From c7cef6fd6737e169211e5559d29a415000e8e8ae Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Wed, 7 Jun 2023 22:11:23 +0800 Subject: [PATCH 5/5] fix: update --- packages/vite/src/node/build.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index b9f9895a07dfa3..2488fc6edaa5fa 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -865,7 +865,6 @@ const dynamicImportWarningIgnoreList = [ `statically analyzed`, ] -const tty = process.stdout.isTTY && !process.env.CI export function onRollupWarning( warning: RollupWarning, warn: WarningHandler, @@ -911,6 +910,7 @@ export function onRollupWarning( warn(warning) } + const tty = process.stdout.isTTY && !process.env.CI if (tty) { process.stdout.clearLine(0) process.stdout.cursorTo(0)