-
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
React Dom Server: Broken Build for version 15.4.1 #8788
Comments
You are likely using different versions of React and ReactDOMServer. Please make sure you use the exact same version. I also recommend updating both to 15.4.2. |
Also, I don't think importing the UMD bundle is supported in Node environment unless you are also doing the same for React. You can't use ReactDOMServer single-file distribution together with React CommonJS entry point. |
Hi Dan, For the 2 Reply I will have a check and let you know as soon as possible. |
This is a patch release so no, it shouldn't be a problem. If anything, 15.4.2 fixes some issues. But I am pretty certain that if you can't mix UMD with CommonJS packages so that's the likely source of the problem. |
Requiring the UMD Bundle for react is working fine In Furthermore, logging through the bundle I can see that: function(t, n, r) {
"use strict";
var o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
// e is an instanceof React and has no __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED field
n.exports = o.ReactCurrentOwner
} |
Hmm I think you're right. I don't we ever supported using UMD builds in the Node environment. |
I'm trying to optimize performances in general. |
Yea, we should make it clearer the advice to use minified builds is mostly for client-side since we don't have a good way to do this on the server side yet. On the server side, it should be enough to run your app with |
I'll close since we don't support it. For more heavy server side optimization tips check out this PR: raxjs/server-side-rendering-comparison#5 I hope it helps! |
@gaearon it's worth noting that this did work with |
(see this popular talk on SSR performance in React that recommends it) |
Hmm, I wasn't aware that this used to work. |
Seems this would happen since 15.4.0.Not sure if it's the desired behavior. |
Yes, that's the main reason, but we can't revert it (there are good reasons for this change). |
Note that not only the server build of react-dom is affected; this fails in the same way with React 15.4.2: var React = require("react/dist/react.min.js");
var ReactDOM = require("react-dom/dist/react-dom.min.js"); (The use case for such an operation is loading the minified version of React inside Atom). |
This accidentally happened to work because package boundaries were fake, but now they are real. However, now I’m not sure we could support this even if we wanted to. These are UMD bundles. However you are loading them in a CommonJS environment. How would you expect them to “find” one another? They don’t know each other’s locations. Since you’re in CommonJS, they can’t set globals, like they do in the browser. So I understand it’s frustrating this doesn’t work anymore, but it was never officially supported (you won’t find this usage suggested anywhere in the docs), and as far as I understand, it’s not even feasible to support after the true package split. The real solution here is to bundle your code if you rely on this. If you bundle the code (e.g. with webpack, browserify or rollup), you can always specify Let me know if I missed something, but so far it seems like we can’t fix it. Sorry! For server rendering performance, we intend to provide flat precompiled bundles in the future which should have the same effect. |
I was using webpack and that's the reason because |
With Webpack, using |
@gaearon, in the case of Atom you can, in fact, set globals by using Alternatively you could, if you wanted to, provide an additional set of minified files for As to using bundling tools, this is certainly an option, but a rather inconvenient one as far as Atom extension development goes (since it introduces a build stage). Of course, if you've decided not to support importing from minified files in |
@gaearon Is it really enough to set I'm using Webpack 2.6.1 and I'm trying to use minified versions of resolve: {
alias: {
react: require.resolve('react/dist/react.min.js'),
'react-dom/server': require.resolve('react-dom/dist/react-dom-server.min.js'),
},
}, but I'm getting exactly the same error, i.e. |
@szimek I'm having the exact same error, except in React-Native and no |
@luchillo17 You seem to be mixing incompatible versions of |
Oh i didn't think that'd be a thing, is there an official compatibility chart? |
React Native always supports only one version of |
@gaearon I've looked at that package.json file and the version is At this point i'm considering starting a new project and moving my source folder. |
Please provide a project reproducing the problem. People generally use RN without such issues so you need to give more details to help you. |
Can i tell |
Sorry, you'd need to ask this in |
So i guess providing you with a repo would mean nothing since it's a |
I can take a look at it to see if anything is wrong on the
because |
Also i'm using typescript, maybe that's part of the issue? |
I don't know. As for your report,
This doesn't sound right. You can see That file was added in So something is wrong with your report. |
Please provide minimal code reproducing the problem. It's likely the problem is exactly what the error message says. In future versions we'll provide more details there. |
I'll try making it from zero because the current error message says The error above shows after activating |
@gaearon I've started a new one, still no business logic, only adding typescript, now it shows |
@gaearon I've put my base project here: |
If it's not related to the issue you originally described, please create a new issue with your project in React Native repo. Thanks! |
@gaearon I've created one in React Native repo since it might be related to them instead of just React: |
Do you want to request a feature or report a bug?
BUG
What is the current behavior?
It breaks the code execution
file:
react-dom/dist/react-dom-server.min.js
Beautified:
Output:
What is the expected behavior?
var ReactDomServer = require('react-dom/dist/react-dom-server.min.js');
with the desired goal of having a server-side rendering for production which skips unnecessary comments, warnings, etc. React Documentation PageThe text was updated successfully, but these errors were encountered: