{"action":"created","comment":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/82260402","pull_request_review_id":3180555,"id":82260402,"diff_hunk":"@@ -918,6 +960,19 @@ abstract class PrepJSInterop extends plugins.PluginComponent\n     }\n   }\n \n+  /** Checks that arguments to `@JSImport` on [[sym]] are literals.\n+   *  Reports an error on each annotation where this is not the case.\n+   */\n+  private def checkJSImportLiteral(sym: Symbol): Unit = {\n+    for {\n+      annot <- sym.getAnnotation(JSImportAnnotation)\n+      if (0 until annot.args.size).exists(i => annot.stringArg(i).isEmpty)\n+    } {\n+      reporter.error(annot.pos,","path":"compiler/src/main/scala/org/scalajs/core/compiler/PrepJSInterop.scala","position":null,"original_position":143,"commit_id":"113a6b06773ec99cd283c37abece8964a8d109f7","original_commit_id":"98be760f5eb1aac482c2cdd7dc028849eb2c6b0b","user":{"login":"gzm0","id":1140323,"avatar_url":"https://avatars.githubusercontent.com/u/1140323?v=3","gravatar_id":"","url":"https://api.github.com/users/gzm0","html_url":"https://github.com/gzm0","followers_url":"https://api.github.com/users/gzm0/followers","following_url":"https://api.github.com/users/gzm0/following{/other_user}","gists_url":"https://api.github.com/users/gzm0/gists{/gist_id}","starred_url":"https://api.github.com/users/gzm0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gzm0/subscriptions","organizations_url":"https://api.github.com/users/gzm0/orgs","repos_url":"https://api.github.com/users/gzm0/repos","events_url":"https://api.github.com/users/gzm0/events{/privacy}","received_events_url":"https://api.github.com/users/gzm0/received_events","type":"User","site_admin":false},"body":"Could you report the position of the offending argument?","created_at":"2016-10-06T19:02:06Z","updated_at":"2016-10-06T19:02:06Z","html_url":"https://github.com/scala-js/scala-js/pull/2572#discussion_r82260402","pull_request_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2572","_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments/82260402"},"html":{"href":"https://github.com/scala-js/scala-js/pull/2572#discussion_r82260402"},"pull_request":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2572"}}},"pull_request":{"url":"https://api.github.com/repos/scala-js/scala-js/pulls/2572","id":82992203,"html_url":"https://github.com/scala-js/scala-js/pull/2572","diff_url":"https://github.com/scala-js/scala-js/pull/2572.diff","patch_url":"https://github.com/scala-js/scala-js/pull/2572.patch","issue_url":"https://api.github.com/repos/scala-js/scala-js/issues/2572","number":2572,"state":"open","locked":false,"title":"Add `@JSImport` and the generation of CommonJS module.","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"body":"This is the first and biggest step towards #2175. It contains all the semantic changes to the language and the IR. The only thing that is left is to actually emit ES2015 modules rather than CommonJS modules in the emitter.\r\n\r\nThis commit contains two major changes, which are inherently linked:\r\n\r\n* An `@JSImport` annotation which can be used on top-level native JS classes and objects to signify that they should be imported from a JavaScript module.\r\n* A backend configuration `ModuleKind`, which instructs the emitter to generate a CommonJS module, rather than a script meant to be executed at the top-level of a JS engine.\r\n\r\nA codebase containing a reachable `@JSImport` cannot be successfully emitted to a top-level script, as there is no universal way of importing things.\r\n\r\nWe could imagine emitting Node.js modules without `@JSImport` support at first, but it would be a bit nonsensical to have modules that cannot import from other modules.\r\n\r\nWhen emitting a module, top-level `@JSExport`s become the module exports, obviously.\r\n\r\nSemantically, `@JSImport` and `@JSExport` are ES2015 module imports and exports. They are therefore static, which means that a) things cannot be conditionally imported or exported and b) their \"key\" must be a compile-time string constant.\r\n\r\nThe `ModuleKind` can be specified in sbt with the new key `scalaJSModuleKind`, which is scoped per project and per configuration, but not per stage. Indeed, they specify the interface with the outside JavaScript world, and that should not change in fastOpt versus fullOpt. Obviously, setting `scalaJSModuleKind` to `CommonJSModule` requires Node.js to be used for `run` and `test` tasks.\r\n\r\nThe historical fact that the `scalaJSLauncher` is stage-independent unfortunately makes `packageJSLauncher` incompatible with a `scalaJSModuleKind` different from `NoModule`. This is because, with modules, the contents of the launcher must reference the module ID, which is different in fastOpt and fullOpt.\r\n\r\nIn the future, we will extend `ModuleKind` with a new kind for actual ECMAScript 2015 modules.\r\n\r\n---\r\n\r\nMain things that could warrant discussion:\r\n\r\n* The semantics of `@JSImport`\r\n* The Tools API changes\r\n* The way to *run* and *test* a Scala.js application that uses Node.js modules from sbt\r\n\r\n# Semantics of `@JSImport`\r\n\r\nSee the Scaladoc of `@JSImport`. I'm personally happy with them as is, but we need to get this right, so it's good to have other people have a look at it.\r\n\r\n# The Tools API change\r\n\r\n`ModuleKind` comes along `Semantics` and `OutputMode` to be one of three mandatory \"options\" of the linker. It makes sense as a mandatory thing because it impacts the behavior of the Scala.js output. `LinkerFrontend.Config` and `LinkerBackend.Config` only contain superficial things, like source map emission, which don't have impact on the behavior.\r\n\r\n# sbt integration for running and testing\r\n\r\nI am not sure at all about the current design. Basically the idea is to alter the launcher script to `require` the produced module, which gives something like that for the hello world:\r\n```js\r\nrequire(\"/path/to/helloworld-fastopt.js\")[\"helloworld\"][\"HelloWorld\"]().main();\r\n```\r\nNote that we need the fully qualified path, and that it is specific to FastOpt. There needs to be a *different* launcher for fullOpt. The existing design of the sbt plugin does not accommodate well to this requirement. Hence, in the current implementation, `persistLauncher := true` is forbidden when `moduleKind != NoModule`. Moreover, Rhino does not support `moduleKind != NoModule` either, obviously.\r\n\r\nThe error reporting when misconfiguring those things in sbt might subpar ...","created_at":"2016-08-27T16:32:16Z","updated_at":"2016-10-06T19:53:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bdaa873f92626a45b5eefd0d63f9696cc92626ae","assignee":{"login":"gzm0","id":1140323,"avatar_url":"https://avatars.githubusercontent.com/u/1140323?v=3","gravatar_id":"","url":"https://api.github.com/users/gzm0","html_url":"https://github.com/gzm0","followers_url":"https://api.github.com/users/gzm0/followers","following_url":"https://api.github.com/users/gzm0/following{/other_user}","gists_url":"https://api.github.com/users/gzm0/gists{/gist_id}","starred_url":"https://api.github.com/users/gzm0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gzm0/subscriptions","organizations_url":"https://api.github.com/users/gzm0/orgs","repos_url":"https://api.github.com/users/gzm0/repos","events_url":"https://api.github.com/users/gzm0/events{/privacy}","received_events_url":"https://api.github.com/users/gzm0/received_events","type":"User","site_admin":false},"assignees":[{"login":"gzm0","id":1140323,"avatar_url":"https://avatars.githubusercontent.com/u/1140323?v=3","gravatar_id":"","url":"https://api.github.com/users/gzm0","html_url":"https://github.com/gzm0","followers_url":"https://api.github.com/users/gzm0/followers","following_url":"https://api.github.com/users/gzm0/following{/other_user}","gists_url":"https://api.github.com/users/gzm0/gists{/gist_id}","starred_url":"https://api.github.com/users/gzm0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gzm0/subscriptions","organizations_url":"https://api.github.com/users/gzm0/orgs","repos_url":"https://api.github.com/users/gzm0/repos","events_url":"https://api.github.com/users/gzm0/events{/privacy}","received_events_url":"https://api.github.com/users/gzm0/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2572/commits","review_comments_url":"https://api.github.com/repos/scala-js/scala-js/pulls/2572/comments","review_comment_url":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala-js/scala-js/issues/2572/comments","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/113a6b06773ec99cd283c37abece8964a8d109f7","head":{"label":"sjrd:modules","ref":"modules","sha":"113a6b06773ec99cd283c37abece8964a8d109f7","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"repo":{"id":8660284,"name":"scala-js","full_name":"sjrd/scala-js","owner":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?v=3","gravatar_id":"","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sjrd/scala-js","description":"Scala.js, a Scala to JavaScript compiler","fork":true,"url":"https://api.github.com/repos/sjrd/scala-js","forks_url":"https://api.github.com/repos/sjrd/scala-js/forks","keys_url":"https://api.github.com/repos/sjrd/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sjrd/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sjrd/scala-js/teams","hooks_url":"https://api.github.com/repos/sjrd/scala-js/hooks","issue_events_url":"https://api.github.com/repos/sjrd/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/sjrd/scala-js/events","assignees_url":"https://api.github.com/repos/sjrd/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/sjrd/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/sjrd/scala-js/tags","blobs_url":"https://api.github.com/repos/sjrd/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sjrd/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sjrd/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/sjrd/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sjrd/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/sjrd/scala-js/languages","stargazers_url":"https://api.github.com/repos/sjrd/scala-js/stargazers","contributors_url":"https://api.github.com/repos/sjrd/scala-js/contributors","subscribers_url":"https://api.github.com/repos/sjrd/scala-js/subscribers","subscription_url":"https://api.github.com/repos/sjrd/scala-js/subscription","commits_url":"https://api.github.com/repos/sjrd/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/sjrd/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/sjrd/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/sjrd/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/sjrd/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/sjrd/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sjrd/scala-js/merges","archive_url":"https://api.github.com/repos/sjrd/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sjrd/scala-js/downloads","issues_url":"https://api.github.com/repos/sjrd/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/sjrd/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/sjrd/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/sjrd/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sjrd/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/sjrd/scala-js/releases{/id}","deployments_url":"https://api.github.com/repos/sjrd/scala-js/deployments","created_at":"2013-03-08T21:32:59Z","updated_at":"2016-05-31T23:13:36Z","pushed_at":"2016-10-06T14:14:12Z","git_url":"git://github.com/sjrd/scala-js.git","ssh_url":"git@github.com:sjrd/scala-js.git","clone_url":"https://github.com/sjrd/scala-js.git","svn_url":"https://github.com/sjrd/scala-js","homepage":"http://www.scala-js.org/","size":13000,"stargazers_count":13,"watchers_count":13,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":13,"default_branch":"master"}},"base":{"label":"scala-js:master","ref":"master","sha":"89075e4052c6832aef7d5763bcb78d9bcc1bc169","user":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"repo":{"id":8272315,"name":"scala-js","full_name":"scala-js/scala-js","owner":{"login":"scala-js","id":6039724,"avatar_url":"https://avatars.githubusercontent.com/u/6039724?v=3","gravatar_id":"","url":"https://api.github.com/users/scala-js","html_url":"https://github.com/scala-js","followers_url":"https://api.github.com/users/scala-js/followers","following_url":"https://api.github.com/users/scala-js/following{/other_user}","gists_url":"https://api.github.com/users/scala-js/gists{/gist_id}","starred_url":"https://api.github.com/users/scala-js/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala-js/subscriptions","organizations_url":"https://api.github.com/users/scala-js/orgs","repos_url":"https://api.github.com/users/scala-js/repos","events_url":"https://api.github.com/users/scala-js/events{/privacy}","received_events_url":"https://api.github.com/users/scala-js/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala-js/scala-js","description":"Scala.js, the Scala to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/scala-js/scala-js","forks_url":"https://api.github.com/repos/scala-js/scala-js/forks","keys_url":"https://api.github.com/repos/scala-js/scala-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala-js/scala-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala-js/scala-js/teams","hooks_url":"https://api.github.com/repos/scala-js/scala-js/hooks","issue_events_url":"https://api.github.com/repos/scala-js/scala-js/issues/events{/number}","events_url":"https://api.github.com/repos/scala-js/scala-js/events","assignees_url":"https://api.github.com/repos/scala-js/scala-js/assignees{/user}","branches_url":"https://api.github.com/repos/scala-js/scala-js/branches{/branch}","tags_url":"https://api.github.com/repos/scala-js/scala-js/tags","blobs_url":"https://api.github.com/repos/scala-js/scala-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala-js/scala-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala-js/scala-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala-js/scala-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala-js/scala-js/statuses/{sha}","languages_url":"https://api.github.com/repos/scala-js/scala-js/languages","stargazers_url":"https://api.github.com/repos/scala-js/scala-js/stargazers","contributors_url":"https://api.github.com/repos/scala-js/scala-js/contributors","subscribers_url":"https://api.github.com/repos/scala-js/scala-js/subscribers","subscription_url":"https://api.github.com/repos/scala-js/scala-js/subscription","commits_url":"https://api.github.com/repos/scala-js/scala-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala-js/scala-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala-js/scala-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala-js/scala-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala-js/scala-js/contents/{+path}","compare_url":"https://api.github.com/repos/scala-js/scala-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala-js/scala-js/merges","archive_url":"https://api.github.com/repos/scala-js/scala-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala-js/scala-js/downloads","issues_url":"https://api.github.com/repos/scala-js/scala-js/issues{/number}","pulls_url":"https://api.github.com/repos/scala-js/scala-js/pulls{/number}","milestones_url":"https://api.github.com/repos/scala-js/scala-js/milestones{/number}","notifications_url":"https://api.github.com/repos/scala-js/scala-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala-js/scala-js/labels{/name}","releases_url":"https://api.github.com/repos/scala-js/scala-js/releases{/id}","deployments_url":"https://api.github.com/repos/scala-js/scala-js/deployments","created_at":"2013-02-18T16:33:55Z","updated_at":"2016-10-06T17:50:18Z","pushed_at":"2016-10-06T18:06:06Z","git_url":"git://github.com/scala-js/scala-js.git","ssh_url":"git@github.com:scala-js/scala-js.git","clone_url":"https://github.com/scala-js/scala-js.git","svn_url":"https://github.com/scala-js/scala-js","homepage":"https://www.scala-js.org/","size":15871,"stargazers_count":2591,"watchers_count":2591,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":234,"mirror_url":null,"open_issues_count":105,"forks":234,"open_issues":105,"watchers":2591,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2572"},"html":{"href":"https://github.com/scala-js/scala-js/pull/2572"},"issue":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/2572"},"comments":{"href":"https://api.github.com/repos/scala-js/scala-js/issues/2572/comments"},"review_comments":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2572/comments"},"review_comment":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala-js/scala-js/pulls/2572/commits"},"statuses":{"href":"https://api.github.com/repos/scala-js/scala-js/statuses/113a6b06773ec99cd283c37abece8964a8d109f7"}}}}
{"actor":{"display_login":"gzm0"}}