babel: "export { named } from" breaks IE8 (T7322)
Issue originally made by @timdorr
Bug information
- Babel version: 6.7.7
- Node version: 5.5.0
- npm version: 3.8.7
Options
{
"presets": ["es2015-loose", "stage-1", "react"],
"plugins": [
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}
Input code
export { foo, bar } from './baz'
Description
Apologies if this has been discussed before. T2322 is tangentially related and fixed by add-module-exports
.
When using the above input code, you get something like this as output:
var _baz = require('./baz');
Object.defineProperty(exports, 'foo', {
enumerable: true,
get: function get() {
return _baz.foo;
}
});
Object.defineProperty(exports, 'bar', {
enumerable: true,
get: function get() {
return _baz.bar;
}
});
While core-js/babel-polyfill can add in defineProperty support, it cannot do getters. I’m not sure why defineProperty is used, so pardon my ignorance if I’m missing something super-obvious. But can’t a simple property assignment be used instead? It’s enumerable anyways, so I’m not sure of the practical difference.
It appears the code template remains untouched since the original 6.0.0 release, so perhaps it needs to be touched up a bit? I’m happy to submit a PR.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (6 by maintainers)
It’s not really possible to implement reexporting without using getters… unless you just assume that the original export will never ever change, which breaks things, in particular circular references 😕