Calculate IconoirContext path

This commit is contained in:
Pascal Jufer 2023-10-29 02:41:31 +01:00
parent 4a49bb6e9e
commit 1b58f4b357
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View file

@ -50,7 +50,6 @@ const defaultTsOptions = {
export default async (ctx, target) => {
const localJsTargets = jsTargets.map((jsTarget) => ({
...jsTarget,
iconTemplate: getIconTemplate(target.native, jsTarget.ext),
}));
const promises = [];
@ -121,6 +120,18 @@ export default async (ctx, target) => {
mainIndex.add(mainIndexComponentName, jsPath);
variantIndex.add(icon.pascalName, jsPath);
if (!jsTarget.iconTemplate) {
jsTarget.iconTemplate = getIconTemplate(
target.native,
toImportPath(
path.relative(
path.join(jsTarget.path, variant),
jsTarget.iconoirContextPath,
),
),
);
}
const reactComponent = getReactComponent(
icon.path,
target.native,

View file

@ -1,6 +1,6 @@
import { generateImport } from '../../../lib/import-export.js';
export function getTemplate(native, ext) {
export function getTemplate(native, iconoirContextPath) {
return (variables, { tpl }) => {
variables.props[0].name = 'passedProps';
@ -13,7 +13,7 @@ export function getTemplate(native, ext) {
const useClientDirective = native ? '' : '"use client";';
const iconoirContextImport = generateImport(
['IconoirContext'],
`../IconoirContext.${ext}`,
iconoirContextPath,
);
return tpl`