Repository navigation
Description
Issue Description
I'm using Webpack with core-js polyfill in my Node.js project relying on Sequelize library. I decided to make an earlier migration from Sequelize 5 to Sequelize 6 but was unable to make it working to due this error:
/home/ezze/Development/geobase/node_modules/lodash/lodash.js:11927
throw new Error(CORE_ERROR_TEXT);
^
Error: Unsupported core-js use. Try https://npms.io/search?q=ponyfill.
at Function.isNative (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:11927:15)
at _.mergeWith (/home/ezze/Development/geobase/node_modules/sequelize/lib/utils.js:54:42)
at baseMergeDeep (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3643:11)
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:3603:11
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:4905:15
at baseMerge (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3600:7)
at baseMergeDeep (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3689:9)
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:3603:11
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:4905:15
at baseMerge (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3600:7)
at baseMergeDeep (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3689:9)
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:3603:11
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:4905:15
at baseMerge (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3600:7)
at baseMergeDeep (/home/ezze/Development/geobase/node_modules/lodash/lodash.js:3689:9)
at /home/ezze/Development/geobase/node_modules/lodash/lodash.js:3603:11
What are you doing?
Upgrading Sequelize 5 => 6. I narrowed down the problem and created a repo to reproduce it. The issue is caused by _.isNative() function that is incompatible with core-js and is used by mergeDefaults utility function of Sequelize.
This method can't reliably detect native functions in the presence of the core-js package because core-js circumvents this kind of detection. Despite multiple requests, the core-js maintainer has made it clear: any attempt to fix the detection will be obstructed. As a result, we're left with little choice but to throw an error. Unfortunately, this also affects packages, like babel-polyfill, which rely on core-js.
What do you expect to happen?
The code working in Sequelize 5 to work in Sequelize 6.
What is actually happening?
An error
Error: Unsupported core-js use. Try https://npms.io/search?q=ponyfill.
is thrown.
Environment
- Sequelize version: 6.0.0-beta.6
- Node.js version: 10.21.0
- Operating System: Ubuntu 18.04 LTS
How does this problem relate to dialects?
- I think this problem happens regardless of the dialect.
- I think this problem happens only for the following dialect(s):
- I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
- Yes, I have the time but I don't know how to start, I would need guidance.
- No, I don't have the time, although I believe I could do it if I had the time...
- No, I don't have the time and I wouldn't even know how to start.
Activity
sushantdhiman commentedon Jun 10, 2020
What we can do
_.isNativewhich is compatible for our use-case. We mainly want to prevent nativetoStringoverrides over custom definedtoString. So some version of_.isNativewhich can tell iftoStringis native or not should work for our use-case.core-jsto support this detection ORlodashto don't throw.I don't think
(2)will work so a PR for(1)will be appreciatedtpodom commentedon Jul 6, 2020
I also ran into this due to Apollo GraphQL utilizing core-js to shim Array.flatMap and a couple of other items. From what I can tell from the Lodash is they attempted to resolve this with the core-js team and reached a stalemate: https://github.com/lodash/lodash/blob/4.17.15-npm/isNative.js#L8
One option is to require _baseIsNative directly which bypasses the core-js detection. What do you think about that option? Here's an example:
sushantdhiman commentedon Jul 7, 2020
That should work for our use-case
fix: use lodash _baseIsNative directly instead of _.isNative (#12358) (…
fix: use lodash _baseIsNative directly instead of _.isNative (sequeli…
fix: use lodash _baseIsNative directly instead of _.isNative (#12358) (…
sushantdhiman commentedon Jul 10, 2020
🎉 This issue has been resolved in version 6.3.1 🎉
The release is available on:
Your semantic-release bot 📦🚀