{"action":"created","issue":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/1266","repository_url":"https://api.github.com/repos/systemjs/systemjs","labels_url":"https://api.github.com/repos/systemjs/systemjs/issues/1266/labels{/name}","comments_url":"https://api.github.com/repos/systemjs/systemjs/issues/1266/comments","events_url":"https://api.github.com/repos/systemjs/systemjs/issues/1266/events","html_url":"https://github.com/systemjs/systemjs/issues/1266","id":154199478,"number":1266,"title":"module is not defined when transpiling Typescript using module: \"commonjs\"","user":{"login":"filipesilva","id":4172079,"avatar_url":"https://avatars.githubusercontent.com/u/4172079?v=3","gravatar_id":"","url":"https://api.github.com/users/filipesilva","html_url":"https://github.com/filipesilva","followers_url":"https://api.github.com/users/filipesilva/followers","following_url":"https://api.github.com/users/filipesilva/following{/other_user}","gists_url":"https://api.github.com/users/filipesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/filipesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipesilva/subscriptions","organizations_url":"https://api.github.com/users/filipesilva/orgs","repos_url":"https://api.github.com/users/filipesilva/repos","events_url":"https://api.github.com/users/filipesilva/events{/privacy}","received_events_url":"https://api.github.com/users/filipesilva/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-05-11T09:32:59Z","updated_at":"2016-05-14T00:44:54Z","closed_at":null,"body":"Heya,\r\n\r\nI've a simple Angular 2 [quickstart app](https://github.com/angular/quickstart) running locally, which I've modified `app.component.ts` to also have `moduleId: module.id`:\r\n\r\n```\r\nimport {Component} from '@angular/core';\r\n\r\n@Component({\r\n    moduleId: module.id,\r\n    selector: 'my-app',\r\n    template: '<h1>My First Angular 2 App</h1>'\r\n})\r\nexport class AppComponent { }\r\n```\r\n\r\nLocally I compile to typescript, serve and use SystemJS to load it and it runs fine.\r\n\r\nI also tried to do this in a plunker, using typescript compilation and setting `module: \"commonjs\"` on `typescriptOptions` but I seem to be getting `Error: ReferenceError: module is not defined`. The plunker can be found here: http://plnkr.co/edit/xZkh2B44LU0HA3GlOWaC?p=preview\r\n\r\nI've read https://github.com/systemjs/systemjs/issues/1030 and it seems that a `__moduleName` property exists for ES Modules, but since I'm compiling to CommonJS modules I thought `module` would be available.\r\n\r\nIs this scenario possible using SystemJS?"},"comment":{"url":"https://api.github.com/repos/systemjs/systemjs/issues/comments/219190041","html_url":"https://github.com/systemjs/systemjs/issues/1266#issuecomment-219190041","issue_url":"https://api.github.com/repos/systemjs/systemjs/issues/1266","id":219190041,"user":{"login":"frankwallis","id":4387473,"avatar_url":"https://avatars.githubusercontent.com/u/4387473?v=3","gravatar_id":"","url":"https://api.github.com/users/frankwallis","html_url":"https://github.com/frankwallis","followers_url":"https://api.github.com/users/frankwallis/followers","following_url":"https://api.github.com/users/frankwallis/following{/other_user}","gists_url":"https://api.github.com/users/frankwallis/gists{/gist_id}","starred_url":"https://api.github.com/users/frankwallis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankwallis/subscriptions","organizations_url":"https://api.github.com/users/frankwallis/orgs","repos_url":"https://api.github.com/users/frankwallis/repos","events_url":"https://api.github.com/users/frankwallis/events{/privacy}","received_events_url":"https://api.github.com/users/frankwallis/received_events","type":"User","site_admin":false},"created_at":"2016-05-14T00:44:54Z","updated_at":"2016-05-14T00:44:54Z","body":"The built in TypeScript transpiler always outputs in system format regardless of the ```module``` config option, see [here](https://github.com/systemjs/systemjs/blob/596b751b531d960acc73ff41678c4681d137ae75/dist/system.src.js#L1296). So SystemJS never sees the module in commonjs form so it does not apply the commonjs [wrapper](https://github.com/systemjs/systemjs/blob/596b751b531d960acc73ff41678c4681d137ae75/dist/system.src.js#L3910).\r\n\r\nIn the plugin-typescript example I don't think that plugin-typescript is actually being called, and it works for me in a different test, so I need to debug the plnkr a bit further.\r\n"}}