Skip to content

Commit 8fe0a72

Browse files
committedMar 12, 2025
re-use utils functions
1 parent f404946 commit 8fe0a72

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎src/compiler/bundle/file-load-plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { normalizeFsPath } from '@utils';
1+
import { isDtsFile, normalizeFsPath } from '@utils';
22
import type { Plugin } from 'rollup';
33

44
import { InMemoryFileSystem } from '../sys/in-memory-fs';
@@ -9,7 +9,7 @@ export const fileLoadPlugin = (fs: InMemoryFileSystem): Plugin => {
99

1010
load(id) {
1111
const fsFilePath = normalizeFsPath(id);
12-
if (id.endsWith('.d.ts') || id.endsWith('.d.mts') || id.endsWith('.d.cts')) {
12+
if (isDtsFile(fsFilePath)) {
1313
return '';
1414
}
1515
return fs.readFile(fsFilePath);

‎src/compiler/bundle/typescript-plugin.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isString, normalizeFsPath } from '@utils';
1+
import { isDtsFile, isString, normalizeFsPath } from '@utils';
22
import { basename, isAbsolute } from 'path';
33
import type { LoadResult, Plugin, TransformResult } from 'rollup';
44
import ts from 'typescript';
@@ -90,7 +90,7 @@ export const resolveIdWithTypeScript = (config: d.ValidatedConfig, compilerCtx:
9090
const tsResolvedPath = tsResolved.resolvedModule.resolvedFileName;
9191
if (
9292
isString(tsResolvedPath) &&
93-
!(tsResolvedPath.endsWith('.d.ts') || tsResolvedPath.endsWith('.d.mts') || tsResolvedPath.endsWith('.d.cts'))
93+
!isDtsFile(tsResolvedPath)
9494
) {
9595
return tsResolvedPath;
9696
}

0 commit comments

Comments
 (0)
Failed to load comments.