Skip to content

Bug: react-dom-webpack-server bundles are currently broken on main #26443

Closed as not planned
@markerikson

Description

@markerikson

React version: N/A (Build tooling issue on main as of commit 0131d0c )

Steps To Reproduce

  1. Clone, install, and run yarn build
  2. Inspect build/oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js
  3. Scroll to line 300, around var reservedProps =. Compare with react-dom-bindings/src/shared/DOMProperty.js. Note that:
  • There is no properties object in the build output
  • The lines that should say properties[name] = new PropertyInfoRecord(....) are missing the assignment, and only say new PropertyInfoRecord()
  • A couple of the associated constants like const RESERVED = 0 are also missing

This appears to be a bug in Rollup's tree-shaking behavior. If the Rollup config in build.js is modified to say moduleSideEffects: 'safest', the missing content appears in these bundles.

Per experimentation, this can be addressed by adding a custom Rollup plugin that specifically tells Rollup "this code has side effects, don't tree-shake it" (based on rollup/rollup#4090 (comment) ):

module.exports = function disableTreeshake() {
  return {
    name: 'scripts/rollup/plugins/disable-treeshake',
    transform(code, id) {
      // Fix issue with `react-dom-webpack-server` bundles accidentally
      // stripping out the `properties` object and not filling it out
      if (id.endsWith('DOMProperty.js')) {
        return {
          code,
          map: null,
          moduleSideEffects: 'no-treeshake',
        };
      }
      return null;
    },
  };
};

Link to code example:

The current behavior

The full code from DOMProperty.js does not show up in those react-dom-webpack-server bundles

The expected behavior

The DOMProperty output should show up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions