Replies: 3 comments
-
|
Apologies, I mis-read the output program for test case 7 I see now that both the variable I didn't realize that exported classes can be re-assigned, this was unexpected for me: export class C {}
C = function foo() {
console.log('baz');
}
C() |
Beta Was this translation helpful? Give feedback.
-
|
Test case 7 is export let count = 0;
export class C {} if (C) { count += 1; }I see why |
Beta Was this translation helpful? Give feedback.
-
|
@erights, it seems that exported classes can be re-assigned (which I didn't know) however you are right that in Test Case 7 there is no assignment and it would be safe to skip the live export IMO. This would be a case where we would need a live export I think ( export class C {};
C = function() {
console.log('baz')
}Then import it and the function assignment which overrides the class is used: import {C} from './C.mjs'
C() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just a general discussion to help me understand the rules for live exports. So far I think that the following are live exports:
Are there other cases where I should transform as a live export?
Regarding the exported function expression it appears that the
Object.defineProperty()and$h_live.fn($c_fn);are hoisted to the top; currently my transform is not doing this (input & output) - I assume it is required?. See the output of test case 6 for the output with hoisting.Also I am a bit confused by test case 7. Why is it calling
$h_live.C(C);when the exported variable iscountI would expect it to operate on the exported variable not the class definition. Any pointers much appreciated!Beta Was this translation helpful? Give feedback.
All reactions