From d2e4d448363c7285112e284203c0e34d47002d08 Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Fri, 17 Nov 2023 12:26:34 -0500 Subject: [PATCH] fix(build): prevent index.ts file from being copied into dist --- packages/module/scripts/writeClassMaps.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/module/scripts/writeClassMaps.js b/packages/module/scripts/writeClassMaps.js index 0a2f3755..77879944 100644 --- a/packages/module/scripts/writeClassMaps.js +++ b/packages/module/scripts/writeClassMaps.js @@ -51,6 +51,17 @@ function writeIndex(fileName) { } } +function isNotTS(file) { + const isTS = file.endsWith('.ts'); + const isNotDeclaration = !file.endsWith('.d.ts'); + + if (isTS && isNotDeclaration) { + return false; + } + + return true; +} + /** * @param {any} classMaps Map of file names to classMaps */ @@ -65,10 +76,10 @@ function writeClassMaps(classMaps) { copyFileSync(file, join(outDir, outPath)); ensureDirSync(esmDistDir); - copySync(outDir, esmDistDir); + copySync(outDir, esmDistDir, { filter: isNotTS }); ensureDirSync(jsDistDir); - copySync(outDir, jsDistDir); + copySync(outDir, jsDistDir, { filter: isNotTS }); }); // eslint-disable-next-line no-console