Skip to content

[RSC] Hydration error in build mode from HTML minification #10205

@mwszekely

Description

@mwszekely

First, thank you for this RSC implementation -- it's nice to be able to play with server components outside of Next.js! 🤩

🐛 bug report

Parcel's default behavior of removing comments in build mode seems to cause issues with hydration when loaded in the browser.

Specifically, if a new project is created with npm create parcel react-static, then the development build will throw a hydration error ("React error #418") upon being opened in the browser, even before any modifications are made to any files.

Any of the following options seem to fix the issue:

  • Create a .htmlnanorc config file and add "removeComments": false
  • Specify --no-optimize or add optimize: false to targets.react-static in package.json
  • Remove the <Counter /> component

🎛 Configuration (.babelrc, package.json, cli command)

No changes need to be made from what create parcel starts with, and updating all packages does not appear to fix the error.

🤔 Expected Behavior

While it seems to be trivially work-around-able, it would be preferable if there were no hydration error with the default settings I suppose.

😯 Current Behavior

The error thrown when loaded into the browser appears as follows with its stack trace:

pages.f916a5b0.js:1  Uncaught Error: Minified React error #418; visit https://react.dev/errors/418?args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at rP (pages.f916a5b0.js:1:70043)
    at pages.f916a5b0.js:1:152610
    at ip (pages.f916a5b0.js:1:155391)
    at is (pages.f916a5b0.js:1:147749)
    at pages.f916a5b0.js:1:143864
    at u5 (pages.f916a5b0.js:1:143965)
    at i$ (pages.f916a5b0.js:1:165208)
    at MessagePort.L (pages.f916a5b0.js:1:205166)

💻 Code Sample

(See the default demo provided by running npm create parcel react-static)

🌍 Your Environment

Software Version(s)
Parcel 2.15.4
Node 24.0.1
npm/Yarn 11.3.0
Operating System Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions