Question: can that change tho?

Asked By
Asked At
2017-08-02 21:35:25

Found 15 possible answers.

User Answered At Possible Answer
benjamn 2017-08-02 21:35:32 so I’m surprised it doesn’t retrieve the exports/namespace object and rewrite it to _exports.default elsewhere export default can’t change, but any other kind of export default ... declaration can
ljharb 2017-08-02 21:36:02 let x = 3; export default x; setTimeout(() => { x = 4 }) so this works? i knew it worked on named exports, but i didn’t think it did on defaults
benjamn 2017-08-02 21:36:43 yeah, that’s the expression form ( x is only evaluated once)
will export `anotherFunction`
foo = function anotherFunction() {}
export default function foo () {}
loganfsmyth 2017-08-02 21:37:44 no but you can do export {x as default};
benjamn 2017-08-02 21:37:56 it’s like export { foo as default } followed by a reassignment of foo right
hzoo 2017-08-02 21:38:33 @hzoo uploaded a file: Screen Shot 2017-08-02 at 5.38.16 PM.png
benjamn 2017-08-02 21:38:35 export default is the weird one
hzoo 2017-08-02 21:38:37 so is that not a possible change thing?
loganfsmyth 2017-08-02 21:39:04 no it needs to be an object reference
benjamn 2017-08-02 21:39:16 you can’t tell on the importing side whether the value is live-bound
loganfsmyth 2017-08-02 21:39:23 we could certainly make an liveImports: false flag if people wanted simpler readability
hzoo 2017-08-02 21:39:24 ok good to know..
benjamn 2017-08-02 21:40:36 Here’s what Reify does these days:
let bar;
}); default(v) { bar = v }"bar"), {
ljharb 2017-08-02 21:41:14 hm, is that really intentional tho in the spec? like, that defaults are a live binding only on function and class declarations?
benjamn 2017-08-02 21:41:42 it’s just a question of whether the default export can actually change

Related Questions