{"action":"created","issue":{"url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/120","repository_url":"https://api.github.com/repos/wmonk/create-react-app-typescript","labels_url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/120/comments","events_url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/120/events","html_url":"https://github.com/wmonk/create-react-app-typescript/issues/120","id":246036374,"number":120,"title":"Cant import regular js files when using create-react-app-typescript","user":{"login":"mhgamework","id":125686,"avatar_url":"https://avatars0.githubusercontent.com/u/125686?v=4","gravatar_id":"","url":"https://api.github.com/users/mhgamework","html_url":"https://github.com/mhgamework","followers_url":"https://api.github.com/users/mhgamework/followers","following_url":"https://api.github.com/users/mhgamework/following{/other_user}","gists_url":"https://api.github.com/users/mhgamework/gists{/gist_id}","starred_url":"https://api.github.com/users/mhgamework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhgamework/subscriptions","organizations_url":"https://api.github.com/users/mhgamework/orgs","repos_url":"https://api.github.com/users/mhgamework/repos","events_url":"https://api.github.com/users/mhgamework/events{/privacy}","received_events_url":"https://api.github.com/users/mhgamework/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2017-07-27T13:17:43Z","updated_at":"2017-12-11T16:28:53Z","closed_at":"2017-08-07T15:59:33Z","author_association":"NONE","body":"I have some .js + .d.ts files which i am using in my create-react-app-typescript project. Everything works and runs fine with npm run start or npm run build.\r\n\r\nWhen running npm run test, the import statements for these .js files return the name of the file, instead of actually importing the file.\r\n\r\nI believe this behaviour is caused by the configuration line in \"createJestConfig.js\". The matches all .js files and replaces them with stubs:\r\n```\r\n'^(?!.*\\\\.(css|json)$)': resolve('config/jest/fileTransform.js'),\r\n```\r\n\r\nWhen adding .js to the ignored transform patterns, the tests correctly import my .js+.d.ts files\r\n```\r\n  transformIgnorePatterns: [\r\n      '[/\\\\\\\\]node_modules[/\\\\\\\\].+\\\\.(js|jsx|ts|tsx)$',\r\n      '^.+\\\\.js$' // I ADDED THIS LINE\r\n    ],\r\n```\r\n\r\nI believe this is a bug/oversight in the configuration, since using .js+.dts files as source code is not that strange. In any case i do not think it makes sense to replace all .js files with stubs. \r\nI would love to see this fixed in the project or a way to configure this without the massive workaround i have posted below\r\n\r\nThanks,\r\nMH\r\n\r\nPS\r\n\r\nI use this workaround to prevent changing the react-scripts ts:\r\n```\r\nvar Module = require('module');\r\nModule.prototype.require = new Proxy(Module.prototype.require, {\r\n    apply(target, thisArg, argumentsList){\r\n\r\n        let name = argumentsList[0];\r\n\r\n        if (name === \"./utils/createJestConfig\") {///\\.\\/utils\\/createJestConfig/g.test(name)){\r\n            var ret = Reflect.apply(target, thisArg, argumentsList);\r\n            var ori = ret;\r\n            createJestConfig = function (a, b, c) {\r\n                var ret = ori(a, b, c);\r\n                ret.transformIgnorePatterns.push('^.+\\\\.js$');\r\n                return ret;\r\n            }\r\n            return createJestConfig;\r\n        }\r\n        else\r\n            return Reflect.apply(target, thisArg, argumentsList)\r\n    }\r\n})\r\n\r\nrequire(\"react-scripts-ts/scripts/test\");\r\n```"},"comment":{"url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/comments/350777120","html_url":"https://github.com/wmonk/create-react-app-typescript/issues/120#issuecomment-350777120","issue_url":"https://api.github.com/repos/wmonk/create-react-app-typescript/issues/120","id":350777120,"user":{"login":"QuantumInformation","id":216566,"avatar_url":"https://avatars0.githubusercontent.com/u/216566?v=4","gravatar_id":"","url":"https://api.github.com/users/QuantumInformation","html_url":"https://github.com/QuantumInformation","followers_url":"https://api.github.com/users/QuantumInformation/followers","following_url":"https://api.github.com/users/QuantumInformation/following{/other_user}","gists_url":"https://api.github.com/users/QuantumInformation/gists{/gist_id}","starred_url":"https://api.github.com/users/QuantumInformation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuantumInformation/subscriptions","organizations_url":"https://api.github.com/users/QuantumInformation/orgs","repos_url":"https://api.github.com/users/QuantumInformation/repos","events_url":"https://api.github.com/users/QuantumInformation/events{/privacy}","received_events_url":"https://api.github.com/users/QuantumInformation/received_events","type":"User","site_admin":false},"created_at":"2017-12-11T16:28:53Z","updated_at":"2017-12-11T16:28:53Z","author_association":"NONE","body":"I'm trying to use pretender (js only) with typescript without the types by importing this way:\r\n```js\r\nlet Pretender:any = require('pretender')\r\n```\r\n![image](https://user-images.githubusercontent.com/216566/33841581-1d58ca94-de90-11e7-9fa6-8723be552b99.png)\r\n\r\nIf I just run it as normal it comes out like:\r\n\r\n![image](https://user-images.githubusercontent.com/216566/33841620-30e1f52c-de90-11e7-8b4d-ebb8dc1b78a5.png)\r\n\r\nthis might be a webpack issue, any ideas?\r\n\r\n"}}
{"actor":{"display_login":"QuantumInformation"}}