core-js version 3 + this code
import "core-js/es/symbol";
Symbol("test");
cause Exception thrown and not caught in IE11 pointing to this line: https://github.com/zloirock/core-js/blob/master/packages/core-js/internals/internal-state.js#L18
debugging shows that isObject(it) part is false.
Webpack output
```js
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["layout"],{
// "./app/javascript/packs/layout.ts":
/!*************!\
!* ./app/javascript/packs/layout.ts !
************/
/! no exports provided /
/**/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import / var core_js_modules_es_symbol__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/! core-js/modules/es.symbol / "./node_modules/core-js/modules/es.symbol.js");
/ harmony import / var core_js_modules_es_symbol__WEBPACK_IMPORTED_MODULE_0___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol__WEBPACK_IMPORTED_MODULE_0__);
/ harmony import / var core_js_modules_es_symbol_description__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/! core-js/modules/es.symbol.description / "./node_modules/core-js/modules/es.symbol.description.js");
/ harmony import / var core_js_modules_es_symbol_description__WEBPACK_IMPORTED_MODULE_1___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_description__WEBPACK_IMPORTED_MODULE_1__);
/ harmony import / var core_js_modules_es_symbol_async_iterator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/! core-js/modules/es.symbol.async-iterator / "./node_modules/core-js/modules/es.symbol.async-iterator.js");
/ harmony import / var core_js_modules_es_symbol_async_iterator__WEBPACK_IMPORTED_MODULE_2___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_async_iterator__WEBPACK_IMPORTED_MODULE_2__);
/ harmony import / var core_js_modules_es_symbol_has_instance__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/! core-js/modules/es.symbol.has-instance / "./node_modules/core-js/modules/es.symbol.has-instance.js");
/ harmony import / var core_js_modules_es_symbol_has_instance__WEBPACK_IMPORTED_MODULE_3___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_has_instance__WEBPACK_IMPORTED_MODULE_3__);
/ harmony import / var core_js_modules_es_symbol_is_concat_spreadable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/! core-js/modules/es.symbol.is-concat-spreadable / "./node_modules/core-js/modules/es.symbol.is-concat-spreadable.js");
/ harmony import / var core_js_modules_es_symbol_is_concat_spreadable__WEBPACK_IMPORTED_MODULE_4___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_is_concat_spreadable__WEBPACK_IMPORTED_MODULE_4__);
/ harmony import / var core_js_modules_es_symbol_iterator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/! core-js/modules/es.symbol.iterator / "./node_modules/core-js/modules/es.symbol.iterator.js");
/ harmony import / var core_js_modules_es_symbol_iterator__WEBPACK_IMPORTED_MODULE_5___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_iterator__WEBPACK_IMPORTED_MODULE_5__);
/ harmony import / var core_js_modules_es_symbol_match__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/! core-js/modules/es.symbol.match / "./node_modules/core-js/modules/es.symbol.match.js");
/ harmony import / var core_js_modules_es_symbol_match__WEBPACK_IMPORTED_MODULE_6___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_match__WEBPACK_IMPORTED_MODULE_6__);
/ harmony import / var core_js_modules_es_symbol_replace__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/! core-js/modules/es.symbol.replace / "./node_modules/core-js/modules/es.symbol.replace.js");
/ harmony import / var core_js_modules_es_symbol_replace__WEBPACK_IMPORTED_MODULE_7___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_replace__WEBPACK_IMPORTED_MODULE_7__);
/ harmony import / var core_js_modules_es_symbol_search__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/! core-js/modules/es.symbol.search / "./node_modules/core-js/modules/es.symbol.search.js");
/ harmony import / var core_js_modules_es_symbol_search__WEBPACK_IMPORTED_MODULE_8___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_search__WEBPACK_IMPORTED_MODULE_8__);
/ harmony import / var core_js_modules_es_symbol_species__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/! core-js/modules/es.symbol.species / "./node_modules/core-js/modules/es.symbol.species.js");
/ harmony import / var core_js_modules_es_symbol_species__WEBPACK_IMPORTED_MODULE_9___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_species__WEBPACK_IMPORTED_MODULE_9__);
/ harmony import / var core_js_modules_es_symbol_split__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/! core-js/modules/es.symbol.split / "./node_modules/core-js/modules/es.symbol.split.js");
/ harmony import / var core_js_modules_es_symbol_split__WEBPACK_IMPORTED_MODULE_10___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_split__WEBPACK_IMPORTED_MODULE_10__);
/ harmony import / var core_js_modules_es_symbol_to_primitive__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/! core-js/modules/es.symbol.to-primitive / "./node_modules/core-js/modules/es.symbol.to-primitive.js");
/ harmony import / var core_js_modules_es_symbol_to_primitive__WEBPACK_IMPORTED_MODULE_11___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_to_primitive__WEBPACK_IMPORTED_MODULE_11__);
/ harmony import / var core_js_modules_es_symbol_to_string_tag__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/! core-js/modules/es.symbol.to-string-tag / "./node_modules/core-js/modules/es.symbol.to-string-tag.js");
/ harmony import / var core_js_modules_es_symbol_to_string_tag__WEBPACK_IMPORTED_MODULE_12___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_to_string_tag__WEBPACK_IMPORTED_MODULE_12__);
/ harmony import / var core_js_modules_es_symbol_unscopables__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/! core-js/modules/es.symbol.unscopables / "./node_modules/core-js/modules/es.symbol.unscopables.js");
/ harmony import / var core_js_modules_es_symbol_unscopables__WEBPACK_IMPORTED_MODULE_13___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_symbol_unscopables__WEBPACK_IMPORTED_MODULE_13__);
/ harmony import / var core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/! core-js/modules/es.array.concat / "./node_modules/core-js/modules/es.array.concat.js");
/ harmony import / var core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_14___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_array_concat__WEBPACK_IMPORTED_MODULE_14__);
/ harmony import / var core_js_modules_es_json_to_string_tag__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/! core-js/modules/es.json.to-string-tag / "./node_modules/core-js/modules/es.json.to-string-tag.js");
/ harmony import / var core_js_modules_es_json_to_string_tag__WEBPACK_IMPORTED_MODULE_15___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_json_to_string_tag__WEBPACK_IMPORTED_MODULE_15__);
/ harmony import / var core_js_modules_es_math_to_string_tag__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/! core-js/modules/es.math.to-string-tag / "./node_modules/core-js/modules/es.math.to-string-tag.js");
/ harmony import / var core_js_modules_es_math_to_string_tag__WEBPACK_IMPORTED_MODULE_16___default = /#__PURE__/__webpack_require__.n(core_js_modules_es_math_to_string_tag__WEBPACK_IMPORTED_MODULE_16__);
/ harmony import / var core_js_modules_es_object_to_string__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/! core-js/modules/es.object.to-string / "./node_modules/core-js/modules/es.object.to-string.js");
/ harmony import / var core_js_modules_es_object_to_string__WEBPACK_IMPORTED_MODULE_17___default = /#__PURE__*/__webpack_require__.n(core_js_modules_es_object_to_string__WEBPACK_IMPORTED_MODULE_17__);
Symbol("test");
/*/ })
},[["./app/javascript/packs/layout.ts","runtime","vendors~layout"]]]);
//# sourceMappingURL=layout-4d52b5d1e5b236c62a54.chunk.js.map
```
Would be happy to provide more info if needed!
Sorry, I can't reproduce it. This code works fine for me:

Maybe the problem in your build process? Maybe you could create a repo with a reproducible example?
Hi @zloirock
I can confirm I am getting the same issue at the same line of internal-state.js. This issue has only occurred since upgrading to using core-js v3 & regenerator-runtime in lieu of @babel-polyfill.



Any help would be much appreciated :) Let me know if you need me to provide any further information.
Let me know if you need me to provide any further information.
@andrewcourtice here could help a reproducible example.
Maybe it's because of the different IE minor version.
@zloirock removing the isObject(it) check in internal-state.js resolved the issue. The value of it is always a symbol and therefore always fails that check.
Can you provide the full stack trace?
Maybe it's because of the different IE minor version.
Unlikely.
removing the isObject(it) check in internal-state.js resolved the issue. The value of it is always a symbol and therefore always fails that check.
IE11 haven't native symbols. Are you sure that core-js is not transpiled by babel? Babel should not transpile core-js for correct work.
@zloirock that was the thing! I'm using webpacker which is in the latest release transpiles node modules.
These changes fix it:
const nodeModulesLoader = environment.loaders.get("nodeModules");
nodeModulesLoader.exclude = [].concat(nodeModulesLoader.exclude || []);
nodeModulesLoader.exclude.push(/core-js/);
Thanks a lot for the help! if it is the same case for @andrewcourtice I would be happy to close the issue
If it compiles node_modules by default, it might be worth reporting a bug to webpacker asking to also exclude core-js by default.
How would compiling core-js cause this bug? I believe core-js is written in ES3, so babel shouldn't have anything to compile
@JakeChampion in this case, it's _typeof helper from @babel/plugin-transform-typeof-symbol which breaks core-js Symbol polyfill since internally polyfilled symbols handled as objects.
Unfortunately in my case I don't believe the problem is core-js being transpiled. I have an exclude expression in my webpack config to ensure node modules aren't processed.
The only things that have changed in my project are:
From:
"dependencies": {
"@babel/polyfill": "^7.2.5"
},
"devDependencies": {
"@babel/core": "^7.3.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.3.4",
"@babel/register": "^7.0.0"
}
To:
"dependencies": {
"core-js": "3",
"regenerator-runtime": "^0.13.2"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.4.2",
"@babel/register": "^7.4.0"
}
From:
import '@babel/polyfill';
to:
import 'core-js/stable';
import 'regenerator-runtime/runtime';
From:
module.exports = {
presets: [
['@babel/preset-env', {
useBuiltIns: 'entry',
include: [
'es7.promise.finally'
]
}]
],
plugins: [
'@babel/plugin-syntax-dynamic-import'
]
};
to:
module.exports = {
presets: [
['@babel/preset-env', {
useBuiltIns: 'entry',
corejs: 3
}]
],
plugins: [
'@babel/plugin-syntax-dynamic-import'
]
};
For reference my .browserslistrc file is:
> 5%
last 2 versions
Firefox ESR
not dead
and my webpack babel rule is:
{
test: /\.js$/,
loader: 'babel-loader',
exclude: file => /node_modules\/(?!@myCompany)/.test(file) && !/\.vue\.js/.test(file)
}
Perhaps I have an incorrect configuration somewhere or have missed something crucial?
You are explicitly _not_ excluding core-js, since /node_modules\/(?!@myCompany|core-js)/.test(file) will return true for any core-js module.
I suggest using something like this: (assuming that you want to transpile every .js file outside node_modules and only .vue.js files from @myCompany even if in node_modules):
{
test: /\.js$/,
loader: "babel-loader",
exclude: {
test: /node_modules/,
not: [
/@myCompany.*\.vue\.js$/
]
},
}
Sorry that was something I was just testing. The actual config doesn't have the core-js alternative in it.
@nicolo-ribaudo Thanks, I'll give that a go.
That is the same as your edited regexp, without core-js :stuck_out_tongue:
I don't see why this was closed. This continues to happen. I can confirm, using the same settings op had.
In ie version: 11.0.9600.19301
@mihaisavezi because it's not a core-js issue, the problem in users babel config, see the explanation above.
To provide some of the requested information in textual form and potentially help other searchers find this...
Stacktrace:
Anonymous function [Line: 58959, Col: 7], application-25c17a393321492539b8.js
description [Line: 67405, Col: 9], application-25c17a393321492539b8.js
./node_modules/core-js/modules/es.symbol.description.js [Line: 67078, Col: 1], application-25c17a393321492539b8.js
__webpack_require__ [Line: 20, Col: 12], application-25c17a393321492539b8.js
./node_modules/core-js/es/index.js [Line: 55490, Col: 1], application-25c17a393321492539b8.js
__webpack_require__ [Line: 20, Col: 12], application-25c17a393321492539b8.js
./node_modules/core-js/stable/index.js [Line: 70334, Col: 1], application-25c17a393321492539b8.js
__webpack_require__ [Line: 20, Col: 12], application-25c17a393321492539b8.js
./app/javascript/packs/application.js [Line: 22482, Col: 22], application-25c17a393321492539b8.js
__webpack_require__ [Line: 20, Col: 12], application-25c17a393321492539b8.js
Anonymous function [Line: 84, Col: 11], application-25c17a393321492539b8.js
Global code [Line: 1, Col: 11], application-25c17a393321492539b8.js
The function throwing the exception is:
var getterFor = function getterFor(TYPE) {
return function (it) {
var state;
if (!isObject(it) || (state = get(it)).type !== TYPE) {
throw TypeError('Incompatible receiver, ' + TYPE + ' required');
}
return state;
};
};
We are also experiencing this, but our webpack configuration appears to not be transpiling node_modules at all:
{ test: /\.(js|jsx|mjs)?(\.erb)?$/,
include: [ '...snip.../app/javascript' ],
exclude: /node_modules/,
use: [ { loader: 'babel-loader', options: [Object] } ] }
Is there a specific part of the processed output of corejs I can look at to determine if it has had some transformation performed on it? This would let be rule in/out some misconfiguration somewhere.
Ah, apologies, I see now that the existing solution works for me 鈥斅營 was unaware that the nodeModules loader was provided by webpacker itself, and not a custom configuration from that poster.
Sorry for the noise!
@shepmaster I did a PR to webpacker to fix that behavior, hope it'll get merged soon https://github.com/rails/webpacker/pull/2031
I tried a solution like
{
test: /\.js$/,
exclude: [/node_modules\/(?!(core-js))/],
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
modules: false,
useBuiltIns: 'entry',
corejs: 3,
},
],
],
babelrc: false,
plugins: [
'@babel/plugin-syntax-dynamic-import',
['@babel/plugin-transform-react-jsx', { pragma: 'h' }],
],
},
},
],
},
with latest core-js 3.0.1, babel 7 and webpack 4 but the error keeps happening. 馃槶
With that regex, you're excluding all of your node_modules _except_ core-js. ?! is negative look-ahead.
version 3 has this error.
https://github.com/zloirock/core-js#babelpolyfill
Now it's deprecated in favour of separate inclusion of required parts of core-js and regenerator-runtime and, for preventing breaking changes, left on core-js@2.
npm i [email protected]
set config:
const rules = [
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: 2
}
]
]
}
}
]
}
];
and replace import '@babel/polyfill'; to:
import 'core-js';
import 'regenerator-runtime/runtime';
(ver 2.6.5 does not have 'core-js/stable')
@yuma84 why just not configure your transpiler correctly, as explained above? -)
Hey. Following up with this issue, here's my idea of a reliable, cross-platform exclusion of core-js:
const isPathInside = require('is-path-inside')
const pkgDir = require('pkg-dir')
const coreJsDir = pkgDir.sync(require.resolve('core-js'))
module.exports = {
module: {
rules: [
{
test: /\.m?js$/,
exclude: (input) => isPathInside(input, coreJsDir),
use: { loader: 'babel-loader' }
}
]
}
}
Further, this seems like it should be a default exclusion, doesn't it? I mean鈥攏o-one would ever wanna transpile core-js, right?
To which package(s) should I suggest/request/make a PR for this to be a default exclusion? So many packages :confused:.
I fixed it by changing my babel-loader for node_modules to
{
test: /\.(js|jsx)$/,
exclude: /@babel(?:\/|\\{1,2})runtime|core-js/,
use: {
loader: 'babel-loader',
options: {
babelrc: false,
configFile: path.resolve(__dirname, 'babel.config.js'),
compact: false,
cacheDirectory: true,
sourceMaps: false,
},
},
},
Notice the |core-js added to the exclude field. That did the trick for our setup.
Thank you, this Helped me with pwa-starter-kit migration to core-js3 <3
Running into the exact same issue:
Stack trace:
console.trace()
at Anonymous function (eval code:20:7)
at toString (eval code:178:5)
at hoistNonReactStatics (eval code:86:7)
at hoistNonReactStatics (eval code:70:9)
at withRouter (eval code:730:3)
at eval code (eval code:70:1)
at ./node_modules/@optimistdigital/create-frontend/universal-react/Router.js (http://192.168.1.65:3000/app.js:4819:1)
at __webpack_require__ (http://192.168.1.65:3000/app.js:727:12)
Incompatible receiver, Symbol required
SCRIPT5022: Exception thrown and not caught
eval code (431) (22,7)
internal-state.js

webpack
const babelExcludes = /node_modules[\/\\](?!(@optimistdigital[\/\\]create-frontend)[\/\\]).*/; // Exclude everything except create-frontend code
{
test: /\.(js|mjs)$/,
exclude: babelExcludes,
use: [
{
loader: require.resolve('babel-loader'),
options: babelOpts,
},
],
},
babel
module.exports = {
presets: [
['@babel/preset-env', { corejs: 3, modules: false, useBuiltIns: 'entry' }],
'@babel/preset-react'
],
plugins: [
require.resolve('babel-plugin-dev-expression'),
'@babel/plugin-proposal-object-rest-spread',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-transform-runtime', { corejs: 3 }],
'babel-plugin-lodash',
],
env: {
production: {
plugins: [require.resolve('babel-plugin-transform-react-remove-prop-types')],
},
development: {
plugins: [require.resolve('@babel/plugin-transform-react-jsx-source')],
},
test: {
plugins: [require.resolve('@babel/plugin-transform-modules-commonjs')],
},
},
};
Fixed it. It was due to the corejs: 3 being passed to ['@babel/plugin-transform-runtime', { corejs: 3 }]. According to core-js creator, the option should be passed to either @babel/preset-env with useBuiltIns: 'entry' OR @babel/plugin-transform-runtime, not both.
I removed { corejs: 3 } from ['@babel/plugin-transform-runtime'] and it started working again. Polyfills were being imported twice, causing duplicates and apparently also errors.
@Tarpsvo I started troubleshooting this very issue 4 hours ago and a colleague just pointed out your comment to me, which finally fixed it! So thank you!
@Tarpsvo ...and how are you importing core-js?
I'm still getting the error and also getting Import of core-js was not found.
Could you please share the relevant part of your webpack file? Thanks
import 'core-js/stable'; as I'm using core-js 3.
For those, coming here in the future.
I have a multipage PHP app, and JS ES6 modules, this a setup that works:
babel
...
const presets = [
[
'@babel/preset-env', {
useBuiltIns: 'usage', //"usage", because of multipage app and because of ProvidePlugin used in webpack
corejs: '3.4',
// debug: true, // useful to see what's going on :)
modules: 'amd',
targets: {
browsers: ['last 5 versions', 'safari >= 8'],
esmodules: false
}
}
]
]
const plugins = [
'ramda',
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-proposal-class-properties',
[
'@babel/plugin-transform-runtime',
{
regenerator: true
}
]
]
...
webpack
{
test: /\.js$/,
exclude: {
test: /node_modules/,
// including some packages that I want to transpile:
not: [
/(ssr-window|dom7|swiper|micromodal)/
]
},
use: [
{
loader: 'babel-loader'
},
{
loader: 'standard-loader?error=true'
}
]
},
Since core-js 3.4.2, I get this error too. It works with core-js 3.4.1

Replacing import 'core-js'; by import 'core-js/stable'; in polyfills.js make it works
It probably means the 3.4.2 version, introduces bugs in the non-stable part of core-js but i'd like to hear about this from the author
@Clemzd [email protected] does not contain any changes in ES proposals. However, this version includes one minor bug which could cause something like that, it was fixed in the latest versions. Please, check - maybe you have other used copies of core-js or other polyfills. If it will not help - feel free to add a new issue with the reproducible example or at least a detailed specification.
@zloirock Ty for your answer. I get this error with [email protected] too so I don't think it may be related with this minor bug. I don't really have the time to make a reproducible example but I can give you my package.json. Is this could be enough?
@Clemzd sorry, but in this case, it's not enough, I don't see any obvious problems. If you will be able to add a reproducible example, please, open a new issue. This issue is absolutely unrelated.
Most helpful comment
@zloirock that was the thing! I'm using webpacker which is in the latest release transpiles node modules.
These changes fix it:
Thanks a lot for the help! if it is the same case for @andrewcourtice I would be happy to close the issue