Table of Contents generated with DocToc
This is a React plugin template for Apache Airflow that builds as a library component.
This template is configured to build your React component as a library that can be consumed by other applications.
pnpm dev - Start development server with hot reloadpnpm build - Build the library for productionpnpm build:types - Generate TypeScript declaration files onlypnpm build:lib - Build the JavaScript library onlypnpm test - Run testspnpm lint - Check code qualitypnpm format - Format codeWhen you run pnpm build, the template generates:
dist/main.js - ES module JavaScript librarydist/main.d.ts - TypeScript declaration fileAfter building, other applications can import your component:
import { PluginComponent } from 'your-plugin-name'; // Use in your React app <PluginComponent />
For development and testing, use pnpm dev which will:
src/dev.tsx entry pointThe template is configured with:
Be mindful when upgrading dependencies that are marked as external in vite.config.ts, those are shared dependencies with the host application (Airflow UI) and should remain in a compatible version range to avoid issues.
PluginComponentProps interface in src/main.tsxexternal array in vite.config.tsvite.config.tsThe package.json is configured with:
main and module pointing to the built librarytypes pointing to generated declaration filesexports for modern import/export supportfiles array specifying what gets publishedThis ensures your plugin can be consumed as both a CommonJS and ES module with full TypeScript support.
AirflowPlugin) for consistency“Failed to resolve module specifier ‘react’”
vite.config.ts“Cannot read properties of null (reading ‘useState’)”
“Objects are not valid as a React child”
MIME type issues
.js and .cjs files are served with correct MIME typeFor more help, check the main project documentation.
Once the development is complete, you can build the library using pnpm build and then host the content of the dist folder. You can do that on your own infrastructure or within airflow by adding static file serving to your api server via registering a plugin fastapi_apps. You can take a look at the Airflow documentation for more information on how to do that.