From c22d1c13d5cc97117d690a31518bd972c9f7c55f Mon Sep 17 00:00:00 2001 From: PeachScript Date: Thu, 7 Sep 2023 11:37:54 +0800 Subject: [PATCH] refactor: compatible with windows os --- src/builder/bundless/loaders/index.ts | 4 +++- src/builder/bundless/loaders/javascript/index.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/builder/bundless/loaders/index.ts b/src/builder/bundless/loaders/index.ts index 6925ccf5..2bd10b71 100644 --- a/src/builder/bundless/loaders/index.ts +++ b/src/builder/bundless/loaders/index.ts @@ -1,3 +1,4 @@ +import { winPath } from '@umijs/utils'; import fs from 'fs'; import { runLoaders } from 'loader-runner'; import type { IApi } from '../../../types'; @@ -63,6 +64,7 @@ export default async ( const cacheRet = await cache.get(cacheKey, ''); // use cache first + /* istanbul ignore if -- @preserve */ if (cacheRet) { const tsconfig = /\.tsx?$/.test(fileAbsPath) ? getTsconfig(opts.cwd) @@ -75,7 +77,7 @@ export default async ( // FIXME: shit code for avoid invalid declaration value when tsconfig changed declaration: tsconfig?.options.declaration && - tsconfig?.fileNames.includes(fileAbsPath), + tsconfig?.fileNames.includes(winPath(fileAbsPath)), }, }); } diff --git a/src/builder/bundless/loaders/javascript/index.ts b/src/builder/bundless/loaders/javascript/index.ts index 1263eb65..b3da638d 100644 --- a/src/builder/bundless/loaders/javascript/index.ts +++ b/src/builder/bundless/loaders/javascript/index.ts @@ -1,3 +1,4 @@ +import { winPath } from '@umijs/utils'; import { getTsconfig } from '../../dts'; import type { IBundlessLoader, IJSTransformer, ILoaderOutput } from '../types'; @@ -37,7 +38,7 @@ const jsLoader: IBundlessLoader = function (content) { : undefined; if ( tsconfig?.options.declaration && - tsconfig?.fileNames.includes(this.resource) + tsconfig?.fileNames.includes(winPath(this.resource)) ) { outputOpts.declaration = true; }