Skip to content

[Bug] SWC panic crash with React Native 0.84.0-rc.0: "Object rest pattern should be removed by es2018::object_rest_spread pass" #1327

@nthtrung09it

Description

@nthtrung09it

Description

When using Re.Pack 5.2.3 with React Native 0.84.0-rc.0, the bundler crashes immediately with a Rust panic in SWC during the ES2015 destructuring transform.

Environment

  • Re.Pack version: 5.2.3
  • @rspack/core version: 1.5.8
  • @swc/core version: 1.13.5
  • React Native version: 0.84.0-rc.0
  • Node.js version: v22.21.1
  • pnpm version: 10.27.0
  • OS: macOS (Darwin 24.6.0, arm64)

Error Message

▄▀▀▀ ▀▀▀▀   █▀▀█ █▀▀█ ▄▀▀▀ █  █
█    ▀▀▀▀   █▀▀▀ █▀▀█ █    █▀▀▄
▀    ▀▀▀▀ ▀ ▀    ▀  ▀  ▀▀▀ ▀  ▀
5.2.3, powered by Rspack

ℹ [DevServer] Server listening at http://127.0.0.1:8081 
⠴ [DevServer] [===-------------] 16% ios 
Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues: panicked at index.crates.io-1949cf8c6b5b557f/swc_ecma_compat_es2015-28.0.0/src/destructuring.rs:419:52:
internal error: entered unreachable code: Object rest pattern should be removed by es2018::object_rest_spread pass

Steps to Reproduce

  1. Create a React Native 0.84.0-rc.0 project with Re.Pack 5.2.3
  2. Run react-native webpack-start --config rspack.config.mts --port 8081 --platform ios
  3. The bundler crashes at ~16-30% progress with the panic above

Configuration

Using @callstack/repack/babel-swc-loader as recommended:

{
  test: /\.[cm]?[jt]sx?$/,
  use: {
    loader: '@callstack/repack/babel-swc-loader',
    parallel: true,
    options: {},
  },
  type: 'javascript/auto',
}

Analysis

The panic occurs in swc_ecma_compat_es2015/src/destructuring.rs:419:52, indicating that the ES2018 object_rest_spread pass didn't run before the ES2015 destructuring pass, causing an unexpected object rest pattern ({...rest}) to reach the destructuring handler.

This appears to be related to:

Expected Behavior

The bundler should successfully compile React Native 0.84.0-rc.0 code without panicking.

Additional Context

  • The crash happens very early in bundling (~16%), suggesting it's hitting core RN code or a common dependency
  • No verbose output shows which file triggers the crash
  • This worked on React Native 0.83.1

Workaround Attempts

  • Updated to @callstack/repack 5.2.3 - still crashes
  • Tried running with --verbose - panic occurs before file info is logged

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions