Skip to content

refactor(commands): unify webpack and Rspack commands - #1424

Open
jbroma wants to merge 11 commits into
callstack:mainfrom
jbroma:refactor/unify-commands
Open

refactor(commands): unify webpack and Rspack commands#1424
jbroma wants to merge 11 commits into
callstack:mainfrom
jbroma:refactor/unify-commands

Conversation

@jbroma

@jbroma jbroma commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a single @callstack/repack/commands entry point with automatic bundler detection and a validated --bundler override
  • consolidate the duplicate start and bundle command orchestration and dev-server delegate while preserving the separate Rspack and webpack compiler implementations
  • retain the bundler-specific command entry points as deprecated compatibility overrides
  • reject pending webpack asset requests when compilation fails instead of leaving HTTP requests hanging
  • update Re.Pack Init, tester apps, CLI documentation, tests, and Changesets for the unified surface

Why

The command registries and most command orchestration were duplicated even though both bundlers already shared the config and dev-server layers. This gives users one stable command entry point while keeping each bundler's deliberately different execution model behind a small shared compiler interface.

Related to #1421. This PR intentionally does not merge compiler internals, defineConfig helpers, or bundler configuration templates: those remain bundler-specific where their types and runtime behavior differ.

Validation

  • full repository JavaScript regression suite passed
  • @callstack/repack: 31 Jest suites, 290 tests, and 22 snapshots passed
  • Re.Pack TypeScript and Biome checks passed
  • production documentation build passed
  • iOS simulator runtime smoke tests passed for tester-app, tester-federation, and tester-federation-v2, including async chunks, miniapp lifecycle, and both Module Federation gallery flows
  • direct iOS simulator target builds, installs, and launches passed for all three apps; the standard React Native CLI destination lookup remains affected by a local Xcode 26.6/runtime discovery issue

jbroma and others added 11 commits February 7, 2026 15:27
… and --bundler option

Add Bundler type alias, CompilerInterface and CompilerAsset to the
shared types.ts. Remove duplicate CompilerAsset definitions from
rspack/types.ts and webpack/types.ts. Add --bundler <string> CLI
option to both startCommandOptions and bundleCommandOptions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add detectBundler() utility that determines the bundler engine with
the following priority:
1. Explicit --bundler flag
2. Custom config path filename inference (rspack.* vs webpack.*)
3. Config file discovery (rspack configs checked first)
4. Default: rspack

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Webpack Compiler:
- Remove EventEmitter inheritance
- Add platforms property and devServerContext with late-init
- Add setDevServerContext() and start() (no-op) methods
- Internalize event handling: worker messages now call
  devServerContext.notifyBuildStart/End and broadcastToHmrClients
  directly instead of emitting events
- Constructor now takes platforms as first argument

Rspack Compiler:
- Add 'implements CompilerInterface' declaration
- Import CompilerAsset from shared types

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…ction

Add unified bundle.ts and start.ts that merge the rspack and webpack
implementations, using detectBundler() and dynamic imports to select
the correct engine at runtime.

Add commands/index.ts exporting the unified command definitions and
a createBoundCommands() helper for deprecated entry points.

Add commands/index.js and commands/index.d.ts as the new primary
CJS entry point. Update commands/rspack.js and commands/webpack.js
to be deprecation wrappers that delegate via createBoundCommands().

Add './commands' export to package.json (alongside existing wildcard).

Delete old bundler-specific files:
- rspack/bundle.ts, rspack/start.ts, rspack/index.ts
- webpack/bundle.ts, webpack/start.ts, webpack/index.ts

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Update init package:
- Remove bundler parameter from modifyReactNativeConfig()
- Use '@callstack/repack/commands' instead of bundler-specific paths

Simplify react-native.config.js in all test apps to use the unified
import instead of conditional require based on USE_WEBPACK env var.

Update integration tests to import from '@callstack/repack/commands'
instead of separate rspack/webpack command sets.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@jbroma is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 39d67ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Minor
@callstack/repack-init Minor
@callstack/repack-plugin-expo-modules Minor
@callstack/repack-plugin-nativewind Minor
@callstack/repack-plugin-reanimated Minor
@callstack/repack-dev-server Minor

Not sure what this means? Click here to learn what changesets are.

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

@jbroma
jbroma marked this pull request as ready for review July 29, 2026 20:22
@thymikee

Copy link
Copy Markdown
Member

he's back!

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