How remorses/unframer works
Main components and their responsibilities
• CLI & Core Logic:
• The “unframer” CLI (see unframer/bin.js and src/cli.tsx) is the entry point that interacts with the Framer export component URLs (populated by a Framer plugin) and triggers the download, TypeScript type extraction, style generation, and bundling logic.
• It invokes internal modules (like those in unframer/src) to perform tasks such as fetching remote URLs, running esbuild for bundling, generating the “styles.css” with global Framer styles, and integrating npm dependency resolutions.
• Bundler and Type Generation:
• A module built on top of esbuild (see unframer/src/esbuild.ts) is responsible for bundling the external Framer component code.
• The type extraction part reads the “propertyControls” from each exported component to generate full TypeScript type definitions.
• Scripts & Utilities:
• Several scripts in /unframer/scripts (debugging, sourcemaps-exporter, version replace, etc.) support the overall build and export process.
• Utility functions in unframer/src/utils.ts and others manage common tasks.
• Framer Plugin Integration:
• The tool depends on data (URLs, export settings) pushed by the “React Export” Framer plugin. This component is not part of the codebase but acts as an external interface.
• Sample Framework Applications:
• The reactive demo apps (Astro, Next.js, Remix) included in the repository demonstrate how the exported components (and their CSS, props, responsive variants, dark mode settings, etc.) integrate into real-world projects.
• External Dependencies:
• The architecture draws on external libraries such as React 19, esbuild, and others that affect runtime behavior (e.g., handling React Strict Mode and SSR).
Relationships and interactions
• The CLI starts the process (using commands like “npx unframer {projectId} --outDir ./src/framer”) and triggers the internal pipeline.
• It issues HTTP HEAD requests (polling the Framer website for changes) to detect new exports.
• When a change is detected, the CLI downloads the component JavaScript modules and bundles them with esbuild.
• The bundler then resolves npm dependencies automatically (with options for external dependencies) and produces bundled JS files plus accompanying CSS (for global styles and fonts).
• Generated output (components with type definitions) can be integrated by downstream sample apps. These apps import the generated ‘styles.css’ and module exports (e.g., Menus, Logos) and implement responsive rendering, client-side navigation, localization, and dark mode.
• Directional data flow should be shown from user actions in Framer to component export, processing via the CLI, and finally consumption in one of the sample front-end apps.
Important architectural patterns and design principles
• Separation of concerns: The CLI is responsible for orchestration, while the bundler and type extractor handle their dedicated tasks.
• Modular design: The code is divided across logical directories (e.g., unframer/src for core functionality; scripts for auxiliary processes; separate sample apps for integration).
• Extensibility: The output supports a wide range of frameworks, and the architecture is built so that additional processing (such as more advanced dependency resolution or new export formats) can be added.
• Component reusability: The exported Framer components are designed to be framework-agnostic and integrate seamlessly into various React ecosystems.
Specific elements
• Clear labels:
• The “unframer CLI”.
• Core modules (“Fetcher”, “Bundler & Type Generator”, “Asset/Style Exporter”).
• Integration flow into sample front-end projects.
• Internal modules vs. external services (like Framer).
• Build-time processes (CLI, bundler) versus runtime components (exported React components in sample apps).
• Optional pathways like the “--watch” mode which continuously polls and triggers rebundling.