Skip to content

feat: bring lazy platform compilation to Rspack - #1430

Open
jbroma wants to merge 24 commits into
callstack:mainfrom
jbroma:feat/lazy-compilation
Open

feat: bring lazy platform compilation to Rspack#1430
jbroma wants to merge 24 commits into
callstack:mainfrom
jbroma:feat/lazy-compilation

Conversation

@jbroma

@jbroma jbroma commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Bring the Rspack development experience to parity with Webpack by compiling each configured platform only when its bundle is first requested.

Developer wins

  • The development server starts without eagerly compiling every configured platform.
  • Launching an iOS app no longer waits for an unused Android build, and vice versa.
  • Each platform keeps independent compilation state, progress reporting, HMR notifications, stats, and asset caching.
  • A platform compiles once on first request, then serves subsequent bundle requests from the existing cache until a source change triggers a rebuild.
  • Shutdown now closes Rspack cleanly, rejects pending bundle requests, and still stops the development server when compiler shutdown fails.

How it works

Rspack starts every child compiler in a multi-compiler eagerly. Re.Pack now holds each child compiler at its initial watch run and releases it on the first bundle request for that platform. The watcher timestamps are refreshed when a gate is released to prevent the deferred compiler from treating changes made during startup as a second, phantom rebuild.

Unsupported platforms fail immediately instead of leaving requests pending. The implementation also tracks compilation, assets, stats, and request resolvers per platform.

Validation

  • Focused lazy-compilation compiler tests: 5/5 passed
  • Tester app dev-server integration tests: 2/2 passed
  • Re.Pack TypeScript and Biome checks passed
  • iOS smoke test passed
  • Watcher behavior verified with Rspack 1.6, 2.0, and 2.1
  • Changeset validation passed

@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c6a2573

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-plugin-expo-modules Minor
@callstack/repack-plugin-nativewind Minor
@callstack/repack-plugin-reanimated Minor
@callstack/repack-dev-server Minor
@callstack/repack-init 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

@vercel

vercel Bot commented Jul 31, 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.

this.buildStartTime[platform] = Date.now();

if (platform === 'android') {
void runAdbReverse({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed we calling runAdbReverse in watchRun so basically ADB system command on every file save, I know it was before this PR but since we refactoring this parte maybe we could move it outside watchRun or add some debounce (30 seconds) to prevent ADB spam on rapid saves

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @bartekkrok nice catch! It has been that way for a while to ensure smoother dev experience, I'd leave it as it is in this PR but this is definitely something that can be improved, although the gains are almost non-existent in this case - adb happily accepts that spam and this generates no performance overhead in reality.

@bartekkrok bartekkrok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this and everything looks fine for me. Good job

# Conflicts:
#	packages/repack/src/commands/rspack/Compiler.ts
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.

3 participants