Skip to content

Conversation

@andersonleal
Copy link
Contributor

Summary

This PR introduces a comprehensive migration of the Motia monorepo build system from CommonJS to native ES Modules (ESM), replacing the previous build tooling (tsc/Vite) with tsdown across all packages. This modernization improves build performance, simplifies configuration, and ensures better compatibility with the modern JavaScript ecosystem.

Key Changes

  • ESM-first architecture: All packages now use "type": "module" and output .mjs files
  • tsdown adoption: Replaced tsc/Vite build configurations with tsdown for consistent, fast builds
  • Updated TypeScript configuration: Changed module resolution to bundler and module format to ESNext
  • Dependency updates: Updated TypeScript to 5.9.3, ts-jest to 29.4.5, and other dependencies
  • Biome schema update: Updated to version 2.3.5

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • Other (please describe):

Packages Affected

Core Packages

  • @motiadev/core - Migrated to ESM with tsdown
  • @motiadev/snap - Migrated to ESM with tsdown, updated CLI entry point

Adapter Packages

  • @motiadev/adapter-rabbitmq-events - Added tsdown config
  • @motiadev/adapter-redis-cron - Added tsdown config
  • @motiadev/adapter-redis-state - Added tsdown config
  • @motiadev/adapter-redis-streams - Added tsdown config

Stream Client Packages

  • @motiadev/stream-client - Migrated to ESM with tsdown
  • @motiadev/stream-client-browser - Added tsdown config
  • @motiadev/stream-client-node - Migrated to ESM, removed custom build script
  • @motiadev/stream-client-react - Added tsdown config

UI Packages

  • @motiadev/ui - Replaced Vite with tsdown
  • @motiadev/workbench - Migrated to tsdown, updated post-build script

Plugins

  • plugin-endpoint - Replaced Vite with tsdown
  • plugin-example - Replaced Vite with tsdown
  • plugin-logs - Replaced Vite with tsdown
  • plugin-observability - Replaced Vite with tsdown
  • plugin-states - Replaced Vite with tsdown

Changes Overview

Build System Changes

Before After
tsc for TypeScript compilation tsdown for bundling
Vite for plugin builds tsdown for all builds
CommonJS (require) ESM (import)
.js output files .mjs output files
dist/cjs/ and dist/esm/ dist/ (ESM only)

Package.json Export Changes

// Before
{
  "main": "dist/cjs/index.js",
  "module": "dist/esm/index.js",
  "types": "dist/types/index.d.ts"
}

// After
{
  "type": "module",
  "main": "dist/index.mjs",
  "module": "dist/index.mjs",
  "types": "dist/index.d.mts"
}

Test Configuration

  • Jest now runs with NODE_OPTIONS='--experimental-vm-modules' for ESM support
  • Migrated jest.config.js to jest.config.cjs where needed

Checklist

  • I have read the CONTRIBUTING.md
  • My code follows the code style of this project
  • I have added tests where applicable
  • I have tested my changes locally
  • I have linked relevant issues
  • I have added screenshots for UI changes (if applicable)

Testing Performed

  • All packages build successfully with pnpm build
  • Unit tests pass with ESM configuration
  • Playground runs correctly with updated packages
  • Workbench starts and functions properly
  • CLI commands work as expected

Migration Notes

For Contributors

  • Use import syntax instead of require
  • File extensions may be needed in imports for certain edge cases
  • Jest tests now require --experimental-vm-modules flag

For Users

  • No breaking changes in public API
  • Import paths remain the same
  • TypeScript users get improved module resolution

Additional Context

This migration prepares Motia for better tree-shaking, faster builds, and improved compatibility with modern tooling. The tsdown bundler was chosen for its simplicity, speed, and excellent TypeScript support.

Files Added

  • tsdown.config.ts in each package (17 new configs)
  • jest.config.cjs for packages needing CommonJS Jest config

Files Removed

  • vite.config.ts from plugins and UI packages
  • scripts/build.sh from several packages
  • tsconfig.build.json and tsconfig.node.json where redundant
  • Various .d.ts declaration files that are now auto-generated

@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
motia-docs Ready Ready Preview Comment Dec 1, 2025 9:40pm
motia-ui Ready Ready Preview Comment Dec 1, 2025 9:40pm

@github-actions
Copy link

⚠️ This PR is quite large (>1000 lines). Consider splitting it into smaller PRs for easier review.

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

Dependency Review Summary

The full dependency review summary is too large to display here. Please download the artifact named "dependency-review-summary" to view the complete report.

View full job summary

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

E2E Test Results ✅

All tests have completed. Tests passed.

Matrix: 2 OS (Ubuntu, macOS) × 2 Templates (TypeScript, Python) = 4 jobs

View detailed test results


This comment is automatically posted by the PR E2E Results workflow.

…creation and dependency management

fix: increase timeout for flows dropdown visibility check in WorkbenchPage

refactor: enhance FlowTabMenuItem to display loading state for flows and improve dropdown menu structure

fix: update runner path in language-runner to support custom TypeScript runner files in test mode

chore: update pnpm-lock.yaml to upgrade various dependencies including prettier, eslint, express, and ts-jest, while ensuring compatibility with TypeScript and improving overall project stability

refactor: enhance jsRunner path resolution in language-runner to support test mode with TypeScript and improve command arguments

refactor: update jsRunner path resolution in language-runner to support test mode with TypeScript and module file extensions

chore: update pnpm-lock.yaml and package.json to remove esbuild dependency and upgrade to esbuild version 0.25.12, while refactoring tsdown configuration and enhancing CLI functionality with Redis memory server management

chore: update pnpm-lock.yaml and package.json to upgrade tsx version and refactor tsx loader path resolution in language-runner

chore: update pnpm-lock.yaml and package.json for dependency adjustments, enhance TypeScript configuration for ES module support, and refactor test package structure

chore: update CI workflow to exclude playground directory from tests

chore: update CI workflow to exclude plugins directory from tests and enhance global setup with server output tracking

chore: update pnpm-lock.yaml and package.json for dependency version upgrades and add plugins directory to workflow

refactor: remove unused CSS plugins from tsdown configurations and clean up package.json files across multiple plugins

fix: update pnpm-lock.yaml with dependency version adjustments and add warm-up functionality for Motia plugins in workbench middleware

fix: update package.json and import paths for ES module compatibility in snap and stream-client packages

fix: add module type to package.json for ES module support

fix: update import paths in petstore step templates to use absolute paths and remove module type from package.json

fix: update package.json and tsdown.config.ts to include esbuild and tsx dependencies, adjust TypeScript module settings for improved compatibility

fix: change import statement in state-audit-cron step to use type import for Order

fix: update import statements in petstore step templates to use type imports and add Babel plugin for React in workbench package.json

fix: update pnpm-lock.yaml to adjust lucide-react version and remove unused dependencies, while refining TypeScript configuration in header component

fix: update workbench middleware to include Babel plugin for React and remove unused Radix UI dependencies

fix: update workbench configuration to include new Rollup URL plugin and adjust entry points for improved asset handling

fix: update pnpm-lock.yaml with new dependencies, including Babel plugin, and adjust tsdown version for improved compatibility

fix: update dependencies to latest versions, including React and Lucide, and integrate Babel plugin for improved JSX support

fix: add React and ReactDOM as dependencies and remove unused example plugin from motia.config.ts

fix: remove unused dependencies from pnpm-lock.yaml and ensure consistent versioning for React

fix: update TypeScript configuration to support ES modules and refine project structure by removing unused dependencies in templates

chore: add TypeScript configuration files for app and node environments in workbench

fix: refactor import statements in motia.config.ts templates and remove unused dependencies from workbench

fix: streamline import paths and remove unused dependencies in middleware and header components

fix: update import paths for various components and add eslint configuration for workbench

fix: update import statement for Order type to include .ts extension and export CronConfig type in core index

fix: correct import statements in validate-event-input, button, and table components

fix: update built CLI path in E2E tests to use .mjs extension

chore: update Node.js version to 24.11.1 in setup actions

fix: correct import path for utility functions in Empty component

fix(tests): add missing on method in LockedData mock for middleware management tests

chore: update schema version in biome.json to 2.3.5

chore: update package configurations and add tsdown config files for multiple packages
…ndencies including express, @types/express, lucide-react, and Storybook packages, while ensuring compatibility with TypeScript and improving overall project stability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants