@forgewp/compiler
v0.4.3
Published
Compile ForgeWP React themes into installable WordPress themes
Readme
@forgewp/compiler ⚙️
The core engine of the ForgeWP ecosystem. It transforms modern React applications into standards-compliant WordPress themes.
📦 Features
1. Theme Export
Compiles your React components into header.php, footer.php, and index.php. It automatically:
- Resolves asset paths.
- Injects standard WordPress PHP hooks (
wp_head(),wp_footer()). - Replaces relative links with dynamic WordPress routing (
home_url()).
pnpm export2. Smart Component Adder
A powerful utility that pulls components from the ForgeWP Registry or shadcn/ui and applies the signature Sharpness Transformer.
pnpm forgewp add navbar
# Or
pnpm forgewp add --name navbar3. Native Gutenberg Block Generator
Dynamically scaffolds dynamic WordPress blocks authored in React with options for custom attributes:
pnpm forgewp make:block HeroBlock --attributes=heading,text,image,buttonText4. Post-Type Loop Scaffolder
Instantly scaffolds beautifully designed React loop grid components bound to custom WordPress post types (ACF-like integration):
pnpm forgewp make:loop PortfolioGrid --postType=portfolioNote: If the requested post type does not exist in cms/mock-data.json, the compiler will automatically register and seed it for you!
5. Custom Page Template Scaffolder
Scaffold custom standalone WordPress Page Templates written in React:
pnpm forgewp make:page AboutUs6. Resilient Framework Immunity & Diagnostics
Keep your monorepo perfectly healthy, clean, and self-healing:
pnpm forgewp doctor # Run diagnostic health & dependency checks
pnpm forgewp repair # Force restore framework utility blueprints
pnpm forgewp clean # Prune build artifacts and clear caches🔌 Configuration
ForgeWP is controlled via wp.config.ts in your project root:
export default {
themeName: 'My Sharp Theme',
slug: 'my-sharp-theme',
style: 'forgewp', // or "shadcn"
};🧩 Framework Adapters
The compiler is adapter-driven. React is the default adapter today, but the adapter boundary is designed to support other renderers in the future.
Read more in ADAPTERS.md.
Adapter test coverage
The compiler package now includes dedicated adapter validation scripts:
pnpm --filter @forgewp/compiler run test:adapter-runtimepnpm --filter @forgewp/compiler run test:adapter-types
Maintainable, Resilient, WordPress-native.
