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
Overriding export *
causes TypeError
#3137
Comments
I see. So Rollup is basically interfering with its own logic here. I see at least two possible solutions:
|
Should also probably check how Babel handles this. |
Babel creates an object with all named exports and skips the exports in the copying logic: Babel REPL link. But it looks like Babel doesn't handle overriding exports correctly, either. It works for named exports but if two |
Thanks for checking. Not sure what to make of the second scenario, but at least the first is better than what we have at the moment. As far as I know, the correct behaviour for conflicting namespace reexports is to remove the conflicting bindings. So if the bindings should be non-configurable, we would need to check and omit the bindings of the other export in such a scenario. I.e. var _module = require("module-1");
var _module2 = require("module-2");
Object.keys(_module).forEach(function (key) {
if (key === "default" || key === "__esModule" ||
Object.prototype.hasOwnProperty.call(_module2, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _module[key];
}
});
});
Object.keys(_module2).forEach(function (key) {
if (key === "default" || key === "__esModule" ||
Object.prototype.hasOwnProperty.call(_module, key)) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _module2[key];
}
});
}); Combining this with Babel's approach for the first scenario, I guess this should work, or am I overlooking something here? |
As a temporary workaround I've done the following and it works. import * as fs from "fs";
const existsSync = ":)";
export default { ...fs, existsSync } This way it doesn't try to do But would be good to see this one fixed. |
I'm bumping into this. Is there a better workaround than using edit: Using |
Sorry for dropping the ball on this. Fix is here: #3959 |
How Do We Reproduce?
REPL link.
Expected Behavior
The second export overrides
existsSync
of the first export.Actual Behavior
A
TypeError
is thrown when the Rollup output is executed in Node:The text was updated successfully, but these errors were encountered: