-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[0.56.0] Cannot import re-exported named symbols #20083
Comments
Does the bot just automatically add the “Old Version” tag to every new issue? |
Looking at the generated /* @flow */
import _default from 'react';
export default _default;
export * from 'react'; This was transpiled into: __d(function (global, _$$_REQUIRE, module, exports, _dependencyMap) {
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {};
exports.default = void 0;
var _react = _interopRequireDefault(_$$_REQUIRE(_dependencyMap[0], "react"));
Object.keys(_react).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _react[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default2 = _react.default;
exports.default = _default2;
},328,[594],"index.js");
Am I missing or misreading anything? If not, the next question is why building with RN generates this… |
Same issue here |
I don't have any details to add but am also hitting this issue and very stuck. |
It looks like—I’m groping in unknown territory here—for some reason it’s using |
Minimal repro: https://github.com/haggholm/babel-re-export-failure |
See Babel issue. I now realise that the reason we have not had this problem with our web build, but only React Native, is not an issue with RN per se, but due to the fact that Webpack can consume ES modules, so we do not perform a CommonJS module transform and hence don’t have any problematic Babel helpers in the Webpack build. |
This has now been fixed in Babel (master); presumably it will be released in their next beta version (54). I hope that’s soon enough to go in the next RN point release… |
The bug is fixed in the latest babel |
Metro 0.42.2 has this fix, and we're now on Metro 0.43+. Closing. |
Environment
Description
0.56 is exciting times! After getting past #19955 and then thanks to the changes in other modules prompted by @Ashoat in #20038, I’m finally able to build a JS bundle. However, it immediately crashes. The exact crash is irrelevant and uninteresting, but what it comes down to is this:
@client/react
is a do-nothing shim that we use as a mechanism for synchronizing the version; it simply depends on a specific version of React (currently 16.4.1) looks like this:Possibly ugly, but I thought fairly harmless. However, just as in my previous issues (#19955, #20038), this works fine with Webpack, and worked fine with RN 0.55, but fails in RN 0.56.
If the
Component
class is explicitly re-exported, it works, and the default export works; but the generic re-export syntaxexport * from
does not. As we use this to re-export quite a lot of symbols, it would not be trivial to update all those references (and it would change our shim from a fairly innocent do-nothing to something requiring active maintenance when symbol names change).The text was updated successfully, but these errors were encountered: