Skip to content

Transpilation in v16.1.0 freezes the react-dom/server interface #11526

Closed
@travi

Description

@travi

As initially reported in #11520 (comment), attempting to upgrade from v16.0 to v16.1 caused a test that was previously working to fail. The test was using sinon to stub renderToStaticMarkup on react-dom/server and v16.1 results in the following error:

TypeError: Cannot redefine property: renderToStaticMarkup
    at Function.defineProperty (<anonymous>)
    at wrapMethod (node_modules/sinon/lib/sinon/util/core/wrap-method.js:92:16)
    at stub (node_modules/sinon/lib/sinon/stub.js:60:44)
    at Object.stub (node_modules/sinon/lib/sinon/collection.js:102:33)
    at Context.setup (test/unit/....)

the export from react-dom/cjs/react-dom-server.node.development is frozen as:

Object.freeze({
  renderToString: renderToString,
  renderToStaticMarkup: renderToStaticMarkup,
  renderToNodeStream: renderToNodeStream,
  renderToStaticNodeStream: renderToStaticNodeStream,
  version: version
});

the source is not frozen, and #11520 (comment) further confirms that the Object.freeze() is a result of the transpilation.

for now, i am simply splitting this report into a separate issue from #11520, but i will add a reproduction soon and plan to submit a PR as a follow up.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions