question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build fails @babel/core - Invalid value used as weak map key

See original GitHub issue

Bug Report

Current Behavior I have upgraded from babel 6.25.0 to @babel/core 7.0.0 by using the babel-upgrade --write comand.

I am using webpack and babel together. I am able to run webpack-dev-server fine after the upgrade. When I attempt to start my app in prod and run my build command, the build immediately fails pointing to @babel/core within babel-loader with this error:

ERROR in ./src/index.jsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Invalid value used as weak map key
    at WeakMap.set (<anonymous>)
    at loadCachedDescriptor (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-descriptors.js:84:20)
    at createPluginDescriptors.map.desc (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-descriptors.js:63:108)
    at Array.map (<anonymous>)
    at alias (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-descriptors.js:63:96)
    at cachedFunction (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/caching.js:33:19)
    at plugins.plugins (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-descriptors.js:28:77)
    at mergeChainOpts (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-chain.js:319:26)
    at /Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/config-chain.js:68:29)
    at loadPrivatePartialConfig (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/partial.js:85:55)
    at loadFullConfig (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/config/full.js:43:39)
    at process.nextTick (/Users/tjohnson/Public/repos/api-manager-web/node_modules/@babel/core/lib/transform.js:28:33)
    at process._tickCallback (internal/process/next_tick.js:61:11)

I have spent a long time looking for similiar issues, opened a question on SO, and unfortunately I have not had any luck resolving this. Thank you for the help.

Expected behavior/code I expect to be able to run my build command and bundle my app for prod.

Babel Configuration (.babelrc, package.json, cli command)

{
	"presets": ["@babel/preset-env", "@babel/preset-react", "react-app"],
	"env": {
		"development": {
			"plugins": ["react-hot-loader/babel"]
		},
		"test": {
			"plugins": [
				["webpack-alias", { "config": "./build_config/webpack.common.js" }],
				"istanbul",
				"dynamic-import-node"
			]
		},
		"production": {
			"plugins": [
				"transform-react-remove-prop-types",
				["recharts", null],
				["react-hot-loader/babel", null]
			]
		}
	}
}

package.json devDependencies

  "devDependencies": {
    "@babel/core": "7.4.4",
    "@babel/preset-env": "^7.4.4",
    "@babel/preset-react": "^7.0.0",
    "autoprefixer": "^7.1.2",
    "babel-eslint": "^9.0.0",
    "babel-loader": "^8.0.5",
    "babel-plugin-istanbul": "^5.0.1",
    "babel-plugin-recharts": "^1.1.0",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.6",
    "babel-preset-react-app": "^8.0.0",
    "chai": "^4.1.2",
    "chai-as-promised": "^7.1.1",
    "copy-webpack-plugin": "^5.0.3",
    "copyfiles": "^2.1.0",
    "cross-env": "^5.0.1",
    "css-loader": "^2.1.1",
    "dotenv": "^8.0.0",
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16": "^1.6.0",
    "eslint": "^5.15.3",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-config-prettier": "^3.1.0",
    "eslint-import-resolver-webpack": "^0.10.1",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.1",
    "eslint-plugin-prettier": "^2.6.2",
    "eslint-plugin-react": "^7.11.0",
    "eslint-plugin-react-hooks": "^1.0.1",
    "eslint-plugin-testcafe": "^0.2.1",
    "extract-text-webpack-plugin": "^4.0.0-alpha.0",
    "file-loader": "^3.0.1",
    "html-webpack-plugin": "^3.2.0",
    "jsdom": "9.0.0",
    "mocha": "^5.2.0",
    "mocha-duplicate-reporter": "^0.2.1",
    "mocha-jenkins-reporter": "^0.4.0",
    "mocha-multi": "^0.11.0",
    "mocha-sonar-generic-test-coverage": "0.0.3",
    "node-sass": "^4.9.3",
    "null-loader": "^1.0.0",
    "nyc": "^13.0.1",
    "postcss-loader": "^2.0.6",
    "preload-webpack-plugin": "^2.3.0",
    "process-finder": "1.0.0",
    "react-hot-loader": "^4.8.4",
    "redux-mock-store": "^1.2.2",
    "retire": "^2.0.2",
    "rimraf": "^2.5.4",
    "sass-loader": "^6.0.6",
    "script-ext-html-webpack-plugin": "^2.1.3",
    "semver": "^5.3.0",
    "simple-mock": "^0.7.3",
    "sinon": "^7.2.2",
    "style-loader": "^0.20.2",
    "stylelint": "^9.10.1",
    "stylelint-config-standard": "^18.0.0",
    "testcafe": "^1.0.0",
    "tree-kill": "1.2.0",
    "url-join": "^4.0.0",
    "url-loader": "^1.1.2",
    "weakmap-polyfill": "^2.0.0",
    "webpack": "^4.30.0",
    "webpack-bundle-analyzer": "^3.3.2",
    "webpack-cli": "^3.3.1",
    "webpack-dev-middleware": "^3.6.2",
    "webpack-dev-server": "^3.3.1",
    "webpack-merge": "^4.2.1"
  },

cli commands:

    "prebuild": "rm -rf dist",
    "all": "npm run build && npm run lint && npm run test",
    "build": "npm run build:dist",
    "build:copy": "copyfiles -f ./public/favicon.ico ./dist && copyfiles -f ./public/authzconfiguration.tpl.js ./dist",
    "build:dist": "npm run build:copy && cross-env NODE_ENV=production webpack -p --env=prod --progress --colors",
"start": "webpack-dev-server --progress --colors --env=dev",

Environment

  • Babel version(s): 7.0.0
  • Node/npm version: Node v10.15.0 - npm 6.7.0:
  • OS: OSX 10.14.3
  • Monorepo: no
  • How you are using Babel: loader/webpack

Possible Solution I have looked at my dependencies, and I have several packages that depend on babel v6.xx. This may relate to it, but I am not sure

Additional context/Screenshots Screen Shot 2019-05-04 at 1 51 09 AM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
divbhasincommented, May 5, 2019

@nicolo-ribaudo I would like to take this issue, please. Thank you!

1reaction
loganfsmythcommented, May 4, 2019

Huh, I’m surprised that this doesn’t give a more useful error message and gets all the way to the WeakMap. We must have missed something in the validation of the config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid value used in weak set" while build using webpack ...
I want to build css files from scss ones, but I get an error that says "TypeError: Invalid value used in weak set"...
Read more >
BabelJS - Quick Guide - Tutorialspoint
Proxy returns the object with key-values. Output. Siya Kapoor Mumbai invalid key. Let us now see how to transpile the above code to...
Read more >
Acknowledgements | Discord
Gotta show respect where respect is due. See all the licenses and open source projects that Discord uses.
Read more >
Upgrading to Angular 14 - Ionic declares lots of issues
node_modules/ngx-electron/ivy_ngcc/fesm2015/ngx-electron.js - Error: Invalid value used as weak map key .
Read more >
Read Setting up ES6 | Leanpub
WeakMaps : The entries of a WeakMap are key-value pairs. ... This information can be used for error messages and debugging, to refer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found