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
Aliased symbol also exported under non-aliased name. #438
Comments
Here’s an even simpler case for src/axis.js: export var orientBottom = 42;
export default function() {
var orient;
orient = orientBottom;
}; Which produces: define(['exports'], function (exports) { 'use strict';
exports.orientBottom = 42;
function axis() {
var orient;
orient = exports.orientBottom;
};
exports.axis = axis;
exports.axisOrientBottom = exports.orientBottom;
}); |
I can work around this issue by creating a var instead of an alias in index.js: import {orientBottom} from "./src/axis";
export {default as axis} from "./src/axis";
export var axisOrientBottom = orientBottom; I assume this has something to do with exports being bindings rather than constants. Like, it’s protecting against someone importing axisOrientBottom and the setting the value to something else, yeah? |
Another interesting observation is that it produces broken code if the exported symbol is a function. In src/axis.js: export function orientBottom() {};
export default function() {
var orient;
orient = orientBottom;
}; Which produces: define(['exports'], function (exports) { 'use strict';
function exports.orientBottom() {};
function axis() {
var orient;
orient = exports.orientBottom;
};
exports.axis = axis;
exports.axisOrientBottom = exports.orientBottom;
}); Which then fails because “exports.orientBottom” isn’t a valid function name. |
Although as I understand it (per 2ality), the imported ES6 binding should be immutable: no one should be able to reassign the That can’t be strictly enforced by Rollup when converting to ES5 (unless you wanted to protect the |
Fix double export of aliased names
Fixed at last, in 0.25.1 (the first bug, not the |
index.js:
src/axis.js:
Resulting Rollup with
-f amd
:Note that the bottom orientation is unexpectedly exported twice: once as
orientBottom
(wrongly) and once asaxisOrientBottom
(correctly).The text was updated successfully, but these errors were encountered: