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

chore: clean up build configurations #2060

Merged

Conversation

saikumarrs
Copy link
Member

@saikumarrs saikumarrs commented Feb 24, 2025

PR Description

I've fixed several issues and cleaned up stale items in the packages` build configurations:

  • Bugsnag API key and URL are not required anymore except for the legacy SDK package.
  • Sanity suite deployment workflow has been updated to send the missing env variables during the SDK packages build step.
  • Removed unused globals like __SDK_BUNDLE_FILENAME__ from appropriate packages.

The clean up helps us in maintaining the build configurations better now that the clutter has been cleared.

Linear task (optional)

https://linear.app/rudderstack/issue/SDK-3012/clean-up-build-configurations

Cross Browser Tests

Please confirm you have tested for the following browsers:

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • Chores

    • Removed outdated example configuration entries related to error tracking.
    • Cleaned up obsolete settings in development and testing environments.
  • Refactor

    • Streamlined bundling logic for plugins, enhancing consistency in build configurations.
    • Simplified requirements by removing unused global declarations, leading to a more maintainable setup.

These updates aim to reduce clutter in configuration files and improve the overall development and build process, ensuring a smoother setup and deployment experience for users.

@saikumarrs saikumarrs self-assigned this Feb 24, 2025
@saikumarrs saikumarrs requested a review from a team as a code owner February 24, 2025 05:01
Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

📝 Walkthrough

Walkthrough

This pull request removes references to Bugsnag error tracking and deprecated dynamic bundle configurations from several files. The changes delete the BUGSNAG_API_KEY entry in multiple environment example files, remove Bugsnag-related constants and placeholders from Rollup configuration files, and eliminate unused global variables in both test and type declaration files. A new constant is introduced in one Rollup file to simplify plugin bundling logic, and outdated replacement keys in loading scripts are removed.

Changes

File(s) Change Summary
.env.example, packages/analytics-js/.env.example, packages/analytics-js-service-worker/.env.example Removed BUGSNAG_API_KEY from environment examples; deleted the service worker env file that contained multiple configuration placeholders including Bugsnag variables.
packages/analytics-js-plugins/rollup.config.mjs, packages/analytics-js/rollup.config.mjs Removed Bugsnag-related variables (bugsnagSDKUrl, __RS_BUGSNAG_API_KEY__, __RS_BUGSNAG_SDK_URL__); added bundleAllPlugins constant and simplified outDirCDNRoot assignment in the analytics JS Rollup config.
jest/jest.setup-dom.js Removed the global property assignment for __IS_DYNAMIC_CUSTOM_BUNDLE__.
packages/loading-scripts/rollup.config.mjs Removed the remotePluginsBasePath constant and several replacement keys (__SDK_BUNDLE_FILENAME__, __CONFIG_SERVER_HOST__, __DEST_SDK_BASE_URL__, __PLUGINS_BASE_URL__) from the Rollup configuration.
types/global.d.ts Removed declarations for global constants __IS_DYNAMIC_CUSTOM_BUNDLE__ and __BUNDLED_PLUGINS_LIST__.

Possibly related PRs

Suggested reviewers

  • ChryssaAliferi
  • 1abhishekpandey
✨ 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.

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

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.41%. Comparing base (ed4db5b) to head (703a59f).
Report is 2 commits behind head on hotfix/unsuppress-npm-errors.

Additional details and impacted files
@@                      Coverage Diff                      @@
##           hotfix/unsuppress-npm-errors    #2060   +/-   ##
=============================================================
  Coverage                         61.41%   61.41%           
=============================================================
  Files                               478      478           
  Lines                             16404    16404           
  Branches                           3232     3245   +13     
=============================================================
  Hits                              10075    10075           
+ Misses                             5122     5105   -17     
- Partials                           1207     1224   +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@saikumarrs
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Feb 24, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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)
packages/analytics-js/rollup.config.mjs (1)

166-276: Consider refactoring the plugin configuration.

The plugin configuration section is quite lengthy and could benefit from being split into smaller, more focused functions. This would improve maintainability and make the code easier to understand.

Consider extracting plugin configurations into separate functions:

- return {
-   watch: {
-     include: ['src/**', ...additionalWatchPaths],
-   },
-   external: [/rudderAnalyticsRemotePlugins\/.*/, ...Object.keys(pkg.peerDependencies || {})],
-   onwarn(warning, warn) {
-     if (warning.code === 'THIS_IS_UNDEFINED') {
-       return;
-     }
-     warn(warning);
-   },
-   plugins: [
-     replace({...}),
-     resolve({...}),
-     // ... more plugins
-   ],
- };
+ const getWatchConfig = () => ({
+   include: ['src/**', ...additionalWatchPaths],
+ });
+ 
+ const getExternalConfig = () => [
+   /rudderAnalyticsRemotePlugins\/.*/,
+   ...Object.keys(pkg.peerDependencies || {}),
+ ];
+ 
+ const getWarningHandler = () => (warning, warn) => {
+   if (warning.code === 'THIS_IS_UNDEFINED') {
+     return;
+   }
+   warn(warning);
+ };
+ 
+ const getPluginsConfig = () => [
+   replace({...}),
+   resolve({...}),
+   // ... more plugins
+ ];
+ 
+ return {
+   watch: getWatchConfig(),
+   external: getExternalConfig(),
+   onwarn: getWarningHandler(),
+   plugins: getPluginsConfig(),
+ };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ed4db5b and 703a59f.

⛔ Files ignored due to path filters (1)
  • .github/workflows/deploy-sanity-suite.yml is excluded by !**/*.yml
📒 Files selected for processing (8)
  • .env.example (0 hunks)
  • jest/jest.setup-dom.js (0 hunks)
  • packages/analytics-js-plugins/rollup.config.mjs (0 hunks)
  • packages/analytics-js-service-worker/.env.example (0 hunks)
  • packages/analytics-js/.env.example (0 hunks)
  • packages/analytics-js/rollup.config.mjs (3 hunks)
  • packages/loading-scripts/rollup.config.mjs (0 hunks)
  • types/global.d.ts (0 hunks)
💤 Files with no reviewable changes (7)
  • .env.example
  • jest/jest.setup-dom.js
  • types/global.d.ts
  • packages/analytics-js-service-worker/.env.example
  • packages/analytics-js-plugins/rollup.config.mjs
  • packages/analytics-js/.env.example
  • packages/loading-scripts/rollup.config.mjs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Bundle size checks
🔇 Additional comments (3)
packages/analytics-js/rollup.config.mjs (3)

31-31: LGTM! Improved plugin bundling logic.

The new bundleAllPlugins constant simplifies the logic for determining when to bundle all plugins, making it more maintainable and easier to understand.

Also applies to: 183-183


43-43: LGTM! Simplified CDN path logic.

The outDirCDNRoot assignment has been simplified by removing the conditional logic, which aligns with the PR's objective of cleaning up build configurations.


189-189:

❓ Verification inconclusive

Verify Bugsnag release stage configuration.

While Bugsnag API key and URL requirements are being removed, the __RS_BUGSNAG_RELEASE_STAGE__ replacement is still present. This might need to be removed for consistency.


🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining Bugsnag-related configurations

# Search for Bugsnag-related configurations in the codebase
rg -i "bugsnag" --type js --type ts --type json

Length of output: 47


I've noticed that the initial search didn't return any Bugsnag references—likely because it excluded .mjs files (where our reference lives). To double-check, please verify the existence and usage of this configuration in the Rollup config by running a search on the file itself:

Once you confirm that __RS_BUGSNAG_RELEASE_STAGE__ appears only in this file and isn’t used elsewhere in the codebase, please verify if it’s still needed. Given that other Bugsnag configurations (like the API key and URL) are already removed, it might be best for consistency to also remove this release stage configuration—provided it doesn’t affect any legacy behavior.

Action: Confirm whether __RS_BUGSNAG_RELEASE_STAGE__ is required. If not, remove it from packages/analytics-js/rollup.config.mjs.


🏁 Script executed:

#!/bin/bash
rg -i "BUGSNAG_RELEASE_STAGE" packages/analytics-js/rollup.config.mjs

Length of output: 149


Action: Verify and assess the necessity of the Bugsnag release stage configuration

It appears the initial search didn’t locate the expected file because the filename (or extension) might differ from what was assumed (i.e. rollup.config.mjs). To clarify the situation, please run this script to search for any occurrences of __RS_BUGSNAG_RELEASE_STAGE__ in all potential rollup configuration files under the packages/analytics-js directory:

Once you review the output:

  • If the __RS_BUGSNAG_RELEASE_STAGE__ configuration is only found in legacy rollup settings and isn’t required given that other Bugsnag configurations (e.g., API key and URL) have been removed, please remove it for consistency.
  • If it turns out that this configuration is still actively used or required for legacy support, please document its purpose accordingly.

🏁 Script executed:

#!/bin/bash
# Locate any rollup configuration files (with .mjs or .js extensions) under packages/analytics-js
files=$(fd -e mjs -e js "rollup.config" packages/analytics-js)
if [ -z "$files" ]; then
  echo "No rollup configuration files found in packages/analytics-js."
else
  for file in $files; do
    echo "Searching in: $file"
    rg -n "__RS_BUGSNAG_RELEASE_STAGE__" "$file"
  done
fi

Length of output: 321


Action: Confirm the necessity of the Bugsnag release stage configuration

Our searches indicate that there is no evidence of a rollup configuration file in the expected location (i.e. under “packages/analytics-js”). In particular, attempts to locate occurrences of __RS_BUGSNAG_RELEASE_STAGE__ returned no results, which may imply that this configuration is either no longer in use or the file has been relocated.

  • Please manually verify:
    • Whether the configuration snippet (__RS_BUGSNAG_RELEASE_STAGE__: process.env.BUGSNAG_RELEASE_STAGE || 'production') is present in any rollup configuration file.
    • If it’s not used anywhere else in the codebase, confirm that it can safely be removed for consistency with the removal of other Bugsnag settings.

Once you confirm the configuration isn’t required, please proceed to remove it.

Copy link

size-limit report 📦

Name Size (Base) Size (Current) Size Limit Status
Cookies Utils - Legacy - NPM (ESM) 1.54 KB 1.54 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (CJS) 1.75 KB 1.75 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (UMD) 1.54 KB 1.54 KB (0%) 2 KB
Cookies Utils - Modern - NPM (ESM) 1.17 KB 1.17 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (CJS) 1.4 KB 1.4 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (UMD) 1.16 KB 1.16 KB (0%) 1.5 KB
Plugins Module Federation Mapping - Legacy - CDN 332 B 332 B (0%) 512 B
Plugins Module Federation Mapping - Modern - CDN 331 B 331 B (0%) 512 B
Plugins - Legacy - CDN 13.66 KB 13.66 KB (0%) 14 KB
Plugins - Modern - CDN 5.64 KB 5.64 KB (0%) 6 KB
Common - No bundling 17.92 KB 17.93 KB (+0.1% ▲) 18.4 KB
Load Snippet 765 B 765 B (0%) 1 KB
Core (v1.1) - NPM (ESM) 30.16 KB 30.16 KB (0%) 32 KB
Core (v1.1) - NPM (CJS) 30.32 KB 30.32 KB (0%) 32 KB
Core (v1.1) - NPM (UMD) 30.23 KB 30.23 KB (0%) 32 KB
Core (Content Script - v1.1) - NPM (ESM) 29.59 KB 29.59 KB (0%) 30.5 KB
Core (Content Script - v1.1) - NPM (CJS) 29.84 KB 29.84 KB (0%) 30.5 KB
Core (Content Script - v1.1) - NPM (UMD) 29.71 KB 29.71 KB (0%) 30.5 KB
Core (v1.1) - Legacy - CDN 32.03 KB 32.03 KB (0%) 32.5 KB
Core (v1.1) - Modern - CDN 30 KB 30 KB (0%) 32 KB
Service Worker - Legacy - NPM (ESM) 30.54 KB 30.54 KB (0%) 31 KB
Service Worker - Legacy - NPM (CJS) 30.85 KB 30.85 KB (0%) 31 KB
Service Worker - Legacy - NPM (UMD) 30.69 KB 30.69 KB (0%) 31 KB
Service Worker - Modern - NPM (ESM) 25.73 KB 25.73 KB (0%) 26 KB
Service Worker - Modern - NPM (CJS) 26 KB 26 KB (0%) 26.5 KB
Service Worker - Modern - NPM (UMD) 25.75 KB 25.75 KB (0%) 26 KB
Core - Legacy - NPM (ESM) 47.42 KB 47.42 KB (0%) 48 KB
Core - Legacy - NPM (CJS) 47.64 KB 47.64 KB (0%) 48 KB
Core - Legacy - NPM (UMD) 47.41 KB 47.41 KB (0%) 48 KB
Core - Legacy - CDN 47.53 KB 47.53 KB (0%) 47.6 KB
Core - Modern - NPM (ESM) 26.85 KB 26.85 KB (0%) 27 KB
Core - Modern - NPM (CJS) 27.06 KB 27.06 KB (0%) 27.1 KB
Core - Modern - NPM (UMD) 26.89 KB 26.89 KB (0%) 27 KB
Core - Modern - CDN 27.13 KB 27.13 KB (0%) 27.5 KB
Core (Bundled) - Legacy - NPM (ESM) 47.42 KB 47.42 KB (0%) 48 KB
Core (Bundled) - Legacy - NPM (CJS) 47.67 KB 47.67 KB (0%) 48 KB
Core (Bundled) - Legacy - NPM (UMD) 47.41 KB 47.41 KB (0%) 48 KB
Core (Bundled) - Modern - NPM (ESM) 38.57 KB 38.57 KB (0%) 39 KB
Core (Bundled) - Modern - NPM (CJS) 38.88 KB 38.88 KB (0%) 39 KB
Core (Bundled) - Modern - NPM (UMD) 38.56 KB 38.56 KB (0%) 39 KB
Core (Content Script) - Legacy - NPM (ESM) 47.32 KB 47.32 KB (0%) 48 KB
Core (Content Script) - Legacy - NPM (CJS) 47.59 KB 47.59 KB (0%) 48 KB
Core (Content Script) - Legacy - NPM (UMD) 47.38 KB 47.38 KB (0%) 48 KB
Core (Content Script) - Modern - NPM (ESM) 38.5 KB 38.5 KB (0%) 39 KB
Core (Content Script) - Modern - NPM (CJS) 38.78 KB 38.78 KB (0%) 39 KB
Core (Content Script) - Modern - NPM (UMD) 38.54 KB 38.54 KB (0%) 39 KB
All Integrations - Legacy - CDN 94.94 KB 94.94 KB (0%) 95.3 KB
All Integrations - Modern - CDN 90.5 KB 90.5 KB (0%) 91 KB

@saikumarrs saikumarrs merged commit 32e6104 into hotfix/unsuppress-npm-errors Feb 24, 2025
12 checks passed
@saikumarrs saikumarrs deleted the chore.cleanup-build-configs-sdk-3012 branch February 24, 2025 08:09
saikumarrs added a commit that referenced this pull request Feb 24, 2025
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