Skip to content

Commit 50e0897

Browse files
committed
fix: watch type only files, clear cache on rebuild
1 parent 0adace9 commit 50e0897

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
6363

6464
let farmPluginContext: UnpluginBuildContext
6565

66-
const outputFiles: Record<string, Output> = {}
66+
let outputFiles: Record<string, Output> = Object.create(null)
6767
function addOutput(filename: string, output: Omit<Output, 'ext'>) {
6868
const name = stripExt(filename)
6969
const ext = path.extname(filename)
@@ -84,6 +84,7 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
8484
buildStart() {
8585
// eslint-disable-next-line @typescript-eslint/no-this-alias
8686
farmPluginContext = this
87+
outputFiles = Object.create(null)
8788
},
8889

8990
transformInclude: (id) => filter(id),
@@ -239,23 +240,28 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
239240
if (options.extraOutdir) {
240241
emitName = path.join(options.extraOutdir || '', emitName)
241242
}
243+
242244
debug('[rollup] emit dts file:', emitName)
245+
const originalFileName = srcFilename + ext
246+
243247
if (options.sourceMap && map && outDir) {
244248
source = appendMapUrl(source, emitName)
245249
this.emitFile({
246250
type: 'asset',
247251
fileName: `${emitName}.map`,
248252
source: generateDtsMap(
249253
map,
250-
srcFilename + ext,
254+
originalFileName,
251255
path.join(outDir, emitName),
252256
),
257+
originalFileName,
253258
})
254259
}
255260
this.emitFile({
256261
type: 'asset',
257262
fileName: emitName,
258263
source,
264+
originalFileName,
259265
})
260266
}
261267
}

0 commit comments

Comments
 (0)