-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Uncaught TypeError: isObject is not a function (with useBuiltIns: usage) #743
Comments
It's the problem on your side - it seems it's in your bundling / transpiling process. Seems you transpile |
Oh yeah right! Should all polyfills (including I'm excluding core-js using exclude : /core-js/ But now I get another error in
It looks like an error with
Edit: Related to babel/babel-loader#171 and https://stackoverflow.com/q/54156617/1480391 |
What exactly should be excluded from transpiling in core-js? Is there a documentation about that? I think I prefer blacklisting module to exclude from transpilation, instead of whitelisting module to includes 🤔 |
I tried to exclude Looks like other ones are facing the same problem https://stackoverflow.com/q/57361439/1480391
Once figured out what exactly has to be excluded, may we have some documentation about that? Note that I made my build running without visible errors (I may be facing errors on some browsers) by whitelisting modules I need to transpile, but this is not a sustainable solution. |
Please, also make sure that you use only actual versions of |
Hey @zloirock I found a solution! 🎉 but I'm not sure how to explain it 🤔 I made a console log of ALL dependencies and checked all of them to figure out which one should not be transpiled (in addition to My code is using the following Webpack "buildin" modules that should also NOT be transpiled:
To fix the problem I made the exclude to be: exclude : [
/\bcore-js\b/,
/\bwebpack\/buildin\b/
] I'm super happy to have the problem fixed.. but can you help me understand why Edit: Should I exclude all |
I'm closing this issue as it's not (?) related to core-js, but I'm still interested to have your expertise on this. Should documentation be added on this subject? |
Probably they should be excluded because webpack injects them in every module it bundles. So, when you
|
Thank you for the explanation. Also FYI, I tried to add // Plugins
plugins : [
// Require the Babel runtime as a separate module to avoid the duplication
// https://webpack.js.org/loaders/babel-loader/#babel-is-injecting-helpers-into-each-file-and-bloating-my-code
["@babel/plugin-transform-runtime", {
// Requires @babel/runtime-corejs3
// https://babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2
corejs : { version: 3, proposals: true }
}],
} And I ran into a similar problem giving me the following error:
I solved it by excluding Hope that helps someone |
I don't understand anything about transpilers: I'd like to know where I put that exclude : [ |
@kaline For more details about this solution, see https://stackoverflow.com/a/59647913/1480391 They should be excluded from {
module : {
rules : [{
test : /\.js$/,
+ exclude : [
+ /\bcore-js\b/,
+ /\bwebpack\/buildin\b/
+ ],
loader : "babel-loader",
options: { ... }
}]
} |
This may have changed since the most recent comments. I'm having an issue where core-js and/or the webpack component mentioned ("webpack/buildin") is being transpiled when I use the If anyone's curious, my issue is that my front end code uses schema-inspector, and as of their latest version, they depend on a version of the library async that ES6-ified their code base. Update: I get past that error and get a new error when I change the exclude to catch more Webpack modules:
The new error is So then I broadened my excludes further (a separate Stack Overflow includes the idea of whitelisting regenerator-runtime too, so this makes sense to me):
Again, it gets me past an error, but I get a new one: module.exports = {
/**
* Prints to console using ES6 features (arrow function, const, string
* interpolation, spread syntax).
*/
print: () => {
const from = 'an arrow function in test-es6-library-dependency';
const to = 'console';
const msgObj = {
to: `the ${to}`,
...from,
};
console.log(msgObj);
},
}; (the first line is in my source map is where the error occurs apparently. with source maps disabled, Chrome can't bring me to the exact line that caused the error at runtime) So at this point, by broadening the Webpack excludes it looks like I've solved the problem with Babel transpiling things it shouldn't when |
Got it to work! My most recent issue was after I excluded enough from the Babel transform, the polyfills seemed to work, but then I wasn't getting some of my dependencies bundled in correctly. It kept the CommonJS export syntax. This is because I was a doing a thorough test, including the package I found that I had to add the line So for anyone struggling with this again, know that the solution (today, at least), is to have a wide exclude to protect the core-js polyfill and the build tools from transpilation, and to include the line |
@mattwelke thx for posting solution. It may be helpful for someone. |
Here is my case and solution:
{
test: /\.(jsjsx)$/,
exclude: function(modulePath) {
if (
/node_modules\/local-lib\/.test(
modulePath
) &&
// make sure to exclude node_modules inside the local lib module.
!/\blocal-lib\/node_modules\//.test(modulePath)
) {
return false;
}
return /(node_modules|bower_components)/.test(modulePath);
},
use: {
loader: "babel-loader",
},
}, This error happened because babel use the core-js from the local-lib node_modules, not the root project's. |
I'm building my TypeScript project using Webpack and Babel with
@babel/preset-env
:At runtime (with my Chrome browser) I get the following error:
With the exact same configuration switching from
useBuiltIns : "usage"
to"entry"
everything works perfectly 🤔I tried multiple versions of core-js v3.6.2, v3.6.0, v3.5.0 and v3.4.8 resulting with the same error.
But with core-js v3.6.1 I get a different runtime error:
The text was updated successfully, but these errors were encountered: