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

fix(webpack): Add webpack ErrorOverlayPlugin to improve error visibility (fixes #146). #147

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

junhaoliao
Copy link
Collaborator

@junhaoliao junhaoliao commented Dec 2, 2024

Description

Fixes #146

  1. Add webpack ErrorOverlayPlugin to improve error visibility.

Validation performed

  1. Repeated the reproduction steps in the issue and observed the file paths and lines are correctly displayed together with the source code in the overlay. e.g.,
    image

Summary by CodeRabbit

  • New Features

    • Enhanced error handling during development with the addition of a new error overlay plugin.
    • Improved performance with updated source mapping strategy.
  • Bug Fixes

    • Disabled error overlay in the browser for a cleaner development experience.

Copy link

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces updates to the package.json and webpack.dev.js files for the yscope-log-viewer project. Two new dependencies, error-overlay-webpack-plugin and querystring-es3, are added to enhance error handling and query string manipulation. Additionally, the webpack.dev.js file is modified to incorporate the new error overlay plugin, adjust the development server configuration, and change the source mapping strategy for improved performance.

Changes

File Change Summary
package.json Added dependencies: error-overlay-webpack-plugin (^1.1.1), querystring-es3 (^0.2.1).
webpack.dev.js Added ErrorOverlayPlugin to plugins; updated devServer configuration to disable overlay; changed devtool to cheap-module-source-map; modified ReactRefreshWebpackPlugin to disable overlay; added resolve section with fallback for querystring.

Assessment against linked issues

Objective Addressed Explanation
Error overlay displays webpack-internal:// links instead of file names (#[146])

Possibly related PRs

Suggested reviewers

  • Henry8192

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 969ff35 and 41701e7.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (2 hunks)
  • webpack.dev.js (3 hunks)
🔇 Additional comments (7)
webpack.dev.js (5)

5-5: LGTM: ErrorOverlayPlugin integration looks correct!

The addition of ErrorOverlayPlugin directly addresses the issue of webpack-internal:// links in stack traces.

Also applies to: 63-63


19-21: LGTM: Correct configuration to prevent duplicate overlays

Disabling the built-in webpack overlay is necessary when using ErrorOverlayPlugin to avoid duplicate error displays.


60-62: LGTM: Consistent overlay configuration

The overlay configuration for ReactRefreshWebpackPlugin aligns with the devServer client configuration, ensuring consistent error handling behaviour.


65-70: LGTM: Proper fallback configuration for ErrorOverlayPlugin

The querystring fallback is correctly configured and well-documented as a requirement for ErrorOverlayPlugin.


27-27: Verify impact of source map change on error reporting

The switch to "cheap-module-source-map" might affect the quality of error stack traces. Let's verify this doesn't impact the error overlay's effectiveness.

✅ Verification successful

Source map change is compatible with error overlay functionality

The error overlay functionality is properly configured in webpack.dev.js with ErrorOverlayPlugin, and "cheap-module-source-map" is a widely supported devtool option that maintains sufficient source mapping for error reporting. The change from "eval-source-map" to "cheap-module-source-map" trades some debugging detail for better build performance while still providing adequate error stack traces.

  • ErrorOverlayPlugin is properly imported and configured in webpack.dev.js
  • The devtool configuration is consistent with development best practices
  • Error overlay functionality remains intact with the new source map strategy
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any discussions or known issues about ErrorOverlayPlugin compatibility with cheap-module-source-map
rg -g "*.md" -g "*.js" -i "cheap-module-source-map.*error.overlay|error.overlay.*cheap-module-source-map"

# Check if there are any existing devtool configurations in other webpack files
fd -e js -e ts webpack | xargs rg "devtool.*source-map"

Length of output: 263


Script:

#!/bin/bash
# Check for error overlay plugin usage and configuration
rg -g "*.js" -g "*.ts" "ErrorOverlay|error-overlay"

# Check webpack configuration files for any error overlay related settings
fd -e js -e ts webpack | xargs rg -i "overlay"

# Look for any documentation about error reporting configuration
fd README.md CONTRIBUTING.md | xargs rg -i "error|debug|sourcemap"

Length of output: 22846

package.json (2)

54-54: LGTM: Appropriate version selection

The error-overlay-webpack-plugin version ^1.1.1 is the latest stable release and follows proper semver practices.


63-63: LGTM: Required dependency properly added

The querystring-es3 version ^0.2.1 is correctly added as a required dependency for the ErrorOverlayPlugin fallback configuration.


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 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.

@junhaoliao junhaoliao self-assigned this Dec 2, 2024
@junhaoliao junhaoliao changed the title Add webpack ErrorOverlayPlugin to improve error visibility (fixes #146). fix(webpack): Add webpack ErrorOverlayPlugin to improve error visibility (fixes #146). Dec 2, 2024
hot: "only",
open: true,
port: 3010,
watchFiles: ["src/services/**/*"],
},
devtool: "eval-source-map",
devtool: "cheap-module-source-map",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is needed for react-error-overlay to work.

@@ -53,6 +57,15 @@ module.exports = mergeWithRules({
filename: "[name].bundle.js",
},
plugins: [
new ReactRefreshWebpackPlugin(),
new ReactRefreshWebpackPlugin({
overlay: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to disable the overlay provided by @pmmmwh/react-refresh-webpack-plugin to avoid conflicts.

@@ -15,12 +16,15 @@ module.exports = mergeWithRules({
},
})(common, {
devServer: {
client: {
overlay: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to disable the overlay provided by the webpack devServer to avoid conflicts.

@junhaoliao junhaoliao marked this pull request as draft December 3, 2024 16:36
@junhaoliao
Copy link
Collaborator Author

Let's put this on hold as I discovered that the error overlay does not auto dismiss after the error is fixed. some hooks might need to be registered to achieve auto dismiss

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.

Error overlay displays webpack-internal:// links instead of file names in stack traces
1 participant