Skip to content

dva-core CJS build relies on a regeneratorRuntime global, but it isn't defined #2493

@nicolo-ribaudo

Description

@nicolo-ribaudo

What happens?

(cross-posting from babel/babel#14568 (comment))

At line 445 of https://unpkg.com/browse/dva-core@2.0.4/dist/index.js, dva-core uses the regeneratorRuntime global (which is injected by Babel). However, that global variable is not defined anywhere.

There are three possible fixes:

  1. Add require("regenerator-runtime"), which defines the global regeneratorRuntime variable so that it can be used
  2. Use @babel/plugin-transform-runtime to inject the necessary @babel/runtime imports
  3. Update @babel/core and @babel/plugin-transform-regenerator to ^7.18.0, so that the compiled output doesn't rely on a regeneratorRuntime global anymore.

Surprisingly, the ESM build already follows the 2nd solution and thus isn't affected by this bug. You can see at line 316 of https://unpkg.com/browse/dva-core@2.0.4/dist/index.esm.js that it uses the local _regeneratorRuntime variable, imported at line 17.

Mini Showcase Repository(REQUIRED)

babel/babel#14568 (comment)

Context

  • Dva Version: 2.0.4
  • Node Version: doesn't matter
  • Platform: doesn't matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions