{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/loader/issues/129","repository_url":"https://api.github.com/repos/whatwg/loader","labels_url":"https://api.github.com/repos/whatwg/loader/issues/129/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/loader/issues/129/comments","events_url":"https://api.github.com/repos/whatwg/loader/issues/129/events","html_url":"https://github.com/whatwg/loader/pull/129","id":135167938,"number":129,"title":"Export Objects","user":{"login":"caridy","id":38969,"avatar_url":"https://avatars.githubusercontent.com/u/38969?v=3","gravatar_id":"","url":"https://api.github.com/users/caridy","html_url":"https://github.com/caridy","followers_url":"https://api.github.com/users/caridy/followers","following_url":"https://api.github.com/users/caridy/following{/other_user}","gists_url":"https://api.github.com/users/caridy/gists{/gist_id}","starred_url":"https://api.github.com/users/caridy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caridy/subscriptions","organizations_url":"https://api.github.com/users/caridy/orgs","repos_url":"https://api.github.com/users/caridy/repos","events_url":"https://api.github.com/users/caridy/events{/privacy}","received_events_url":"https://api.github.com/users/caridy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/whatwg/loader/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":{"login":"caridy","id":38969,"avatar_url":"https://avatars.githubusercontent.com/u/38969?v=3","gravatar_id":"","url":"https://api.github.com/users/caridy","html_url":"https://github.com/caridy","followers_url":"https://api.github.com/users/caridy/followers","following_url":"https://api.github.com/users/caridy/following{/other_user}","gists_url":"https://api.github.com/users/caridy/gists{/gist_id}","starred_url":"https://api.github.com/users/caridy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caridy/subscriptions","organizations_url":"https://api.github.com/users/caridy/orgs","repos_url":"https://api.github.com/users/caridy/repos","events_url":"https://api.github.com/users/caridy/events{/privacy}","received_events_url":"https://api.github.com/users/caridy/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-02-21T06:23:57Z","updated_at":"2016-05-03T16:52:13Z","closed_at":"2016-05-03T16:52:12Z","pull_request":{"url":"https://api.github.com/repos/whatwg/loader/pulls/129","html_url":"https://github.com/whatwg/loader/pull/129","diff_url":"https://github.com/whatwg/loader/pull/129.diff","patch_url":"https://github.com/whatwg/loader/pull/129.patch"},"body":"Tagline: Formalizing a reflective API to create export bindings for Reflective Module Records.\r\n\r\n## Details\r\n\r\n* Removing the confusing `mutator` in favor of re-usable Export Objects\r\n* `Reflect.Module.Export.let()`\r\n* `Reflect.Module.Export.var()`\r\n* `Reflect.Module.Export.const()`\r\n* `Reflect.Module.Export.from()`\r\n\r\n## Usage\r\n\r\n```javascript\r\nimport * as fs from \"fs\";\r\n\r\nvar Export = Reflect.Module.Export;\r\n\r\nvar y, TAU;\r\n\r\n// reflective API takes Export objects to represent each export slot\r\nvar mod = new Reflect.Module({\r\n  // initialized mutable (includes \"uninitialized\" var)\r\n  x: Export.var(),\r\n  y: (y = Export.var(42)),\r\n\r\n  // uninitialized mutable (let, class)\r\n  z: Export.let(),\r\n\r\n  // initialized immutable (const)\r\n  PI: Export.const(Math.PI),\r\n\r\n  // uninitialized immutable (const)\r\n  TAU: (TAU = Export.const()),\r\n\r\n  // indirect binding from arbitrary object\r\n  bar: Export.from(delegate, \"bar\"), // optimizable special case; helps interop with existing module systems\r\n\r\n  // re-export (heavily optimizable since `fs` is known to be a module namespace object)\r\n  readFile: Export.from(fs, \"readFile\")\r\n});\r\n\r\nconsole.log(mod.y); // 42\r\ny.set(43);          // mutates the y slot\r\nconsole.log(mod.y); // 43\r\nTAU.get();          // throws TDZ error\r\n```\r\n\r\n## Re-exporing all from Module\r\n\r\n```javascript\r\nfunction exportAllFrom(ns) {\r\n  let o = Object.create(null);\r\n  Object.keys(ns).forEach(key => {\r\n    o[key] = Reflect.Module.Export.from(ns, key);\r\n  });\r\n  return Reflect.Module(o);\r\n} // this return a new namespace object for the new reflective module that was created from the namespace argument.\r\n```\r\n\r\n## Node Compat-Mode\r\n\r\n```javascript\r\nfunction exportAllFromCJS(cjs) {\r\n  let o = Object.create(null);\r\n  Object.keys(cjs).forEach(key => {\r\n    o[key] = Reflect.Module.Export.let(cjs[key]);\r\n  });\r\n  return Reflect.Module(o);\r\n} // this return a new namespace object for the new reflective module that was created from the cjs module argument.\r\n```\r\n\r\n## Rendered HTML\r\n\r\nhttps://rawgit.com/caridy/6430042924e0436918ea/raw/0f9e2224f1c29ac4449000f5350fdcb2ae439157/loader-pr129.html"},"comment":{"url":"https://api.github.com/repos/whatwg/loader/issues/comments/216593312","html_url":"https://github.com/whatwg/loader/pull/129#issuecomment-216593312","issue_url":"https://api.github.com/repos/whatwg/loader/issues/129","id":216593312,"user":{"login":"caridy","id":38969,"avatar_url":"https://avatars.githubusercontent.com/u/38969?v=3","gravatar_id":"","url":"https://api.github.com/users/caridy","html_url":"https://github.com/caridy","followers_url":"https://api.github.com/users/caridy/followers","following_url":"https://api.github.com/users/caridy/following{/other_user}","gists_url":"https://api.github.com/users/caridy/gists{/gist_id}","starred_url":"https://api.github.com/users/caridy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caridy/subscriptions","organizations_url":"https://api.github.com/users/caridy/orgs","repos_url":"https://api.github.com/users/caridy/repos","events_url":"https://api.github.com/users/caridy/events{/privacy}","received_events_url":"https://api.github.com/users/caridy/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T16:52:12Z","updated_at":"2016-05-03T16:52:12Z","body":"We have decided to maintain the old API (export descriptors). Few thoughts:\r\n\r\n* it reflects better the construction of a source text module record\r\n* the extra machinery for the special \"export module record\" is a no-go\r\n* `Export` api has probably better ergonomics, but this is not intended for citizen developers, but low level (libraries and fw) code.\r\n* `Export` doesn't give us the edge we thought in terms of functionalities, everything could be replicated with the export descriptors in the same way you would get it done using declarative syntax.\r\n\r\n_note: there are few editorial things from this PR that we will cherry-pick_"}}