Skip to content

chore: disable sourcemaps for non-prod builds and cleanup craco configs#38706

Merged
KelvinOm merged 2 commits intoreleasefrom
chore/prod-build-performance
Jan 17, 2025
Merged

chore: disable sourcemaps for non-prod builds and cleanup craco configs#38706
KelvinOm merged 2 commits intoreleasefrom
chore/prod-build-performance

Conversation

@KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Jan 16, 2025

Description

  • reduce --max-old-space-size to 7168 for build. Test for EE here.
  • disable sourcemaps for non-prod build
  • cleanup craco configs

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12825105662
Commit: 80b63a6
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/Binding/Api_withPageload_Input_spec.js
List of identified flaky tests.
Fri, 17 Jan 2025 09:34:32 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Configuration Updates

    • Reduced memory allocation for the build process.
    • Updated Webpack configuration with Brotli compression.
    • Modified WebSocket settings for the development server.
    • Streamlined build configuration by removing unnecessary sections.
  • Performance Optimization

    • Adjusted build memory limits.
    • Improved compression algorithm for build artifacts.

@KelvinOm KelvinOm requested a review from dvj1988 January 16, 2025 13:58
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2025

Walkthrough

The pull request introduces configuration modifications across several client-side build configuration files. The changes primarily focus on optimizing build and development server settings, including adjusting memory allocation in the build script, updating Webpack compression settings, and refining WebSocket and caching configurations. These modifications streamline the build and development processes for the client application.

Changes

File Change Summary
app/client/build.sh Reduced Node.js max old space size from 10240 MB to 7168 MB
app/client/craco.build.config.js - Updated CompressionPlugin to use Brotli compression
- Removed jest configuration
- Added babel configuration with babel-plugin-lodash
app/client/craco.common.config.js Removed devServer and babel configurations
app/client/craco.dev.config.js - Added webSocketURL configuration for development server
- Moved optimization, cache, and experiments under webpack.configure

Possibly related PRs

Suggested reviewers

  • sharat87
  • ApekshaBhosale
  • dvj1988

Poem

🚀 Configs dance, memory's light
Brotli compresses with all its might
WebSockets sing, build scripts gleam
Performance flows like a coding dream
Optimization's sweet refrain! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c9d523 and 80b63a6.

📒 Files selected for processing (4)
  • app/client/build.sh (1 hunks)
  • app/client/craco.build.config.js (2 hunks)
  • app/client/craco.common.config.js (0 hunks)
  • app/client/craco.dev.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/craco.common.config.js
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/client/build.sh
  • app/client/craco.dev.config.js
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (4)
app/client/craco.build.config.js (4)

Line range hint 41-54: LGTM! FaroSourceMapUploaderPlugin condition updated as requested.

The plugin is now correctly configured to only run in PRODUCTION environment.


Line range hint 55-63: LGTM! Optimal compression configuration.

The Brotli compression setup with appropriate thresholds and file types will provide better compression ratios compared to gzip.


85-90: Consider the impact on development debugging.

While disabling sourcemaps for non-production builds will improve build performance, it might impact debugging capabilities during development. Have you verified that this won't affect the development workflow significantly?

Consider adding a comment explaining the rationale for this change to help future maintainers understand the trade-off between build performance and debugging capabilities.


79-84: Verify the reason for disabling babel cache.

Disabling the babel cache directory could impact build performance. Was this intentionally disabled to address a specific issue?

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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.

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.

@KelvinOm KelvinOm added the ok-to-test Required label for CI label Jan 16, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jan 16, 2025
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 (2)
app/client/craco.dev.config.js (1)

8-13: Consider using dynamic WebSocket configuration.

The hardcoded WebSocket configuration might not work in all development environments. Consider using environment variables for hostname and port.

 webSocketURL: {
-  hostname: "127.0.0.1",
+  hostname: process.env.WDS_SOCKET_HOST || "127.0.0.1",
-  port: 3000,
+  port: process.env.WDS_SOCKET_PORT || 3000,
   protocol: "ws",
 },
app/client/craco.build.config.js (1)

79-84: Consider enabling babel cache for faster builds.

Disabling cacheDirectory might impact build performance. Unless there's a specific reason, consider enabling it.

 babel: {
   plugins: ["babel-plugin-lodash"],
   loaderOptions: {
-    cacheDirectory: false,
+    cacheDirectory: true,
   },
 },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3e5e43 and 9c9d523.

📒 Files selected for processing (4)
  • app/client/build.sh (1 hunks)
  • app/client/craco.build.config.js (1 hunks)
  • app/client/craco.common.config.js (0 hunks)
  • app/client/craco.dev.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/craco.common.config.js
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (3)
app/client/craco.dev.config.js (1)

21-32: LGTM! Webpack configuration looks good.

The cache and optimization settings are appropriate for development builds. The filesystem cache with memoryCacheUnaffected will improve build performance.

app/client/craco.build.config.js (1)

85-89: LGTM! Smart handling of source maps.

Good approach to conditionally enable source maps only for production builds.

app/client/build.sh (1)

21-21: Verify memory requirements for production builds.

The reduction in --max-old-space-size from 10GB to 7GB might impact large production builds. Please ensure this has been tested with your largest production build scenario.

✅ Verification successful

Memory allocation change appears intentional and beneficial

The change increases production build memory from 4GB to 7GB, while keeping local/staging builds at 4GB. This environment-specific optimization suggests careful consideration of memory requirements.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the memory usage during build process

# Get the total memory usage during a test build
{ time REACT_APP_ENVIRONMENT=PRODUCTION craco --max-old-space-size=7168 build --config craco.build.config.js; } 2>&1 | grep "maxRss"

Length of output: 13


Script:

#!/bin/bash
# Check git history for memory-related changes in build scripts
git log -p -- "**/build.sh" | grep -B 5 -A 5 "max-old-space-size"

# Search for any other memory configurations in build files
fd -e js -e json -e sh | xargs rg "max-old-space-size"

# Look for build-related configuration files
fd "craco|webpack" -e js -e json

Length of output: 538

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)
app/client/craco.dev.config.js (1)

8-13: Consider using environment variables for WebSocket configuration.

The hardcoded WebSocket configuration might not work in all development environments. Consider making these values configurable through environment variables.

       webSocketURL: {
-        hostname: "127.0.0.1",
-        pathname: "/ws",
-        port: 3000,
+        hostname: process.env.WS_HOST || "127.0.0.1",
+        pathname: process.env.WS_PATH || "/ws",
+        port: process.env.WS_PORT || 3000,
         protocol: "ws",
       },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3e5e43 and 9c9d523.

📒 Files selected for processing (4)
  • app/client/build.sh (1 hunks)
  • app/client/craco.build.config.js (1 hunks)
  • app/client/craco.common.config.js (0 hunks)
  • app/client/craco.dev.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • app/client/craco.common.config.js
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (4)
app/client/craco.dev.config.js (1)

21-32: LGTM: Webpack configuration restructuring.

The reorganization of cache and optimization settings under webpack.configure improves configuration clarity and maintainability.

app/client/craco.build.config.js (2)

79-84: Reconsider disabling Babel cache directory.

Disabling the Babel cache directory (cacheDirectory: false) might significantly impact build performance. Unless there's a specific reason, consider keeping it enabled.

Could you explain the rationale behind disabling the Babel cache directory?


85-89: LGTM: Source map configuration aligns with PR objectives.

The conditional source map generation (devtool: env === "PRODUCTION" ? "source-map" : false) effectively implements the requirement to disable source maps for non-production builds.

app/client/build.sh (1)

21-21: Verify memory requirements for reduced heap size.

The reduction in --max-old-space-size from 10240MB to 7168MB might impact large builds. Please ensure this was tested with a full production build including all features.

@KelvinOm
Copy link
Collaborator Author

/build-deploy-preview skip-tests=true

@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12810542557.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 38706.
recreate: .

@github-actions
Copy link

Deploy-Preview-URL: https://ce-38706.dp.appsmith.com

hetunandu
hetunandu previously approved these changes Jan 17, 2025
// Jest module mapper which will detect our absolute imports.
"^@test(.*)$": "<rootDir>/test$1",
},
devtool: env === "PRODUCTION" ? "source-map" : false,
Copy link

Choose a reason for hiding this comment

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

@KelvinOm can you also change the condition for faros sourcemap plugin? It's enabled for STAGING and PRODUCTION now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dvj1988 Do you mean to remove check for STAGING and leave it only PRODUCTION? I.e. the condition will be like this?

if (env === "PRODUCTION") {
  plugins.push(
    new FaroSourceMapUploaderPlugin({...}),
  );
}

Copy link

Choose a reason for hiding this comment

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

Yes.

Copy link

@dvj1988 dvj1988 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@KelvinOm KelvinOm merged commit 41a5110 into release Jan 17, 2025
80 of 82 checks passed
@KelvinOm KelvinOm deleted the chore/prod-build-performance branch January 17, 2025 09:35
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
…gs (appsmithorg#38706)

## Description
- reduce --max-old-space-size to 7168 for build. [Test for EE
here](appsmithorg/appsmith-ee#5932).
- disable sourcemaps for non-prod build
- cleanup craco configs

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]
> 🔴 🔴 🔴 Some tests have failed.
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12825105662>
> Commit: 80b63a6
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12825105662&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.All
> Spec: 
> The following are new failures, please fix them before merging the PR:
<ol>
>
<li>cypress/e2e/Regression/ClientSide/Binding/Api_withPageload_Input_spec.js</ol>
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master"
target="_blank">List of identified flaky tests</a>.
> <hr>Fri, 17 Jan 2025 09:34:32 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Configuration Updates**
	- Reduced memory allocation for the build process.
	- Updated Webpack configuration with Brotli compression.
	- Modified WebSocket settings for the development server.
	- Streamlined build configuration by removing unnecessary sections.

- **Performance Optimization**
	- Adjusted build memory limits.
	- Improved compression algorithm for build artifacts.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This was referenced Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants