Skip to content
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

Unable to use 6.0.0-beta.6 with core-js #12358

Closed
2 of 7 tasks
ezze opened this issue Jun 9, 2020 · 4 comments · Fixed by #12475
Closed
2 of 7 tasks

Unable to use 6.0.0-beta.6 with core-js #12358

ezze opened this issue Jun 9, 2020 · 4 comments · Fixed by #12475
Labels
dependency For issues and PRs. Things that are related to one or more dependencies. released

Comments

@ezze
Copy link

ezze commented Jun 9, 2020

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.
@sushantdhiman sushantdhiman added the dependency For issues and PRs. Things that are related to one or more dependencies. label Jun 10, 2020
@sushantdhiman
Copy link
Contributor

sushantdhiman commented Jun 10, 2020

What we can do

  1. Use some alternative for _.isNative which is compatible for our use-case. We mainly want to prevent native toString overrides over custom defined toString. So some version of _.isNative which can tell if toString is native or not should work for our use-case.
  2. Ask core-js to support this detection OR lodash to don't throw.

I don't think (2) will work so a PR for (1) will be appreciated

@tpodom
Copy link
Contributor

tpodom commented 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:

> const baseIsNative = require('lodash/_baseIsNative')
[Function: baseIsNative]
> baseIsNative({})
false
> baseIsNative(function toString() {})
false
> baseIsNative({}.toString)
true

@sushantdhiman
Copy link
Contributor

That should work for our use-case

@sushantdhiman
Copy link
Contributor

🎉 This issue has been resolved in version 6.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency For issues and PRs. Things that are related to one or more dependencies. released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants