{"action":"created","comment":{"url":"https://api.github.com/repos/mochajs/mocha/pulls/comments/171438994","pull_request_review_id":100290201,"id":171438994,"diff_hunk":"@@ -234,6 +234,34 @@ Mocha.prototype.loadFiles = function (fn) {\n   fn && fn();\n };\n \n+/**\n+ * Load registered files via es6 dynamic imports.\n+ *\n+ * Note: `eval` is used in this function or else mocha will not\n+ * compile on older node versions.","path":"lib/mocha.js","position":8,"original_position":8,"commit_id":"a16f8d0cd1068a2c6ac733ed54d3d5f5cdd2633e","original_commit_id":"a16f8d0cd1068a2c6ac733ed54d3d5f5cdd2633e","user":{"login":"boneskull","id":924465,"avatar_url":"https://avatars3.githubusercontent.com/u/924465?v=4","gravatar_id":"","url":"https://api.github.com/users/boneskull","html_url":"https://github.com/boneskull","followers_url":"https://api.github.com/users/boneskull/followers","following_url":"https://api.github.com/users/boneskull/following{/other_user}","gists_url":"https://api.github.com/users/boneskull/gists{/gist_id}","starred_url":"https://api.github.com/users/boneskull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boneskull/subscriptions","organizations_url":"https://api.github.com/users/boneskull/orgs","repos_url":"https://api.github.com/users/boneskull/repos","events_url":"https://api.github.com/users/boneskull/events{/privacy}","received_events_url":"https://api.github.com/users/boneskull/received_events","type":"User","site_admin":false},"body":"I don't understand where this is supposed to work.","created_at":"2018-03-01T01:17:04Z","updated_at":"2018-03-01T01:19:17Z","html_url":"https://github.com/mochajs/mocha/pull/3253#discussion_r171438994","pull_request_url":"https://api.github.com/repos/mochajs/mocha/pulls/3253","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/comments/171438994"},"html":{"href":"https://github.com/mochajs/mocha/pull/3253#discussion_r171438994"},"pull_request":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3253"}}},"pull_request":{"url":"https://api.github.com/repos/mochajs/mocha/pulls/3253","id":171521886,"html_url":"https://github.com/mochajs/mocha/pull/3253","diff_url":"https://github.com/mochajs/mocha/pull/3253.diff","patch_url":"https://github.com/mochajs/mocha/pull/3253.patch","issue_url":"https://api.github.com/repos/mochajs/mocha/issues/3253","number":3253,"state":"open","locked":false,"title":"WIP: use dynamic import to load es module tests.","user":{"login":"harrysarson","id":16308754,"avatar_url":"https://avatars3.githubusercontent.com/u/16308754?v=4","gravatar_id":"","url":"https://api.github.com/users/harrysarson","html_url":"https://github.com/harrysarson","followers_url":"https://api.github.com/users/harrysarson/followers","following_url":"https://api.github.com/users/harrysarson/following{/other_user}","gists_url":"https://api.github.com/users/harrysarson/gists{/gist_id}","starred_url":"https://api.github.com/users/harrysarson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrysarson/subscriptions","organizations_url":"https://api.github.com/users/harrysarson/orgs","repos_url":"https://api.github.com/users/harrysarson/repos","events_url":"https://api.github.com/users/harrysarson/events{/privacy}","received_events_url":"https://api.github.com/users/harrysarson/received_events","type":"User","site_admin":false},"body":"### Description of the Change\r\n\r\nUses the new (and as yet highly experimental) support in node for dynamically loading modules using `const obj = await import('./file-name.mjs');`.\r\n\r\nI have added a new command line flag `--es-modules` which causes mocha to use `import()` instead of `require()` to load test files.\r\n\r\nThis allows tests to `import obj from './somefile.mjs'` without having to transpile tests before running them.\r\n\r\nObviously this only works in the very latest node version. This commit does not break mocha in `node <= 8` unless the user passes the `es-modules` flag.\r\n\r\nCurrently running a script in node with `--experimental-modules` fails if the file does not have an extension which means that `node --experimental-modules bin/_mocha` files. From my understanding (see https://github.com/nodejs/node/pull/18728) node v9.7 will be able to run scripts without the .js extension.\r\n\r\n### Alternate Designs\r\n\r\nCurrent design works fine as long as users are happy to use a transpiler.\r\n\r\n### Why should this be in core?\r\n\r\nCannot be implemented outside of core.\r\n\r\n### Benefits\r\n\r\nTests can be written as es modules.\r\n\r\n### Possible Drawbacks\r\n\r\nCurrent support for modules in node is experimental. It is likely that mocha will want to wait untill node starts properly supporting modules before merging this pr.\r\n\r\n### Applicable issues\r\n\r\n#3006 \r\n\r\nProbably semver minor but could be major.","created_at":"2018-02-26T23:28:05Z","updated_at":"2018-03-01T01:19:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f92d6d19e820dbe9f3a621997c9b98884eef517b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":185748,"url":"https://api.github.com/repos/mochajs/mocha/labels/feature","name":"feature","color":"CC9264","default":false},{"id":533082025,"url":"https://api.github.com/repos/mochajs/mocha/labels/semver-minor","name":"semver-minor","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mochajs/mocha/pulls/3253/commits","review_comments_url":"https://api.github.com/repos/mochajs/mocha/pulls/3253/comments","review_comment_url":"https://api.github.com/repos/mochajs/mocha/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mochajs/mocha/issues/3253/comments","statuses_url":"https://api.github.com/repos/mochajs/mocha/statuses/a16f8d0cd1068a2c6ac733ed54d3d5f5cdd2633e","head":{"label":"harrysarson:es-modules","ref":"es-modules","sha":"a16f8d0cd1068a2c6ac733ed54d3d5f5cdd2633e","user":{"login":"harrysarson","id":16308754,"avatar_url":"https://avatars3.githubusercontent.com/u/16308754?v=4","gravatar_id":"","url":"https://api.github.com/users/harrysarson","html_url":"https://github.com/harrysarson","followers_url":"https://api.github.com/users/harrysarson/followers","following_url":"https://api.github.com/users/harrysarson/following{/other_user}","gists_url":"https://api.github.com/users/harrysarson/gists{/gist_id}","starred_url":"https://api.github.com/users/harrysarson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrysarson/subscriptions","organizations_url":"https://api.github.com/users/harrysarson/orgs","repos_url":"https://api.github.com/users/harrysarson/repos","events_url":"https://api.github.com/users/harrysarson/events{/privacy}","received_events_url":"https://api.github.com/users/harrysarson/received_events","type":"User","site_admin":false},"repo":{"id":117335705,"name":"mocha","full_name":"harrysarson/mocha","owner":{"login":"harrysarson","id":16308754,"avatar_url":"https://avatars3.githubusercontent.com/u/16308754?v=4","gravatar_id":"","url":"https://api.github.com/users/harrysarson","html_url":"https://github.com/harrysarson","followers_url":"https://api.github.com/users/harrysarson/followers","following_url":"https://api.github.com/users/harrysarson/following{/other_user}","gists_url":"https://api.github.com/users/harrysarson/gists{/gist_id}","starred_url":"https://api.github.com/users/harrysarson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrysarson/subscriptions","organizations_url":"https://api.github.com/users/harrysarson/orgs","repos_url":"https://api.github.com/users/harrysarson/repos","events_url":"https://api.github.com/users/harrysarson/events{/privacy}","received_events_url":"https://api.github.com/users/harrysarson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/harrysarson/mocha","description":"☕️ simple, flexible, fun javascript test framework for node.js & the browser","fork":true,"url":"https://api.github.com/repos/harrysarson/mocha","forks_url":"https://api.github.com/repos/harrysarson/mocha/forks","keys_url":"https://api.github.com/repos/harrysarson/mocha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/harrysarson/mocha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/harrysarson/mocha/teams","hooks_url":"https://api.github.com/repos/harrysarson/mocha/hooks","issue_events_url":"https://api.github.com/repos/harrysarson/mocha/issues/events{/number}","events_url":"https://api.github.com/repos/harrysarson/mocha/events","assignees_url":"https://api.github.com/repos/harrysarson/mocha/assignees{/user}","branches_url":"https://api.github.com/repos/harrysarson/mocha/branches{/branch}","tags_url":"https://api.github.com/repos/harrysarson/mocha/tags","blobs_url":"https://api.github.com/repos/harrysarson/mocha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/harrysarson/mocha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/harrysarson/mocha/git/refs{/sha}","trees_url":"https://api.github.com/repos/harrysarson/mocha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/harrysarson/mocha/statuses/{sha}","languages_url":"https://api.github.com/repos/harrysarson/mocha/languages","stargazers_url":"https://api.github.com/repos/harrysarson/mocha/stargazers","contributors_url":"https://api.github.com/repos/harrysarson/mocha/contributors","subscribers_url":"https://api.github.com/repos/harrysarson/mocha/subscribers","subscription_url":"https://api.github.com/repos/harrysarson/mocha/subscription","commits_url":"https://api.github.com/repos/harrysarson/mocha/commits{/sha}","git_commits_url":"https://api.github.com/repos/harrysarson/mocha/git/commits{/sha}","comments_url":"https://api.github.com/repos/harrysarson/mocha/comments{/number}","issue_comment_url":"https://api.github.com/repos/harrysarson/mocha/issues/comments{/number}","contents_url":"https://api.github.com/repos/harrysarson/mocha/contents/{+path}","compare_url":"https://api.github.com/repos/harrysarson/mocha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/harrysarson/mocha/merges","archive_url":"https://api.github.com/repos/harrysarson/mocha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/harrysarson/mocha/downloads","issues_url":"https://api.github.com/repos/harrysarson/mocha/issues{/number}","pulls_url":"https://api.github.com/repos/harrysarson/mocha/pulls{/number}","milestones_url":"https://api.github.com/repos/harrysarson/mocha/milestones{/number}","notifications_url":"https://api.github.com/repos/harrysarson/mocha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/harrysarson/mocha/labels{/name}","releases_url":"https://api.github.com/repos/harrysarson/mocha/releases{/id}","deployments_url":"https://api.github.com/repos/harrysarson/mocha/deployments","created_at":"2018-01-13T10:47:55Z","updated_at":"2018-01-13T10:47:59Z","pushed_at":"2018-02-27T09:54:33Z","git_url":"git://github.com/harrysarson/mocha.git","ssh_url":"git@github.com:harrysarson/mocha.git","clone_url":"https://github.com/harrysarson/mocha.git","svn_url":"https://github.com/harrysarson/mocha","homepage":"https://mochajs.org","size":8142,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mochajs:master","ref":"master","sha":"f71f3472d1049737ce0e2d2131753b468d45c66a","user":{"login":"mochajs","id":8770005,"avatar_url":"https://avatars2.githubusercontent.com/u/8770005?v=4","gravatar_id":"","url":"https://api.github.com/users/mochajs","html_url":"https://github.com/mochajs","followers_url":"https://api.github.com/users/mochajs/followers","following_url":"https://api.github.com/users/mochajs/following{/other_user}","gists_url":"https://api.github.com/users/mochajs/gists{/gist_id}","starred_url":"https://api.github.com/users/mochajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mochajs/subscriptions","organizations_url":"https://api.github.com/users/mochajs/orgs","repos_url":"https://api.github.com/users/mochajs/repos","events_url":"https://api.github.com/users/mochajs/events{/privacy}","received_events_url":"https://api.github.com/users/mochajs/received_events","type":"Organization","site_admin":false},"repo":{"id":1451352,"name":"mocha","full_name":"mochajs/mocha","owner":{"login":"mochajs","id":8770005,"avatar_url":"https://avatars2.githubusercontent.com/u/8770005?v=4","gravatar_id":"","url":"https://api.github.com/users/mochajs","html_url":"https://github.com/mochajs","followers_url":"https://api.github.com/users/mochajs/followers","following_url":"https://api.github.com/users/mochajs/following{/other_user}","gists_url":"https://api.github.com/users/mochajs/gists{/gist_id}","starred_url":"https://api.github.com/users/mochajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mochajs/subscriptions","organizations_url":"https://api.github.com/users/mochajs/orgs","repos_url":"https://api.github.com/users/mochajs/repos","events_url":"https://api.github.com/users/mochajs/events{/privacy}","received_events_url":"https://api.github.com/users/mochajs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mochajs/mocha","description":"☕️ simple, flexible, fun javascript test framework for node.js & the browser","fork":false,"url":"https://api.github.com/repos/mochajs/mocha","forks_url":"https://api.github.com/repos/mochajs/mocha/forks","keys_url":"https://api.github.com/repos/mochajs/mocha/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mochajs/mocha/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mochajs/mocha/teams","hooks_url":"https://api.github.com/repos/mochajs/mocha/hooks","issue_events_url":"https://api.github.com/repos/mochajs/mocha/issues/events{/number}","events_url":"https://api.github.com/repos/mochajs/mocha/events","assignees_url":"https://api.github.com/repos/mochajs/mocha/assignees{/user}","branches_url":"https://api.github.com/repos/mochajs/mocha/branches{/branch}","tags_url":"https://api.github.com/repos/mochajs/mocha/tags","blobs_url":"https://api.github.com/repos/mochajs/mocha/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mochajs/mocha/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mochajs/mocha/git/refs{/sha}","trees_url":"https://api.github.com/repos/mochajs/mocha/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mochajs/mocha/statuses/{sha}","languages_url":"https://api.github.com/repos/mochajs/mocha/languages","stargazers_url":"https://api.github.com/repos/mochajs/mocha/stargazers","contributors_url":"https://api.github.com/repos/mochajs/mocha/contributors","subscribers_url":"https://api.github.com/repos/mochajs/mocha/subscribers","subscription_url":"https://api.github.com/repos/mochajs/mocha/subscription","commits_url":"https://api.github.com/repos/mochajs/mocha/commits{/sha}","git_commits_url":"https://api.github.com/repos/mochajs/mocha/git/commits{/sha}","comments_url":"https://api.github.com/repos/mochajs/mocha/comments{/number}","issue_comment_url":"https://api.github.com/repos/mochajs/mocha/issues/comments{/number}","contents_url":"https://api.github.com/repos/mochajs/mocha/contents/{+path}","compare_url":"https://api.github.com/repos/mochajs/mocha/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mochajs/mocha/merges","archive_url":"https://api.github.com/repos/mochajs/mocha/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mochajs/mocha/downloads","issues_url":"https://api.github.com/repos/mochajs/mocha/issues{/number}","pulls_url":"https://api.github.com/repos/mochajs/mocha/pulls{/number}","milestones_url":"https://api.github.com/repos/mochajs/mocha/milestones{/number}","notifications_url":"https://api.github.com/repos/mochajs/mocha/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mochajs/mocha/labels{/name}","releases_url":"https://api.github.com/repos/mochajs/mocha/releases{/id}","deployments_url":"https://api.github.com/repos/mochajs/mocha/deployments","created_at":"2011-03-07T18:44:25Z","updated_at":"2018-03-01T00:37:57Z","pushed_at":"2018-02-28T18:12:56Z","git_url":"git://github.com/mochajs/mocha.git","ssh_url":"git@github.com:mochajs/mocha.git","clone_url":"https://github.com/mochajs/mocha.git","svn_url":"https://github.com/mochajs/mocha","homepage":"https://mochajs.org","size":8642,"stargazers_count":14760,"watchers_count":14760,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2064,"mirror_url":null,"archived":false,"open_issues_count":325,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2064,"open_issues":325,"watchers":14760,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3253"},"html":{"href":"https://github.com/mochajs/mocha/pull/3253"},"issue":{"href":"https://api.github.com/repos/mochajs/mocha/issues/3253"},"comments":{"href":"https://api.github.com/repos/mochajs/mocha/issues/3253/comments"},"review_comments":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3253/comments"},"review_comment":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mochajs/mocha/pulls/3253/commits"},"statuses":{"href":"https://api.github.com/repos/mochajs/mocha/statuses/a16f8d0cd1068a2c6ac733ed54d3d5f5cdd2633e"}},"author_association":"NONE"}}
{"actor":{"display_login":"boneskull"}}