Open nicolo-ribaudo opened 2 years ago
I tried understanding your build process and this might be a bug with https://github.com/umijs/father, but I cannot find where it's configured for this repository :sweat_smile:
EDIT: Yes, this is a bug with father-build
: it explicitly ignores the runtimeHelpers
option (that you correctly configured in packages/dva-core/.fatherrc.js
) when compiling CJS: https://github.com/umijs/father/blob/2be23ea5198d00b98ad67e92b6b92583a91353d7/packages/father-build/src/getRollupConfig.ts#L79
You could either choose solution (1) or (3), or we could repost this bug in 'father-build` so that (2) works for CJS as it does for ESM.
What happens?
(cross-posting from https://github.com/babel/babel/issues/14568#issuecomment-1133589525)
At line 445 of https://unpkg.com/browse/dva-core@2.0.4/dist/index.js,
dva-core
uses theregeneratorRuntime
global (which is injected by Babel). However, that global variable is not defined anywhere.There are three possible fixes:
require("regenerator-runtime")
, which defines the globalregeneratorRuntime
variable so that it can be used@babel/plugin-transform-runtime
to inject the necessary@babel/runtime
imports@babel/core
and@babel/plugin-transform-regenerator
to ^7.18.0, so that the compiled output doesn't rely on aregeneratorRuntime
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)
https://github.com/babel/babel/issues/14568#issuecomment-1133184851=
Context