Calling Object.entries, within the plug-in reports an error in the project.

The

project has a reference to a plug-in plugin , and Object.entries

is called in the plug-in.
// index.js
import Plugin from "plugin";

xxx...



// .babelrc
{
    "presets": [
        ["env", {
            "modules": false,
            "targets": {
                "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
            }
        }],
        "stage-0"
    ],
    "plugins": [
        "transform-vue-jsx",
        "transform-runtime",
        "syntax-dynamic-import",
        "transform-runtime"
    ]
}

result: Object.entries is no function.

then I add

to webpack.config.js
...
{
    test: /\.js$/,
    loader: "babel-loader",
    include: [resolve("src"), resolve("node_modules/plugin")]
}
...

result error exports is not defined

question:

  1. what"s wrong?
  2. does Object.entries need to add polyfills
Feb.27,2021

this is a function added to the class. You need to add


of polyfill. I can go to "modules: false" in babel-preset-env . I don't quite understand why

Menu