Repository navigation
React Compiler and Export
Translate supported DesignForge document semantics into maintainable React and TypeScript source code, styles, tokens, assets, and a runnable project structure.
- Read a stable, validated document snapshot.
- Convert it into a typed intermediate representation (IR).
- Resolve component and instance relationships.
- Emit deterministic output for the same input and configuration.
- Preserve token references where possible rather than replacing them with unexplained literals.
- Report unsupported semantics and warnings.
- Keep the exported application independent of DesignForge at runtime.
flowchart TD
Snapshot[Validated Document Snapshot] --> IR[Compiler Intermediate Representation]
IR --> Layout[Resolve Layout and Constraints]
Layout --> Components[Emit React Components]
Components --> Styles[Emit CSS / Styling]
Components --> Tokens[Emit Design Tokens]
Components --> Assets[Package Assets]
Styles --> Package[Project Package]
Tokens --> Package
Assets --> Package
Package --> Validate[Type Check / Build Validation]
Validate --> Report[Export Report and Diagnostics]
The initial baseline may generate files such as:
exported-project/
package.json
tsconfig.json
README.md
src/
App.tsx
components/
tokens/
tokens.ts
styles/
public/
assets/
Exact file layout may evolve, but it should remain documented and predictable.
The documented baseline targets React 18/19 with TypeScript and project CSS/styles. Validate versions and dependency choices during implementation rather than treating them as immutable. Include build checks where the environment permits.
The compiler should produce a report containing:
- Exported pages/components
- Generated and copied assets
- Warnings and unsupported features
- Type/build validation results
- Any behavior that differs from the editor or prototype runtime
Where the application provides an embedded React preview, render generated output in a controlled sandbox. Preview errors should be isolated from the editor and reported clearly.
The broader product requirements include image and PDF export and supported vector/image formats. Implement each format through an explicit export adapter with defined fidelity, scope, scale, naming, and error behavior. Do not claim a format works until its export and round-trip or visual tests pass.
- The same document snapshot and compiler configuration produce stable output.
- Exported React projects build and run independently of DesignForge.
- Components, tokens, assets, and supported layout semantics are represented correctly.
- Unsupported features are reported.
- Export failures do not corrupt the source project.
- Generated code is understandable and maintainable, not just a screenshot wrapped in a component.