{"action":"created","issue":{"url":"https://api.github.com/repos/monounity/karma-typescript/issues/186","repository_url":"https://api.github.com/repos/monounity/karma-typescript","labels_url":"https://api.github.com/repos/monounity/karma-typescript/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/monounity/karma-typescript/issues/186/comments","events_url":"https://api.github.com/repos/monounity/karma-typescript/issues/186/events","html_url":"https://github.com/monounity/karma-typescript/issues/186","id":260484930,"number":186,"title":"apply transform API on node_modules too","user":{"login":"nros","id":508093,"avatar_url":"https://avatars2.githubusercontent.com/u/508093?v=4","gravatar_id":"","url":"https://api.github.com/users/nros","html_url":"https://github.com/nros","followers_url":"https://api.github.com/users/nros/followers","following_url":"https://api.github.com/users/nros/following{/other_user}","gists_url":"https://api.github.com/users/nros/gists{/gist_id}","starred_url":"https://api.github.com/users/nros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nros/subscriptions","organizations_url":"https://api.github.com/users/nros/orgs","repos_url":"https://api.github.com/users/nros/repos","events_url":"https://api.github.com/users/nros/events{/privacy}","received_events_url":"https://api.github.com/users/nros/received_events","type":"User","site_admin":false},"labels":[{"id":512075936,"url":"https://api.github.com/repos/monounity/karma-typescript/labels/support","name":"support","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-26T04:08:05Z","updated_at":"2017-09-27T03:45:05Z","closed_at":null,"author_association":"NONE","body":"We are using karma + TypeScript + mocha + chai with `karma-typescript` for unit testing. At the moment [PhantomJS](http://phantomjs.org/) seems the best option for headless testing on CI machines.\r\n\r\nHowever, PhantomJS does not support ES2015 (ES6) and seems to never will. Hence it fails on JavaScript code making use of keywords `let` or `const`. NPM modules utilizing ES 6 features seem to increase, as nodeJS supports and encourages ES6. Therefore PhantomJS fails if any of such modules is used (eg.: [`chai-as-promised`](https://www.npmjs.com/package/chai-as-promised))\r\n\r\nUsually the transform API can be used to apply [`karma-typescript-es6-transform`](https://www.npmjs.com/package/karma-typescript-es6-transform). Unfortunately the transform API is not applied to resolved modules (eg: all those NPMs from `node_modules`). Hence there is no possibility to apply ES6 translation to those.\r\n\r\nWould it be possible to add this feature?"},"comment":{"url":"https://api.github.com/repos/monounity/karma-typescript/issues/comments/332400505","html_url":"https://github.com/monounity/karma-typescript/issues/186#issuecomment-332400505","issue_url":"https://api.github.com/repos/monounity/karma-typescript/issues/186","id":332400505,"user":{"login":"erikbarke","id":5539280,"avatar_url":"https://avatars3.githubusercontent.com/u/5539280?v=4","gravatar_id":"","url":"https://api.github.com/users/erikbarke","html_url":"https://github.com/erikbarke","followers_url":"https://api.github.com/users/erikbarke/followers","following_url":"https://api.github.com/users/erikbarke/following{/other_user}","gists_url":"https://api.github.com/users/erikbarke/gists{/gist_id}","starred_url":"https://api.github.com/users/erikbarke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikbarke/subscriptions","organizations_url":"https://api.github.com/users/erikbarke/orgs","repos_url":"https://api.github.com/users/erikbarke/repos","events_url":"https://api.github.com/users/erikbarke/events{/privacy}","received_events_url":"https://api.github.com/users/erikbarke/received_events","type":"User","site_admin":false},"created_at":"2017-09-27T03:45:05Z","updated_at":"2017-09-27T03:45:05Z","author_association":"COLLABORATOR","body":"This should work for both project files and files bundled from node_modules, what does your config look like?\r\n\r\nI modified the [typescript-latest example project](https://github.com/monounity/karma-typescript/tree/master/examples/typescript-latest) like this:\r\n\r\n```bash\r\nnpm i chai-as-promised karma-typescript-es6-transform\r\n```\r\nkarma.conf.js:\r\n```js\r\nmodule.exports = function(config) {\r\n    config.set({\r\n\r\n        frameworks: [\"jasmine\", \"karma-typescript\"],\r\n\r\n        files: [\r\n            { pattern: \"src/**/*.ts\" }\r\n        ],\r\n\r\n        preprocessors: {\r\n            \"**/*.ts\": [\"karma-typescript\"]\r\n        },\r\n\r\n        reporters: [\"dots\", \"karma-typescript\"],\r\n\r\n        karmaTypescriptConfig: {\r\n            bundlerOptions: {\r\n                transforms: [\r\n                    require(\"karma-typescript-es6-transform\")()\r\n                ]\r\n            }\r\n        },\r\n\r\n        browsers: [\"Chrome\"]\r\n    });\r\n};\r\n```\r\n\r\nhello.component.js:\r\n```js\r\nimport { HelloService } from \"./hello-service.interface\";\r\n\r\nexport class HelloComponent {\r\n\r\n    constructor(private helloService: HelloService) {}\r\n\r\n    public sayHello(): string {\r\n\r\n        console.log(require(\"chai-as-promised\"));\r\n\r\n        return this.helloService.sayHello();\r\n    }\r\n}\r\n```\r\n\r\nThis works if I execute `npm run dev:ci:phantomjs` (PhantomJS barfs if I remove the es6 transform)."}}
{"actor":{"display_login":"erikbarke"}}