Skip to content

Conversation

matux
Copy link
Contributor

@matux matux commented Jul 18, 2025

Description of the change

This PR eliminates runtime package.json imports from the server and react native platforms, replacing them with proper ES module defaults. This fixes compatibility issues with modern build tools like Angular SSR, which cannot resolve package.json imports in certain contexts.

The Angular example now builds successfully without any changes to the example project itself.

The DefinePlugin webpack dependency has been removed together with all traces of the old way of loading defaults.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

SDK-518/make-sure-all-sdk-examples-work-properly

@matux matux requested review from waltjones and Copilot July 18, 2025 16:38
@matux matux self-assigned this Jul 18, 2025
@matux matux changed the title Reorganize defaults Eliminate runtime package.json imports and reorganize defaults Jul 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces runtime package.json imports with proper ES module defaults to fix compatibility issues with modern build tools like Angular SSR. The change eliminates webpack DefinePlugin dependencies and moves all default configuration values to dedicated ES modules.

  • Removes runtime package.json imports from server and React Native platforms
  • Creates dedicated defaults modules for shared, server, React Native, and browser configurations
  • Eliminates webpack DefinePlugin usage and related build-time variable injection

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
webpack.config.cjs Removes DefinePlugin and defaultsPlugin references from all webpack configurations
src/server/rollbar.js Replaces package.json imports with ES module imports from defaults files
src/server/defaults.js New file defining server-specific default configurations
src/react-native/rollbar.js Replaces package.json imports with ES module imports from defaults files
src/react-native/defaults.js New file defining React Native-specific default configurations
src/defaults.js Converts to ES modules with named exports for shared default values
src/browser/defaults.js New file consolidating browser-specific defaults including scrub fields
src/browser/core.js Updates imports to use new ES module defaults structure
src/browser/bundles/rollbar.snippet.js Replaces webpack-injected variable with ES module import
package.json Removes defaults configuration section now handled by ES modules
defaults.cjs Removes entire file as webpack DefinePlugin is no longer used

@matux matux force-pushed the matux/remove-defaults-from-package-json branch from 79d91e3 to 792ec97 Compare July 18, 2025 16:44
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is right. Is this file meant to be standalone? Would the import work in this case? Would webpack do the smart thing and bundle the actual constant instead of leaving the import? Actually haven't checked this...

Should tests fail if this didn't work?

Copy link
Contributor

Choose a reason for hiding this comment

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

Webpack writes a file to /dist/plugins/. You can npm run build and see if it generates the expected output.

Here is the usage doc. https://docs.rollbar.com/docs/rollbarjs-plugins

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it does the right thing!

t.configure({payload:{notifier:{plugins:{jquery:{version:"0.0.8"}}}}});

@matux matux merged commit 973bdea into master Jul 18, 2025
4 checks passed
@matux matux deleted the matux/remove-defaults-from-package-json branch July 18, 2025 18:06
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.

2 participants