mirror of
https://github.com/xtr-dev/payload-automation.git
synced 2025-12-10 17:03:22 +00:00
Fix client-side bundling by separating server and client exports
- Create dedicated /server export for server-side functions and plugin
- Main export now contains only types (client-safe)
- Remove problematic /steps export that exposed server functions
- Update README with correct import structure
- Fix tests to use /server export
This prevents server-side code from being bundled in client JavaScript,
eliminating the "require is not defined in ES module scope" runtime error.
Breaking change: workflowsPlugin must now be imported from '/server':
import { workflowsPlugin } from '@xtr-dev/payload-automation/server'
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
src/index.ts
24
src/index.ts
@@ -1,19 +1,15 @@
|
||||
export { triggerCustomWorkflow, triggerWorkflowById } from './core/trigger-custom-workflow.js'
|
||||
// Main export contains only types and client-safe utilities
|
||||
// Server-side functions are exported via '@xtr-dev/payload-automation/server'
|
||||
|
||||
// Types only - safe for client bundling
|
||||
export type { CustomTriggerOptions, TriggerResult } from './core/trigger-custom-workflow.js'
|
||||
export { WorkflowExecutor } from './core/workflow-executor.js'
|
||||
export type { ExecutionContext, Workflow, WorkflowStep, WorkflowTrigger } from './core/workflow-executor.js'
|
||||
export type { WorkflowsPluginConfig } from './plugin/config-types.js'
|
||||
export { workflowsPlugin } from './plugin/index.js'
|
||||
|
||||
// Export all step tasks
|
||||
export {
|
||||
CreateDocumentStepTask,
|
||||
DeleteDocumentStepTask,
|
||||
HttpRequestStepTask,
|
||||
ReadDocumentStepTask,
|
||||
SendEmailStepTask,
|
||||
UpdateDocumentStepTask
|
||||
} from './steps/index.js'
|
||||
// Server-side functions are NOT re-exported here to avoid bundling issues
|
||||
// Import server-side functions from the /server export instead
|
||||
|
||||
// UI components are exported via separate client export to avoid CSS import issues during type generation
|
||||
// Use: import { TriggerWorkflowButton } from '@xtr-dev/payload-automation/client'
|
||||
// Server functions and plugin should be imported from '/server':
|
||||
// import { workflowsPlugin } from '@xtr-dev/payload-automation/server'
|
||||
// UI components should be imported from '/client':
|
||||
// import { TriggerWorkflowButton } from '@xtr-dev/payload-automation/client'
|
||||
|
||||
Reference in New Issue
Block a user