Skip to content

Create Rslib executor for Nx #3876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: rslib-executor
Choose a base branch
from

Conversation

ScriptedAlchemy
Copy link
Member

Description

This PR introduces a comprehensive Nx plugin for Rslib, providing dedicated executors for building and developing Rslib-based libraries within an Nx workspace.

Key Changes:

  • Rslib Nx Plugin (tools/rslib-plugin):
    • rslib:build executor: Integrates rslib build for production and development builds, including watch mode.
    • rslib:dev executor: Integrates rslib mf-dev for Module Federation development and rslib build --watch for general watch mode.
    • rslib:echo executor: A simple executor for testing plugin functionality.
    • Schema Validation: JSON schemas for all executor options.
    • Package Structure: Configured with proper package.json exports and pnpm-workspace.yaml inclusion for local resolution.
  • runtime-core Migration: The packages/runtime-core project has been migrated from @nx/rollup to use the new rslib:build executor. This migration demonstrated significant performance improvements (build time reduced from ~2.6s to ~50ms).
  • Cleanup: Removed the legacy tools/rslib-old directory and all associated references, along with temporary markdown files and test files created during development.
  • Executor Resolution Fix: Addressed complex Nx local plugin resolution by using relative path references for executors (e.g., ../../tools/rslib-plugin:build) in project.json files.
  • Rslib Compatibility: Adjusted executor commands to be compatible with rslib v0.10.4 (e.g., removed unsupported --mode option).

Why these changes?

To integrate Rslib as a first-class build tool within the Nx monorepo, leveraging its performance benefits, especially for Module Federation projects. This provides a streamlined and faster alternative to existing build processes.

Related Issue

N/A

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

Copy link

changeset-bot bot commented Jul 2, 2025

⚠️ No Changeset found

Latest commit: 0b7845d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

cursoragent and others added 10 commits July 2, 2025 11:22
- Configure rslib to generate TypeScript declaration files (.d.ts)
- Add missing entry points (helpers, core, global) to rslib config
- Update runtime-core package.json exports to use generated declarations
- Fix import patterns in runtime package to use namespace imports
- Exclude dist directories from TypeScript compilation to prevent conflicts
- Add global variable definitions for build-time replacement
- Update multiple package tsconfigs to prevent dual type resolution

This enables proper TypeScript declaration generation via rslib
while maintaining compatibility with existing build processes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
The tools/scripts/publish.mjs file was not referenced anywhere in the
codebase and appears to be legacy/template code that was never integrated
into the actual publishing workflow.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Replace @nx/rollup executor with rslib for runtime-core package
- Add @rslib/core as devDependency and create rslib.config.ts
- Update package.json exports to match rslib output format (.js/.cjs)
- Add TypeScript declaration generation with proper env.d.ts
- Update tsconfig.lib.json for correct output paths
- Remove duplicate global.d.ts file
- Add build script to package.json for direct rslib execution

This migration enables better TypeScript declaration generation and
aligns with modern build tooling standards.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Move global declarations from src/global.ts to separate global-types.d.ts
- This prevents conflicts between source and generated .d.ts files
- Resolves TypeScript errors where packages saw both src and dist types
- Enhanced package now builds successfully without type conflicts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Configure project.json to use ../../tools/rslib-plugin:build executor
- Fix rslib.config.ts import to use JSON import instead of fs.readFileSync
- Add @rslib/core devDependency to package.json
- Ensure proper rslib configuration for TypeScript declaration generation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants