node_modules icon indicating copy to clipboard operation
node_modules copied to clipboard

Function option not working

Open nmattela opened this issue 5 years ago • 1 comments

Either I'm reading the documentation wrong, or setting "function": "myFunctionName" in the options object does not change the called function from the default _jsx to myFunctionName. Below is the content of my .babelrc file:

{
  "plugins": [
    ["babel-plugin-transform-jsx", {
      "useVariables": true,
      "function": "myFunctionName",
      "module": "myModule"
    }]
  ]
}

Which compiles some simple JSX such as <h1>Hello World</h1> to:

import _jsx from "myModule";

_jsx({
  elementName: "h1",
  attributes: {},
  children: ["Hello World"]
});

I would have expected the _jsx to be renamed to myFunctionName, which does not seem to be the case.

nmattela avatar Feb 16 '20 11:02 nmattela

I found the issue: you cannot use the "module" and "function" option together

nmattela avatar Mar 03 '20 09:03 nmattela