From 5849bf0d241e35f9d6d51d182b3e281fc6aefc6c Mon Sep 17 00:00:00 2001 From: sh0ckey1 Date: Mon, 4 Nov 2024 23:40:12 +0800 Subject: [PATCH] fix: handling windows path matching failures --- packages/preset-umi/src/features/check/check.ts | 6 +++++- packages/preset-umi/src/features/transform/babelPlugin.ts | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/preset-umi/src/features/check/check.ts b/packages/preset-umi/src/features/check/check.ts index c8d428d70c43..1df721dcd44a 100644 --- a/packages/preset-umi/src/features/check/check.ts +++ b/packages/preset-umi/src/features/check/check.ts @@ -83,6 +83,10 @@ export default (api: IApi) => { }); function isAbsolutePath(path: string) { - return path.startsWith('/') || path.startsWith('@fs/'); + return ( + path.startsWith('/') || + path.startsWith('@fs/') || + /^[A-Za-z]:\//.test(path) // fix windows path after transform by winPath method + ); } }; diff --git a/packages/preset-umi/src/features/transform/babelPlugin.ts b/packages/preset-umi/src/features/transform/babelPlugin.ts index 529865e3557f..c9de825b9276 100644 --- a/packages/preset-umi/src/features/transform/babelPlugin.ts +++ b/packages/preset-umi/src/features/transform/babelPlugin.ts @@ -36,9 +36,9 @@ export default function () { ) { opts.onCheckCode({ args: { - ...cache.get(state.opts.filename), - file: state.opts.filename, - isFromTmp: state.opts.filename.startsWith(opts.absTmpPath), + ...cache.get(filename), + file: filename, + isFromTmp: filename.startsWith(opts.absTmpPath), }, }); }