Skip to content

Bug: ReactFlightWebpackPlugin does not write files with .mjs extension to the manifest #33155

Closed
@jennyscript

Description

@jennyscript

I'm adding the ReactFlightWebpackPlugin to my project to use server components. The generated react-client-manifest.json does not have any chunks in it. Upon checking the code I see it is specifically only adding files with .js file extension to the chunk list here: https://github.com/facebook/react/blob/main/packages/react-server-dom-webpack/src/ReactFlightWebpackPlugin.js#L280 My project's webpack build generates files with .mjs file extensions.

I have a proposed fix PR here: #33028

React version: 19.1.0

Steps To Reproduce

  1. Configure webpack to generate files with a .mjs file extension. Example:
module.exports = {
  //...
  output: {
    //...
    chunkFilename: '[name].mjs',
    filename: '[name].mjs',
  },
};
  1. Add the plugin to the webpack config. Example:
const ReactServerWebpackPlugin = require("react-server-dom-webpack/plugin");

module.exports = {
  //...
  plugins: [new ReactServerWebpackPlugin({ isServer: false })],
};
  1. Set up one client component as directed in the documentation for server components.
  2. Run the webpack build
  3. Observe that the generated file react-client-manifest.json has empty arrays for the "chunks" list. Sample output:
{
  "file://path/Example.tsx": {
    "id": "./path/Example.tsx",
    "chunks": [],
    "name": "*"
  }
}

Link to code example:
I don't have a full code example, but I have a fix PR here: #33028

The current behavior

No chunks listed in react-client-manifest.json

The expected behavior

Chunks listed in react-client-manifest.json. Testing locally after my PR I see these contents:

{
  "file://path/Example.tsx": {
    "id": "./path/Example.tsx",
    "chunks": [
      "client0",
      "client0-2c4986f8fb78b0ce.mjs"
    ],
    "name": "*"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: 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