Skip to content

The Open Standard for Generative UI

Minor tailwind plugin fixes (#22)

Hrijul Bhatnagar673de800b583
diff --git a/frontend-sdk/packages/react-ui/src/lib/tailwind/generateTailwindPlugin.ts b/frontend-sdk/packages/react-ui/src/lib/tailwind/generateTailwindPlugin.ts
index 87e5f0f55..4a2c2874f 100644
--- a/frontend-sdk/packages/react-ui/src/lib/tailwind/generateTailwindPlugin.ts
+++ b/frontend-sdk/packages/react-ui/src/lib/tailwind/generateTailwindPlugin.ts
@@ -92,7 +92,10 @@ const generateAddComponentsCalls = async () => {
const addComponentsCallPromises = componentsAndPaths.map(async (component) => {
if (UNSTYLED_COMPONENTS.has(component.name)) return;
- if (!component.stylePath) throw new Error(`No styles found for component: ${component.name}`);
+ if (!component.stylePath)
+ throw new Error(
+ `No styles found for component: ${component.name}. If this is intentional, add component name to UNSTYLED_COMPONENTS in generateTailwindPlugin.ts`,
+ );
const componentStyle = fs.readFileSync(path.join(component.path, component.stylePath), "utf-8");
diff --git a/frontend-sdk/packages/react-ui/src/lib/tailwind/pluginTemplate b/frontend-sdk/packages/react-ui/src/lib/tailwind/pluginTemplate
index 3975e49b1..74d8d1a4c 100644
--- a/frontend-sdk/packages/react-ui/src/lib/tailwind/pluginTemplate
+++ b/frontend-sdk/packages/react-ui/src/lib/tailwind/pluginTemplate
@@ -1,6 +1,4 @@
import plugin from "tailwindcss/plugin";
-import type { Config, PluginCreator } from "tailwindcss/types/config";
-import { getComponentsDependencies } from "./utils";
interface CrayonPluginOptions {
components?: `<COMPONENT_TYPES$>`;
@@ -12,7 +10,7 @@ const crayonPlugin = plugin.withOptions<CrayonPluginOptions>(
const includeAllComponents = `<INCLUDE_ALL_COMPONENTS$>`;
const includeAll =
components?.some((component) => includeAllComponents.has(component)) || !components;
- const dependencies = await getComponentsDependencies(components ?? [], componentDependencyMap);
+ const dependencies = await getComponentDependencies(components ?? []);
const componentsToAdd = Array.from(new Set([...(components ?? []), ...dependencies]));
@@ -22,4 +20,11 @@ const crayonPlugin = plugin.withOptions<CrayonPluginOptions>(
const componentDependencyMap = `<COMPONENT_DEPENDENCY_MAP$>`;
+const getComponentDependencies = async (componentNames: (keyof typeof componentDependencyMap)[]) => {
+ const dependencies = componentNames
+ .map((componentName) => componentDependencyMap[componentName])
+ .flat();
+ return Array.from(new Set([...componentNames, ...dependencies]));
+};
+
export default crayonPlugin;
diff --git a/frontend-sdk/packages/react-ui/tsconfig.json b/frontend-sdk/packages/react-ui/tsconfig.json
index a6f81ed16..19697d569 100644
--- a/frontend-sdk/packages/react-ui/tsconfig.json
+++ b/frontend-sdk/packages/react-ui/tsconfig.json
@@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
- "exclude": ["./src/lib/tailwind/generateTailwindPlugin.ts"],
+ "exclude": ["./src/lib/tailwind"],
"compilerOptions": {
"moduleResolution": "bundler",
"module": "ESNext",
@@ -14,7 +14,7 @@
"@/utils/*": ["./src/utils/*"],
"@/hooks/*": ["./src/hooks/*"],
"@/components/*": ["./src/components/*"],
- "@/context/*": ["./src/context/*"],
+ "@/context/*": ["./src/context/*"]
}
}
}