Skip to content

doctor reports false SWC issues for custom hybrid webpack/rspack setups #1090

@justin808

Description

@justin808

Summary

shakapacker:doctor reports false issues for apps that use a custom hybrid bundler setup instead of Shakapacker's generated transpiler defaults.

In our app:

  • Rspack uses built-in SWC
  • a legacy path still intentionally uses Babel
  • both webpack and rspack are installed on purpose
  • assets compile successfully

But shakapacker:doctor reports:

  • Missing required dependency '@swc/core' for SWC transpiler
  • Missing required dependency 'swc-loader' for SWC with webpack

and warnings like:

  • Both SWC and Babel dependencies are installed. Consider removing Babel dependencies to reduce node_modules size
  • Both webpack and rspack are installed - ensure assets_bundler is set correctly

Why this looks incorrect

The app does not set assets_bundler or javascript_transpiler in config/shakapacker.yml, and uses a custom config layer instead.

Relevant behavior in doctor.rb:

  • if javascript_transpiler is unset, doctor assumes swc
  • if assets_bundler is unset, config falls back to webpack
  • that combination causes doctor to require @swc/core and swc-loader

However, in our actual config:

  • webpack path does not use SWC
  • rspack path uses builtin:swc-loader
  • Babel is still intentionally used for a legacy loader path

So doctor is validating its own inferred defaults rather than the app's real build behavior.

Relevant code paths

In Shakapacker 10.0.0:

  • lib/shakapacker/doctor.rb
    • check_javascript_transpiler_dependencies
    • check_swc_dependencies
    • check_transpiler_config_consistency

In our app:

  • custom wrapper config delegates webpack and rspack to a shared config
  • Rspack sets process.env.USE_RSPACK = 'true'
  • shared rules choose:
    • builtin:swc-loader for Rspack
    • babel-loader for a legacy path

Evidence

Despite the doctor output, the upgraded setup builds successfully:

  • shakapacker gem: 10.0.0
  • npm shakapacker: 10.0.0
  • @rspack/core: 2.0.0-rc.1
  • @rspack/cli: 2.0.0-rc.1
  • @rspack/dev-server: 2.0.0-rc.2

pnpm run rspack-dev completed successfully with all bundles compiling.

Suggestion

It seems like doctor should either:

  1. avoid raising SWC dependency issues when the app is clearly using a custom config rather than Shakapacker-managed transpiler selection, or
  2. downgrade these to hints or warnings when javascript_transpiler and assets_bundler are only inferred defaults, or
  3. document that custom hybrid configs should explicitly set javascript_transpiler: none or another value to suppress these checks, if that is the intended contract

Right now the output suggests missing dependencies that are not actually required for a working custom setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugp2Medium: enhancements, docs, quality improvements

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions