50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import { declare } from "@babel/helper-plugin-utils";
|
|
import transformReactJSX from "@babel/plugin-transform-react-jsx";
|
|
import transformReactJSXDevelopment from "@babel/plugin-transform-react-jsx-development";
|
|
import transformReactDisplayName from "@babel/plugin-transform-react-display-name";
|
|
import transformReactPure from "@babel/plugin-transform-react-pure-annotations";
|
|
import normalizeOptions from "./normalize-options";
|
|
|
|
export default declare((api, opts) => {
|
|
api.assertVersion(7);
|
|
|
|
const {
|
|
development,
|
|
importSource,
|
|
pragma,
|
|
pragmaFrag,
|
|
pure,
|
|
runtime,
|
|
throwIfNamespace,
|
|
} = normalizeOptions(opts);
|
|
|
|
return {
|
|
plugins: [
|
|
[
|
|
development ? transformReactJSXDevelopment : transformReactJSX,
|
|
process.env.BABEL_8_BREAKING
|
|
? {
|
|
importSource,
|
|
pragma,
|
|
pragmaFrag,
|
|
runtime,
|
|
throwIfNamespace,
|
|
pure,
|
|
}
|
|
: {
|
|
importSource,
|
|
pragma,
|
|
pragmaFrag,
|
|
runtime,
|
|
throwIfNamespace,
|
|
pure,
|
|
useBuiltIns: !!opts.useBuiltIns,
|
|
useSpread: opts.useSpread,
|
|
},
|
|
],
|
|
transformReactDisplayName,
|
|
pure !== false && transformReactPure,
|
|
].filter(Boolean),
|
|
};
|
|
});
|