Skip to content

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

Closed

Description

@ezze

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

  1. added
    dependency
    on Jun 10, 2020
  2. sushantdhiman commented on Jun 10, 2020

    @sushantdhiman
    Contributor

    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

  3. tpodom commented on Jul 6, 2020

    @tpodom
    Contributor

    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
    
  4. sushantdhiman commented on Jul 7, 2020

    @sushantdhiman
    Contributor

    That should work for our use-case

  5. sushantdhiman commented on Jul 10, 2020

    @sushantdhiman
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependencyreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions