Skip to content

Commit

Permalink
fix(auto api): workaround error message
Browse files Browse the repository at this point in the history
Essentially, you can't import across package boundaries.
Hacky fix is to duplicate types.
  • Loading branch information
TheMcnafaha committed Sep 21, 2024
1 parent f8465ec commit ed843ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 0 additions & 1 deletion apps/website/auto-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function writeToDocs(fullPath: string, componentName: string, api: ComponentPart
}
const json = JSON.stringify(api, null, 2);
const hacky = `export const api=${json}`;
console.log(json);

try {
fs.writeFileSync(dirPath.concat('/api.ts'), hacky);
Expand Down
18 changes: 13 additions & 5 deletions apps/website/src/components/api-table/auto-api.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { JSXOutput, component$, $, QRL, useTask$, useSignal } from '@builder.io/qwik';
import {
PublicType,
type ComponentParts,
type SubComponent,
} from 'apps/website/auto-api';
import { APITable, type APITableProps } from './api-table';
import { packages } from '../install-snippet/install-snippet';

//This is a workaround for not being able to export across packages due to nx rule:
// https://nx.dev/features/enforce-module-boundaries#enforce-module-boundaries
type ComponentParts = Record<string, SubComponents>;
type SubComponents = SubComponent[];
type SubComponent = Record<string, PublicType[]>;
type PublicType = Record<string, ParsedProps[]>;
type ParsedProps = {
comment: string;
prop: string;
type: string;
};
type AutoAPIConfig = {
topHeader?: QRL<(text: string) => JSXOutput>;
subHeader?: QRL<(text: string) => JSXOutput>;
Expand Down

0 comments on commit ed843ff

Please sign in to comment.