-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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 15.4.0 does not work in AMD enviroment #8301
Comments
I'm having trouble getting this to reproduce like you say, however I am having an issue. Here's my minimal setup: https://gist.github.com/zpao/6bb8c4c08d5502d3e4d6923ae244fa9f. I'm just getting Can you help clarify your case so we can investigate better? |
Here is a fiddle demonstrating the broken module in ReactDOM. https://jsfiddle.net/w5xjbgcy/1/ Just change the path to 15.3.0 and ReactDOM will work. |
@zpao If you change app.js to this:
You will get exactly the same behaviour, as was described |
@zpao I think the different behavior comes from different requirejs setups. I get the error in a Java library that integrates React with the Apache Tapestry framework (https://github.com/eddyson-de/tapestry-react). |
Today, I encountered an error while using the Promise.all([
System.import('react'),
System.import('react-dom')
]).then((modules) => {
let React = modules[0],
ReactDOM = modules[1];
}); The specific error message is |
I seem to have exact same issue. When I upgrade to newest version ReactDOM was undefined. Currently I changed back, but of course that not the best solution long term solution. |
@joe-sky, same here.
And not only for me: |
Ah, I couldn't get it to work yesterday because the gist is broken. It should read --- react-dom 2016-11-18 15:16:33.813492205 +0100
+++ react-dom.js 2016-11-18 15:18:09.505958843 +0100
@@ -9,7 +9,7 @@
// RequireJS
} else if (typeof define === "function" && define.amd) {
- require(['react'], f);
+ define(['react'], f);
// <script>
} else {
@@ -29,7 +29,7 @@
f(g.React)
}
})(function(React) {
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactDOM = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+ return (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){return f()}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactDOM = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved. |
Can you try submitting a fix? |
No, because I don't want to sign the CLA. |
While this is unrelated to the issue, is there any particular reason you don't want to sign it? From my reading CLA basically says that you actually wrote that code, and that you give us the copyright and patent rights over your contribution, which is necessary for us to safely it include it in an open source project. Is there anything controversial about this? |
Can confirm this fixes my issue. |
We can't easily reverse the order of require & define with the more internal one, that's the one generated as a part of browserifying. We might have to write our own umd wrapper piece instead. I'll try a few things out - need to make sure this continues working with webpack globals as well… |
Is this UMD output created via babel? |
Nope. The internal UMD there is being created by browserify. The outer one is hand-rolled. |
Ouch, I see the problem... |
Yes. I am not a lawyer. I don't have the necessary knowledge about such things to be sure about the exact consequences if I sign the CLA and I actually don't want to be bothered with such things. I'd like to help, but if you make it hard for me then I don't. |
React itself still works (for me) but ReactDOM seems to be broken indeed as of > 15.3.2. I've been looking at it for a while trying a lot of things with shims and everything but without luck. Had to hardcode React to 15.3.2 for the sake of our deploy scheme. |
Can somebody please point me to a failing SystemJS example? I can’t seem to find one. |
I can confirm that requirejs + 15.3.0 works fine. Unfortunately I can't say the same for 15.4.0. |
Thanks, we‘re aware the issue exists 😉 . |
I run into this issue as well in SystemJS. Solution for me was to explicitly tell SystemJS the format of react-dom in meta. |
@alexisvincent: They just released 15.4.1 which fixes AMD support, I can confirm, it now works again! |
If I try to load react-dom with RequireJS, I get an error: "Mismatched anonymous define()".
Looking at the react-dom from the 15.4.0 distribution (https://cdnjs.cloudflare.com/ajax/libs/react/15.4.0/react-dom.js), I notice that there seem to be two UMD wrappers at the top.
This is probably related to the change in the packaging structure (#7164 and #7168).
The text was updated successfully, but these errors were encountered: