{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node-eps/pulls/comments/50400635","id":50400635,"diff_hunk":"@@ -0,0 +1,274 @@\n+# ES6 Modules\n+\n+Status | Draft\n+------ | ----\n+Author | Bradley Meck\n+Date   | 7 Jan 2016\n+\n+It is our intent to:\n+\n+* implement interoperability for ES6 modules and node's existing module system\n+* create a **Registry Object** (see WhatWG section below) compatible with the WhatWG Loader Registry\n+\n+## Purpose\n+\n+1. Allow a common module syntax for Browser and Server.\n+2. Allow a common registry for inspection by Browser and Server environments/tools.\n+    * these will most likely be represented by metaproperties like `import.context` but spec is not in place fully yet.\n+\n+## Related\n+\n+---\n+\n+### [ECMA262](https://tc39.github.io/ecma262/#sec-source-text-module-records)\n+\n+---\n+\n+Discusses the syntax and semantics of related syntax, and introduces:\n+    \n+#### Types\n+    \n+* [ModuleRecord](https://tc39.github.io/ecma262/#sec-abstract-module-records)\n+    - Defines the list of imports via [ImportEntry](https://tc39.github.io/ecma262/#table-39).\n+    - Defines the list of exports via [ExportEntry](https://tc39.github.io/ecma262/#table-41).\n+    \n+* [ModuleNamespace](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects)\n+    - Represents a read-only snapshot of a module's exports.\n+    \n+### Operations\n+    \n+* [ParseModule](https://tc39.github.io/ecma262/#sec-parsemodule)\n+    - Creates a SourceTextModuleRecord from source code.\n+    \n+* [HostResolveImportedModule](https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule)\n+    - A hook for when an import is exactly performed.\n+    \n+* [CreateImportBinding](https://tc39.github.io/ecma262/#sec-createimportbinding)\n+    - A means to create a shared binding (variable) from an export to an import. Required for the \"live\" binding of imports.\n+\n+* [ModuleNamespaceCreate](https://tc39.github.io/ecma262/#sec-modulenamespacecreate)\n+    - Provides a means of creating a list of exports manually, used so that CommonJS `module.exports` can create ModuleRecords that are prepopulated.\n+\n+---\n+\n+### [WhatWG Loader](https://github.com/whatwg/loader)\n+\n+---\n+\n+Discusses the design of module metadata in a [Registry](https://whatwg.github.io/loader/#registry). All actions regarding the Registry are synchronous.\n+\n+**NOTE** It is not Node's intent to implement the asynchronous pipeline in the Loader specification. There is discussion about including a synchronous pipeline in the specification as an addendum.\n+\n+\n+### [Summary Video on Youtube](youtube.com/watch?v=NdOKO-6Ty7k)\n+\n+## Additional Structures Required\n+\n+### DynamicModuleRecord\n+\n+A Module Record that presents a view of an Object for its `[[Namespace]]` rather than coming from an environment record.\n+\n+The list of exports is frozen upon construction. No new properties may be added. No properties may be removed.\n+\n+## Algorithm\n+\n+When `require()`ing a file.\n+\n+1. Determine if file is ES6 or CommonJS (CJS).\n+2. If CJS\n+\t1. Evaluate immediately\n+\t2. Produce a DynamicModuleRecord from `module.exports`\n+3. If ES6\n+\t1. Parse for `import`/`export`s and keep record, in order to create bindings\n+\t2. Gather all submodules by performing `require` recursively\n+\t\t* See circular dep semantics below \n+\t3. Connect `import` bindings for all relevant submodules (see [ModuleDeclarationInstantiation](https://tc39.github.io/ecma262/#sec-moduledeclarationinstantiation))\n+\t4. Evaluate\n+\n+## Semantics\n+\n+### Determining if source is an ES6 Module\n+\n+If a module can be parsed outside of the ES6 Module goal, it will be treated as a [Script](https://tc39.github.io/ecma262/#sec-parse-script). Otherwise it will be parsed as [ES6](https://tc39.github.io/ecma262/#sec-parsemodule).\n+\n+In pseudocode, it looks somewhat like:\n+\n+```\n+try {\n+  v8::Script::Compile\n+}\n+catch (e) {\n+  v8::Script::CompileModule\n+}\n+```\n+\n+V8 may or may not choose to use parser fallback to combine this into one step.\n+\n+### CommonJS consuming ES6\n+\n+#### default exports\n+\n+ES6 modules only ever declare named exports. A default export just exports a property named `default`.\n+\n+Given\n+\n+```javascript\n+let foo = 'my-default';\n+export default foo;\n+```\n+\n+```javascript\n+require('./es6');","path":"002-es6-modules.md","position":121,"original_position":121,"commit_id":"7a00ec0bd3a34aab0d6385e22743b582a57592da","original_commit_id":"da7b2bc166a5de3d9ee4ecd5328383f71760eb38","user":{"login":"bmeck","id":234659,"avatar_url":"https://avatars.githubusercontent.com/u/234659?v=3","gravatar_id":"","url":"https://api.github.com/users/bmeck","html_url":"https://github.com/bmeck","followers_url":"https://api.github.com/users/bmeck/followers","following_url":"https://api.github.com/users/bmeck/following{/other_user}","gists_url":"https://api.github.com/users/bmeck/gists{/gist_id}","starred_url":"https://api.github.com/users/bmeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmeck/subscriptions","organizations_url":"https://api.github.com/users/bmeck/orgs","repos_url":"https://api.github.com/users/bmeck/repos","events_url":"https://api.github.com/users/bmeck/events{/privacy}","received_events_url":"https://api.github.com/users/bmeck/received_events","type":"User","site_admin":false},"body":"@medikoo can you expand:\r\n\r\n> solve with Babel problems that this change may introduce","created_at":"2016-01-21T13:37:00Z","updated_at":"2016-01-21T13:37:00Z","html_url":"https://github.com/nodejs/node-eps/pull/3#discussion_r50400635","pull_request_url":"https://api.github.com/repos/nodejs/node-eps/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/comments/50400635"},"html":{"href":"https://github.com/nodejs/node-eps/pull/3#discussion_r50400635"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node-eps/pulls/3","id":55413977,"html_url":"https://github.com/nodejs/node-eps/pull/3","diff_url":"https://github.com/nodejs/node-eps/pull/3.diff","patch_url":"https://github.com/nodejs/node-eps/pull/3.patch","issue_url":"https://api.github.com/repos/nodejs/node-eps/issues/3","number":3,"state":"open","locked":false,"title":"002: ES6 module interop","user":{"login":"bmeck","id":234659,"avatar_url":"https://avatars.githubusercontent.com/u/234659?v=3","gravatar_id":"","url":"https://api.github.com/users/bmeck","html_url":"https://github.com/bmeck","followers_url":"https://api.github.com/users/bmeck/followers","following_url":"https://api.github.com/users/bmeck/following{/other_user}","gists_url":"https://api.github.com/users/bmeck/gists{/gist_id}","starred_url":"https://api.github.com/users/bmeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmeck/subscriptions","organizations_url":"https://api.github.com/users/bmeck/orgs","repos_url":"https://api.github.com/users/bmeck/repos","events_url":"https://api.github.com/users/bmeck/events{/privacy}","received_events_url":"https://api.github.com/users/bmeck/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-08T01:18:07Z","updated_at":"2016-01-21T13:37:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"08276f5fd681c374347f43f8b04d3a6a45769400","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node-eps/pulls/3/commits","review_comments_url":"https://api.github.com/repos/nodejs/node-eps/pulls/3/comments","review_comment_url":"https://api.github.com/repos/nodejs/node-eps/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node-eps/issues/3/comments","statuses_url":"https://api.github.com/repos/nodejs/node-eps/statuses/7a00ec0bd3a34aab0d6385e22743b582a57592da","head":{"label":"bmeck:es6-module","ref":"es6-module","sha":"7a00ec0bd3a34aab0d6385e22743b582a57592da","user":{"login":"bmeck","id":234659,"avatar_url":"https://avatars.githubusercontent.com/u/234659?v=3","gravatar_id":"","url":"https://api.github.com/users/bmeck","html_url":"https://github.com/bmeck","followers_url":"https://api.github.com/users/bmeck/followers","following_url":"https://api.github.com/users/bmeck/following{/other_user}","gists_url":"https://api.github.com/users/bmeck/gists{/gist_id}","starred_url":"https://api.github.com/users/bmeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmeck/subscriptions","organizations_url":"https://api.github.com/users/bmeck/orgs","repos_url":"https://api.github.com/users/bmeck/repos","events_url":"https://api.github.com/users/bmeck/events{/privacy}","received_events_url":"https://api.github.com/users/bmeck/received_events","type":"User","site_admin":false},"repo":{"id":49231705,"name":"node-eps","full_name":"bmeck/node-eps","owner":{"login":"bmeck","id":234659,"avatar_url":"https://avatars.githubusercontent.com/u/234659?v=3","gravatar_id":"","url":"https://api.github.com/users/bmeck","html_url":"https://github.com/bmeck","followers_url":"https://api.github.com/users/bmeck/followers","following_url":"https://api.github.com/users/bmeck/following{/other_user}","gists_url":"https://api.github.com/users/bmeck/gists{/gist_id}","starred_url":"https://api.github.com/users/bmeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmeck/subscriptions","organizations_url":"https://api.github.com/users/bmeck/orgs","repos_url":"https://api.github.com/users/bmeck/repos","events_url":"https://api.github.com/users/bmeck/events{/privacy}","received_events_url":"https://api.github.com/users/bmeck/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bmeck/node-eps","description":"Node.js Enhancement Proposals for discussion on future API additions/changes to Node core","fork":true,"url":"https://api.github.com/repos/bmeck/node-eps","forks_url":"https://api.github.com/repos/bmeck/node-eps/forks","keys_url":"https://api.github.com/repos/bmeck/node-eps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bmeck/node-eps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bmeck/node-eps/teams","hooks_url":"https://api.github.com/repos/bmeck/node-eps/hooks","issue_events_url":"https://api.github.com/repos/bmeck/node-eps/issues/events{/number}","events_url":"https://api.github.com/repos/bmeck/node-eps/events","assignees_url":"https://api.github.com/repos/bmeck/node-eps/assignees{/user}","branches_url":"https://api.github.com/repos/bmeck/node-eps/branches{/branch}","tags_url":"https://api.github.com/repos/bmeck/node-eps/tags","blobs_url":"https://api.github.com/repos/bmeck/node-eps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bmeck/node-eps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bmeck/node-eps/git/refs{/sha}","trees_url":"https://api.github.com/repos/bmeck/node-eps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bmeck/node-eps/statuses/{sha}","languages_url":"https://api.github.com/repos/bmeck/node-eps/languages","stargazers_url":"https://api.github.com/repos/bmeck/node-eps/stargazers","contributors_url":"https://api.github.com/repos/bmeck/node-eps/contributors","subscribers_url":"https://api.github.com/repos/bmeck/node-eps/subscribers","subscription_url":"https://api.github.com/repos/bmeck/node-eps/subscription","commits_url":"https://api.github.com/repos/bmeck/node-eps/commits{/sha}","git_commits_url":"https://api.github.com/repos/bmeck/node-eps/git/commits{/sha}","comments_url":"https://api.github.com/repos/bmeck/node-eps/comments{/number}","issue_comment_url":"https://api.github.com/repos/bmeck/node-eps/issues/comments{/number}","contents_url":"https://api.github.com/repos/bmeck/node-eps/contents/{+path}","compare_url":"https://api.github.com/repos/bmeck/node-eps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bmeck/node-eps/merges","archive_url":"https://api.github.com/repos/bmeck/node-eps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bmeck/node-eps/downloads","issues_url":"https://api.github.com/repos/bmeck/node-eps/issues{/number}","pulls_url":"https://api.github.com/repos/bmeck/node-eps/pulls{/number}","milestones_url":"https://api.github.com/repos/bmeck/node-eps/milestones{/number}","notifications_url":"https://api.github.com/repos/bmeck/node-eps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bmeck/node-eps/labels{/name}","releases_url":"https://api.github.com/repos/bmeck/node-eps/releases{/id}","created_at":"2016-01-07T21:26:09Z","updated_at":"2015-12-18T15:42:19Z","pushed_at":"2016-01-20T01:51:08Z","git_url":"git://github.com/bmeck/node-eps.git","ssh_url":"git@github.com:bmeck/node-eps.git","clone_url":"https://github.com/bmeck/node-eps.git","svn_url":"https://github.com/bmeck/node-eps","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nodejs:master","ref":"master","sha":"d8eb50e0a4c9a16289736c5db2a36d941c9a86a9","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":48204104,"name":"node-eps","full_name":"nodejs/node-eps","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node-eps","description":"Node.js Enhancement Proposals for discussion on future API additions/changes to Node core","fork":false,"url":"https://api.github.com/repos/nodejs/node-eps","forks_url":"https://api.github.com/repos/nodejs/node-eps/forks","keys_url":"https://api.github.com/repos/nodejs/node-eps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node-eps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node-eps/teams","hooks_url":"https://api.github.com/repos/nodejs/node-eps/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node-eps/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node-eps/events","assignees_url":"https://api.github.com/repos/nodejs/node-eps/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node-eps/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node-eps/tags","blobs_url":"https://api.github.com/repos/nodejs/node-eps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node-eps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node-eps/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node-eps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node-eps/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node-eps/languages","stargazers_url":"https://api.github.com/repos/nodejs/node-eps/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node-eps/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node-eps/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node-eps/subscription","commits_url":"https://api.github.com/repos/nodejs/node-eps/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node-eps/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node-eps/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node-eps/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node-eps/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node-eps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node-eps/merges","archive_url":"https://api.github.com/repos/nodejs/node-eps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node-eps/downloads","issues_url":"https://api.github.com/repos/nodejs/node-eps/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node-eps/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node-eps/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node-eps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node-eps/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node-eps/releases{/id}","created_at":"2015-12-17T23:39:07Z","updated_at":"2016-01-20T19:19:59Z","pushed_at":"2016-01-20T01:51:08Z","git_url":"git://github.com/nodejs/node-eps.git","ssh_url":"git@github.com:nodejs/node-eps.git","clone_url":"https://github.com/nodejs/node-eps.git","svn_url":"https://github.com/nodejs/node-eps","homepage":null,"size":1,"stargazers_count":12,"watchers_count":12,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/3"},"html":{"href":"https://github.com/nodejs/node-eps/pull/3"},"issue":{"href":"https://api.github.com/repos/nodejs/node-eps/issues/3"},"comments":{"href":"https://api.github.com/repos/nodejs/node-eps/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node-eps/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node-eps/statuses/7a00ec0bd3a34aab0d6385e22743b582a57592da"}}}}