mzgoddard / jest-webpack

Use jest with webpack.
https://www.npmjs.com/package/jest-webpack
92 stars 21 forks source link

Maximum call stack size exceeded #30

Closed arthurgeron closed 6 years ago

arthurgeron commented 6 years ago

Error I'm getting:

(node:11828) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:230
        .findIndex(transform => (
         ^

RangeError: Maximum call stack size exceeded
    at Array.findIndex (native)
    at SharedData.compileModule (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:230:10)
    at manifest.(anonymous function).transforms.find.dependencies.forEach.dep (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:279:16)
    at Array.forEach (<anonymous>)
    at SharedData.compileModule (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:276:23)
    at manifest.(anonymous function).transforms.find.dependencies.forEach.dep (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:279:16)
    at Array.forEach (<anonymous>)
    at SharedData.compileModule (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:276:23)
    at manifest.(anonymous function).transforms.find.dependencies.forEach.dep (/home/arthur/ageron/Documents/Projects/secret/node_modules/jest-webpack/src/shared-data.js:279:16)
    at Array.forEach (<anonymous>)

My package.json:

{
  "name": "secret",
  "version": "0.1.0",
  "private": true,
  "main": "./public",
  "scripts": {
    "start": "npm run dev",
    "dev": "./node_modules/.bin/cross-env NODE_ENV=development ./node_modules/.bin/webpack-dev-server --host 0.0.0.0 --content-base public/ --port 4444 --colors --progress --mode development",
    "dev:prod": "./node_modules/.bin/cross-env NODE_ENV=production ./node_modules/.bin/webpack-dev-server --host 0.0.0.0 --content-base public/ --port 4444 --colors --progress --mode production",
    "build": "./node_modules/.bin/cross-env NODE_ENV=production ./node_modules/.bin/webpack --mode production",
    "lint": "./node_modules/.bin/standard",
    "lint:fix": "./node_modules/.bin/standard --fix",
    "test": "./node_modules/.bin/jest",
    "test:beta": "./node_modules/.bin/jest-webpack"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-jest": "^23.0.1",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
    "bootstrap": "^4.1.1",
    "cross-env": "^5.1.6",
    "css-loader": "^0.28.11",
    "domurl": "^2.1.9",
    "eslint": "^4.19.1",
    "ghooks": "^2.0.4",
    "hson-loader": "^2.0.0",
    "html-loader": "^0.5.5",
    "jest": "^23.1.0",
    "jest-css-modules": "^1.1.0",
    "jest-webpack": "^0.5.0",
    "jquery": "^3.3.1",
    "json-loader": "^0.5.7",
    "nib": "^1.1.2",
    "path-here": "^1.1.1",
    "popper.js": "^1.14.3",
    "s-js": "^0.4.8",
    "standard": "^11.0.1",
    "standard-loader": "^6.0.1",
    "style-loader": "^0.21.0",
    "surplus": "^0.5.2",
    "surplus-loader": "^0.5.0",
    "url-loader": "^1.0.1",
    "webpack": "^4.12.0",
    "webpack-cli": "^3.0.8",
    "webpack-dev-server": "^3.1.4"
  },
  "dependencies": {
    "@fortawesome/fontawesome": "^1.1.8",
    "@fortawesome/fontawesome-free-solid": "^5.0.13"
  },
  "config": {
    "ghooks": {
      "pre-commit": "npm run lint"
    }
  },
  "jest": {
    "modulePaths": [
      "/app"
    ],
    "moduleFileExtensions": [
      "js"
    ],
    "moduleDirectories": [
      "node_modules"
    ],
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__test__/__mocks__/file-mock.js",
      "\\.(css|less)$": "<rootDir>/__test__/__mocks__/style-mock.js"
    },
    "transform": {
      "^.+\\.js$": "babel-jest",
      "^.+\\.(css|scss|less)$": "jest-css-modules"
    },
    "verbose": true,
    "globals": {
      "NODE_ENV": "test"
    }
  },
  "standard": {
    "parser": "babel-eslint",
    "exclude": "/node_modules/",
    "error": false,
    "snazzy": true,
    "quiet": true,
    "emitError": false,
    "failOnError": false,
    "failOnWarning": false,
    "ignore": [
      "**/*.test.js",
      "**/*.mock.js"
    ]
  }
}
nix12 commented 6 years ago

I am getting the same error. Is there a workaround for this?

arthurgeron commented 6 years ago

This happened to me because I wasn't ignoring node_modules, I don't have the changes/config here because I've moved away from jest into karma + jasmine.

nix12 commented 6 years ago

Do you remember how you were able to ignore node_modules?

mzgoddard commented 6 years ago

@arthurgeron thank you for opening this issue.

Looking into it it seems it was recursive dependencies causing the issue at this point in the code when building a project with an existing cache.

arthurgeron commented 6 years ago

Awesome, thanks for fixing the problem!