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 bb0f4df07f75..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), }, }); } @@ -48,7 +48,7 @@ export default function () { enter(path: Babel.NodePath, state: any) { opts = state.opts; // @ts-ignore - const file = path?.hub.file.opts.filename; + const file = winPath(path?.hub.file.opts.filename); // @ts-ignore const cache = this.cache; // reset cache