import { foo, bar } as obj from 'module

Andrea Giammarchi andrea.giammarchi at gmail.com
Thu Dec 14 20:29:51 UTC 2017


I've just tried monkey patching all the scenarios I've described/mentioned
and it works right away.

// x.js
export let x = 1;
setTimeout(() => x = 2, 2000);

// module.js
import {x} from './x.js';
const obj = Object.defineProperty({}, 'x', {get() { return x; }});
export {x, obj};

// index.js
import {x, obj} from './module.js';
console.log(x, obj.x);
setTimeout(() => console.log(x, obj.x), 3000);

I see 1, 1 and then 2, 2 without using proxies or exotic objects.

`{a, b, c} as obj` should really just avoid `a`, `b`, `c` scope pollution
and create those accessors in the `obj` constant object reference.

Regards


On Thu, Dec 14, 2017 at 5:55 PM, Darien Valentine <valentinium at gmail.com>
wrote:

> @Andrea I think we are thinking along the same lines. I meant proxy with a
> lowercase p — what you described fits the bill.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171214/9b7a4d76/attachment-0001.html>


More information about the es-discuss mailing list