Babel-preset-env about configuration item modlues

A plug-in is referenced in the

project, because the plug-in has already been compiled through babel, but Object.entries has not been compiled, so you need to compile it yourself through babel.

// .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"
    ]
}

result error exports is not defined

// 

"use strict";

Object.defineProperty(exports, "__esModule", {
    value: true
});
....

then I put the modules in the env configuration item in .babelrc , and the project can run normally.

the modules configuration item is about converting the source code into other specifications, and there is no problem with why you go to this configuration.

Feb.28,2021
Menu