-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transpilation in v16.1.0 freezes the react-dom/server interface #11526
Comments
a reproduction is available at https://github.com/travi/react-dom-frozen |
Here is how to fix it: #11520 (comment) Happy to take a PR for this. |
I hope to put a PR together for this sometime today/tonight. I just ran out of time last night |
* Unfreeze the react-dom/server interface this allows stubbing of the exposed named functions, as was possible before v16.1 fixes #11526 * Fix missing version export * Fix missing version export * Whitespace
So, I'm not super happy with this solution, but it seems easier to do this now and maybe break this in 17. Longer term I would encourage you to use mocking solutions that don't require monkeypatching public APIs, if possible. This would break when Node ships ES modules and React offers an ES module version anyway. |
Thats a very valid point, but I really appreciate the understanding to keep this working for the time being. As a testing advocate, this is what caught my eye about the static nature of es module imports early on and I'm really surprised that I haven't seen more concern about it from the js testing community (likely because tools like babel have insulated things enough that it hasn't been forced yet). Not that it is wrong in any way, but it will require pretty drastic changes to testing approaches in js projects to keep them testable. I expect dependency injection and app-level coordination along the lines of an IoC container to become required, but I haven't seem momentum behind such solutions yet, outside of angular. While it is nice to see the ecosystem evolve and mature, it is a little bittersweet to see the current simplicity and approachability to testing in js headed toward significantly more complexity. I hope that some reasonable solutions emerge by the time React and others start publishing versions that cause current approaches to no longer be valid. Thanks again for the understanding and helping this get resolved for the time being. My first contribution to React has been pretty painless as well. Thanks for all you do! |
In case of React, people commonly use Jest which implements its own module system and can But I agree I expect more people to raise concerns over this with time. |
The fix should be out in 16.1.1. |
interesting. i have not tried i've been holding off on |
* Unfreeze the react-dom/server interface this allows stubbing of the exposed named functions, as was possible before v16.1 fixes facebook#11526 * Fix missing version export * Fix missing version export * Whitespace
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
onreact-dom/server
and v16.1 results in the following error:the export from
react-dom/cjs/react-dom-server.node.development
is frozen as: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.
The text was updated successfully, but these errors were encountered: