开发者

How to pass options to babel plugin transform-modules-commonjs?

I create a Vue 2 project by Vue-Cli 5, then I want to remove "use strick" in the complied code.

As I Know, the @babel/plugin-transform-strick-mode may be enabled via @babel/plugin-transform-modules-commonjs, and the plugin is included in @babel/preset-env under the modules option.

But the Vue-Cli used a preset @vue/babel-preset-app by a plugin @vue/cli-plugin-babel for babel.

So my question is How pass strictMode: false as an option to the transform-modules-commonjs by @vue/babel-preset-app which preset is in the @vue/cli-plugin-babel ?

module.exports = {
  presets: [["@vue/cli-plugin-babel/preset", { modules: "auto" }]],
  plugins: [
    // I tried this way, but it throw many errors like:
    /**
ERROR in ./node_modules/axios/d开发者_开发问答ist/node/axios.cjs 11:15-32
Module not found: Error: Can't resolve 'stream' in 'D:\workspace\cqset_offical_website\node_modules\axios\dist\node'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
     */
    ["@babel/plugin-transform-modules-commonjs", {}],
    [
      "component",
      {
        libraryName: "element-ui",
        styleLibraryName: "theme-chalk",
      },
    ],
  ],
};

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜