babel-merge icon indicating copy to clipboard operation
babel-merge copied to clipboard

[Feature Request] Handle the scene that a plugin/preset with explicit name can be used multiple times.

Open ulivz opened this issue 5 years ago • 1 comments

Feature Request

A plugin / preset can be applied multiple times when the 3rd parameter(i.e. "name", refs.) of a config item is given.

Repro Example

const merge = require('babel-merge');

const together = merge(
  {
    plugins: [
      ["import", { "libraryName": "antd", "libraryDirectory": "lib" }, "ant" /* name */],
    ]
  },
  {
    plugins: [
      ["import", { "libraryName": "antd-mobile", "libraryDirectory": "lib" }, "antd-mobile" /* name */]
    ]
  }
)

console.log(together)

Expected behaviors

{
    plugins: [
      ["/path/to/babel-plugin-import", { "libraryName": "antd", "libraryDirectory": "lib" }, "ant"],
      ["/path/to/babel-plugin-import", { "libraryName": "antd-mobile", "libraryDirectory": "lib" }, "antd-mobile"]
    ]
}

Actual behaviors

{
    plugins: [
        ["/path/to/babel-plugin-import", { "libraryName": "antd-mobile", "libraryDirectory": "lib" }, "antd-mobile"]
    ]
}

ulivz avatar Dec 23 '19 09:12 ulivz

Hi! Thank you for filing this issue. I agree this is a bug. Would you be open to creating a PR for it? :-)

edmorley avatar Dec 29 '19 16:12 edmorley