From c0394964914f354db976fb6d4307054ed2e6442e Mon Sep 17 00:00:00 2001 From: jonambas Date: Sun, 7 Apr 2024 23:47:44 -0400 Subject: [PATCH] fix(codegen): match file extensions --- src/codegen.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/codegen.ts b/src/codegen.ts index db87cb3..b99ba54 100644 --- a/src/codegen.ts +++ b/src/codegen.ts @@ -13,22 +13,15 @@ export const codegen = ( context: PluginContext, ): MaybeAsyncReturn => { const { map } = context; - let ext = 'mjs'; - let dtsExt = 'ts'; const cssFn = args.artifacts.find((a) => a.id === 'css-fn'); const index = args.artifacts.find((a) => a.id === 'css-index'); - - for (const artifact of index?.files || []) { - if (artifact.file.includes('.d.')) { - dtsExt = artifact.file.split('.').at(-1) || dtsExt; - } else { - ext = artifact.file.split('.').at(-1) || ext; - } - } - - const indexFile = index?.files.find((f) => f.file.includes(`index.${ext}`)); + const indexFile = index?.files.find( + (f) => f.file.includes('index.mjs') || f.file.includes('index.js'), + ); const indexDtsFile = index?.files.find((f) => f.file.includes('index.d.')); + const ext = indexFile?.file.split('.').at(-1); + const dtsExt = indexDtsFile?.file.split('.').at(-1); if (!cssFn || !indexFile || !indexDtsFile) return args.artifacts;