Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generators to add fallback: { stream: false } to webpack configs #1676

Conversation

AbanoubGhadban
Copy link
Collaborator

@AbanoubGhadban AbanoubGhadban commented Jan 15, 2025

  • Set fallback for 'stream' to false in both client and server Webpack configurations.
  • Cleaned up package.json by removing unnecessary stream-browserify alias.
  • Update generators to add the fallback statement to webpackConfig.js

These changes enhance compatibility and streamline the build process.

Summary

Remove this paragraph and provide a general description of the code changes in your pull
request... were there any bugs you had fixed? If so, mention them. If
these bugs have open GitHub issues, be sure to tag them here as well,
to keep the conversation linked together.

Pull Request checklist

Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by ~.

  • Add/update test to cover these changes
  • Update documentation
  • Update CHANGELOG file
    Add the CHANGELOG entry at the top of the file.

Other Information

Remove this paragraph and mention any other important and relevant information such as benchmarks.


This change is Reviewable

Summary by CodeRabbit

  • Configuration Changes

    • Updated Webpack configurations to handle the stream module by setting fallback to false.
    • Removed stream-browserify alias from Webpack configuration.
  • Build Process

    • Modified development build script to remove watch mode in package.json.
  • Changelog Updates

    • Added details regarding webpack configuration fixes and enhancements in the CHANGELOG.

- Set fallback for 'stream' to false in both client and server Webpack configurations.
- Cleaned up package.json by removing unnecessary stream-browserify alias.
- Update generators to add the fallback statement to webpackConfig.js

These changes enhance compatibility and streamline the build process.
Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Warning

Rate limit exceeded

@AbanoubGhadban has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0e16e0b and 2432b86.

📒 Files selected for processing (2)
  • lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt (1 hunks)
  • spec/dummy/config/webpack/webpackConfig.js (1 hunks)

Walkthrough

The pull request introduces modifications to Webpack configurations across multiple files, focusing on handling the stream module. The changes primarily involve setting fallback configurations for both client and server environments to { stream: false }, removing the previous stream-browserify alias. Additionally, the development build script in package.json has been updated to remove the --watch flag, changing the build process behavior. The CHANGELOG.md has been updated to reflect these changes and various fixes in version 14.1.0.

Changes

File Change Summary
lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt Added fallback configurations for clientConfig and serverConfig with { stream: false }
spec/dummy/config/webpack/alias.js Removed stream: 'stream-browserify' alias
spec/dummy/config/webpack/webpackConfig.js Updated fallback configurations for stream to false in both client and server configs
spec/dummy/package.json Removed --watch flag from build:dev script
CHANGELOG.md Added entry for webpack configuration updates and various fixes in version 14.1.0

Possibly related PRs

Suggested reviewers

  • justin808
  • ahangarha
  • alexeyr-ci

Poem

🐰 Webpack's stream, once flowing free,
Now stands still, no longer to be.
Configs shift with gentle might,
Fallbacks set, both left and right.
A rabbit's build, precise and neat! 🛠️


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt (1)

9-11: LGTM! Consider clarifying the conditional comment.

The fallback configuration for stream is correctly set to false for both client and server configs. However, the comment about removing the server config line could be more specific.

Consider updating the comment to be more explicit:

-  // Remove the next line if you used "node" target in serverWebpackConfig.js
+  // Remove the serverConfig.resolve.fallback line if you set target: "node" in serverWebpackConfig.js
+  // as Node.js already provides the stream module
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc789d9 and e20058e.

📒 Files selected for processing (4)
  • lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt (1 hunks)
  • spec/dummy/config/webpack/alias.js (0 hunks)
  • spec/dummy/config/webpack/webpackConfig.js (1 hunks)
  • spec/dummy/package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • spec/dummy/config/webpack/alias.js
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: examples (newest)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: build-dummy-app-webpack-test-bundles (oldest)
  • GitHub Check: rspec-package-tests (oldest)
  • GitHub Check: build
  • GitHub Check: examples (oldest)
🔇 Additional comments (2)
spec/dummy/config/webpack/webpackConfig.js (1)

7-9: Verify the fallback configuration in the dummy app.

The fallback configuration matches the template. Let's verify if any tests depend on stream functionality.

✅ Verification successful

Stream fallback configuration is correctly set

The stream: false fallback in webpack configuration is safe as the codebase only uses Rails Turbo Streams feature and doesn't depend on Node.js stream module.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for stream-related tests or implementations in the dummy app
rg -g '!node_modules' -g '!*.lock' -g '!package.json' 'stream' spec/dummy/

Length of output: 1137

spec/dummy/package.json (1)

80-80: Verify if removing --watch was intentional.

The --watch flag was removed from the build:dev script while other watch-related scripts remain unchanged. This change appears unrelated to the stream fallback configuration updates.

Could you confirm if removing the watch flag was intentional? If not, consider keeping it consistent with other dev scripts:

-    "build:dev": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker",
+    "build:dev": "rm -rf public/webpack/development && yarn build:rescript && RAILS_ENV=development NODE_ENV=development bin/shakapacker --watch",
✅ Verification successful

The removal of --watch flag appears intentional and correct

The package.json shows a clear pattern where watch functionality is deliberately separated into dedicated scripts (build:dev:server and build:dev:watch), while regular build scripts like build:test and build:dev are meant for one-time builds.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# View the complete package.json to understand build script patterns
cat spec/dummy/package.json

# Search for any related build script changes in commit messages or PR
gh pr view --json title,body

Length of output: 3309

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
CHANGELOG.md (1)

870-870: Add language specifier to the code block.

Add 'ruby' as the language specifier to the fenced code block for proper syntax highlighting.

-```
+```ruby
  # This configures the script to run to build the production assets by webpack. Set this to nil
  # if you don't want react_on_rails building this file for you.
  config.build_production_command = "npm run build:production"
🧰 Tools
🪛 Markdownlint (0.37.0)

870-870: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e20058e and 2d8c409.

📒 Files selected for processing (1)
  • CHANGELOG.md (2 hunks)
🧰 Additional context used
🪛 Markdownlint (0.37.0)
CHANGELOG.md

870-870: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: rspec-package-tests (newest)
  • GitHub Check: examples (newest)
  • GitHub Check: build-dummy-app-webpack-test-bundles (oldest)
  • GitHub Check: build
  • GitHub Check: examples (oldest)
  • GitHub Check: rspec-package-tests (oldest)
🔇 Additional comments (1)
CHANGELOG.md (1)

21-23: LGTM! Well-structured changelog entry.

The entry follows best practices by clearly describing the change, including the PR reference, and properly attributing the author.

@Judahmeek
Copy link
Contributor

Superseded by #1680

@Judahmeek Judahmeek closed this Jan 16, 2025
@Judahmeek Judahmeek deleted the abanoubghadban/pro1674/fix-cant-resolve-stream-while-bundling branch January 16, 2025 15:09
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