Skip to content

Conversation

@justin808
Copy link
Member

@justin808 justin808 commented Nov 16, 2025

Summary

Fixes #1850 by correcting the shakapacker.yml template configuration to prevent unnecessary "Slow setup for development" warnings when using Procfiles with bin/dev.

Changes

  • Set compile: false in default section - This becomes the default for development and production environments
  • Remove compile: true from development section - Now inherits compile: false from default
  • Keep compile: true in test section - Tests still need on-demand compilation
  • Add clarifying comments - Explain when to use compile: true vs false

Problem Solved

Previously, the installer generated:

development:
  compile: true  # ❌ Wrong - causes on-demand compilation

This caused Rails to attempt on-demand asset compilation even when bin/shakapacker-dev-server or bin/shakapacker --watch were already running via Procfiles, resulting in this warning on every request:

Shakapacker::Compiler - Slow setup for development

Prepare JS assets with either:
1. Running bin/shakapacker-dev-server
2. Set compile to false in shakapacker.yml and run bin/shakapacker -w

After This Fix

The generated configuration now follows best practices:

default: &default
  compile: false  # Default is false (use Procfiles)

development:
  <<: *default
  # Inherits compile: false - no on-demand compilation

test:
  <<: *default
  compile: true  # Only tests need on-demand compilation

production:
  <<: *default
  compile: false  # Assets are precompiled

Impact

  • ✅ Eliminates confusing warnings on every page load during development
  • ✅ Aligns with standard Procfile-based development workflow
  • ✅ Maintains correct behavior for test environment
  • ✅ No impact on production (already had compile: false)

Test Plan

  • Changes made to installer template
  • RuboCop passes with no violations
  • Pre-commit hooks pass (prettier, trailing newlines)

To test the fix:

  1. Generate a new app with the updated installer
  2. Run bin/dev (which starts rails server + shakapacker-dev-server)
  3. Visit any page
  4. Verify no "Slow setup for development" warning appears in logs

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • Chores
    • Updated default build configuration to use on-demand compilation instead of always compiling. Development environments now inherit this default behavior for optimized build performance.

…lopment (#1850)

The installer was generating shakapacker.yml with compile: true in development,
causing unnecessary 'Slow setup for development' warnings when using Procfiles
with bin/dev that already run bin/shakapacker-dev-server or bin/shakapacker --watch.

Changes:
- Set compile: false in default section (inherited by development and production)
- Remove compile: true from development section (inherits false from default)
- Keep compile: true in test section (on-demand compilation needed for tests)
- Add clarifying comments explaining when to use compile: true vs false

This prevents Rails from attempting on-demand compilation when a webpack dev
server is already running, eliminating confusing warnings on every page load.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 16, 2025

Walkthrough

The shakapacker.yml template is updated to set compile: false as the default configuration, removing the explicit compile: true override from the development section so it inherits the default behavior instead.

Changes

Cohort / File(s) Summary
Shakapacker configuration template
lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
Added compile: false to default section with explanatory comments; removed compile: true override from development section to inherit default behavior

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file configuration change affecting two lines (one addition, one removal)
  • No logic changes, purely configuration defaults

Suggested labels

bug

Poem

🐰 A config fix, so clean and small,
Default to false, that's best for all,
Dev warnings gone, the setup flies,
No more "slow" upon our eyes!
Shakapacker smooth, no compromise,
The installer's heart now runs so wise.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing the shakapacker.yml template to prevent 'Slow setup' warnings, which directly matches the core objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #1850: sets compile: false in default section, removes compile: true from development, keeps compile: true in test, and adds clarifying comments.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the shakapacker.yml template file and focused on fixing the compile flag configuration as specified in issue #1850.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch justin808/fix-shakapacker-compile

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cbee429 and 6858a5a.

📒 Files selected for processing (1)
  • lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-02-12T16:38:06.537Z
Learnt from: Romex91
Repo: shakacode/react_on_rails PR: 1697
File: package-scripts.yml:28-28
Timestamp: 2025-02-12T16:38:06.537Z
Learning: The file `node_package/lib/ReactOnRails.full.js` is autogenerated during the build process and should not be present in the repository.

Applied to files:

  • lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808
Repo: shakacode/react_on_rails PR: 1770
File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2
Timestamp: 2025-09-16T08:01:11.146Z
Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules.

Applied to files:

  • lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2
Repo: shakacode/react_on_rails PR: 1732
File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44
Timestamp: 2025-04-26T21:55:55.874Z
Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime.

Applied to files:

  • lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
🔇 Additional comments (1)
lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml (1)

58-61: Excellent fix that correctly addresses the "Slow setup for development" issue.

The changes align perfectly with the PR objectives:

  • Setting compile: false in the default section (line 61) establishes the recommended pattern for Procfile-based workflows
  • Development now inherits this default instead of forcing compile: true, eliminating unnecessary warnings
  • Test retains explicit compile: true for on-demand compilation (line 125)
  • Production preserves explicit compile: false (line 134)

The clarifying comments (lines 58–60) are well-written and will help developers understand when to adjust the setting.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the bug label Nov 16, 2025
@justin808 justin808 merged commit dca30af into master Nov 16, 2025
21 checks passed
@justin808 justin808 deleted the justin808/fix-shakapacker-compile branch November 16, 2025 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installer generates shakapacker.yml with compile: true in development causing 'Slow setup' warnings

2 participants