Skip to content

Commit

Permalink
fix(codegen): match file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jonambas committed Apr 8, 2024
1 parent 75f3b91 commit c039496
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,15 @@ export const codegen = (
context: PluginContext,
): MaybeAsyncReturn<void | Artifact[]> => {
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;

Expand Down

0 comments on commit c039496

Please sign in to comment.