Skip to content

High CPU usage while running a CRA with typescript in Windows. #7070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
charlie632 opened this issue May 16, 2019 · 3 comments
Closed

High CPU usage while running a CRA with typescript in Windows. #7070

charlie632 opened this issue May 16, 2019 · 3 comments

Comments

@charlie632
Copy link

Is this a bug report?

Yes.

Did you try recovering your dependencies?

Yes.

Environment

Environment Info:                                                                                                                                                   System:                                                                           
 OS: Windows 10                                                                   
 CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz                          
Binaries:                                                                          
Node: 10.15.3 - C:\Program Files\nodejs\node.EXE                                 
Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD                          
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD                                   
                                          
npmPackages:                                                                       
react: Not Found                                                                 
react-dom: Not Found                                                             
  react-scripts: Not Found                                                       
npmGlobalPackages:                                                                
 create-react-app: Not Found
--

Details

I have a high CPU usage when running a React app.

image

I think it is a problem with a dependency, because if I run a newly created CRA --typescript, the CPU usage drastically decreases. My package.json is as follows:

{
  "name": "app-name",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.0.0-beta.2",
    "@material-ui/icons": "^4.0.0-beta.0",
    "@material-ui/styles": "^4.0.0-beta.2",
    "@types/jest": "24.0.13",
    "@types/node": "12.0.1",
    "@types/react": "16.8.17",
    "@types/react-dom": "16.8.4",
    "apollo-boost": "^0.3.1",
    "apollo-link": "^1.2.11",
    "apollo-link-context": "^1.0.17",
    "apollo-link-error": "^1.1.10",
    "classnames": "^2.2.6",
    "graphql": "^14.3.0",
    "jwt-decode": "^2.2.0",
    "msal": "^1.0.0",
    "react": "^16.8.6",
    "react-apollo": "^2.5.5",
    "react-apollo-hooks": "^0.4.5",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "3.0.1",
    "typescript": "^3.4.5",
    "use-react-router": "^1.0.6"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "gen": "graphql-codegen --config codegen.yml",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@graphql-codegen/cli": "^1.1.3",
    "@graphql-codegen/typescript": "1.1.3",
    "@graphql-codegen/typescript-operations": "1.1.3",
    "@graphql-codegen/typescript-react-apollo": "1.1.3"
  }
}

Do you know if any of these packages is causing any issues?

I tried rewriting my App.tsx to render just an empty div and the CPU usage is still the same.

Tried deleting and installing node_modules, deleted typescript cache, but no luck.

Tried on a different Windows machine and the results are the same.

@charlie632
Copy link
Author

UPDATE:

Switched to Ubuntu, same project, same package-lock.json - npm installed and no issues. Build times are faster than I could ever imagine. A friend tried in his 2014 Mac and runs perfectly.
So this is Windows related.

Any idea what module or package is occasioning this?

@charlie632
Copy link
Author

Kept having the same issue on Ubuntu. Found out the solution (or workaround) to this. See #6792 for more details.

@ianschmitz
Copy link
Contributor

Yes indeed it is likely related to TypeScript issues. Closing in favor of #6792.

microsoft/TypeScript#31048 is also related to #6792.

@lock lock bot locked and limited conversation to collaborators May 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants