UNPKG

1.78 kBJavaScriptView Raw
1import _extends from '@babel/runtime/helpers/esm/extends';
2import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
3import jsx from '@babel/plugin-transform-react-jsx';
4import pragmatic from '@emotion/babel-plugin-jsx-pragmatic';
5import emotion from '@emotion/babel-plugin';
6
7var pragmaName = '___EmotionJSX'; // pull out the emotion options and pass everything else to the jsx transformer
8// this means if @babel/plugin-transform-react-jsx adds more options, it'll just work
9// and if @emotion/babel-plugin adds more options we can add them since this lives in
10// the same repo as @emotion/babel-plugin
11
12var index = (function (api, _temp) {
13 var _ref = _temp === void 0 ? {} : _temp,
14 pragma = _ref.pragma,
15 sourceMap = _ref.sourceMap,
16 autoLabel = _ref.autoLabel,
17 labelFormat = _ref.labelFormat,
18 importMap = _ref.importMap,
19 options = _objectWithoutPropertiesLoose(_ref, ["pragma", "sourceMap", "autoLabel", "labelFormat", "importMap"]);
20
21 if (options.runtime) {
22 throw new Error('The `runtime` option has been removed. If you want to configure `runtime: "automatic"`, replace `@emotion/babel-preset-css-prop` with `@babel/preset-react` and `@emotion/babel-plugin`. You can find out how to configure things properly here: https://emotion.sh/docs/css-prop#babel-preset');
23 }
24
25 return {
26 plugins: [[pragmatic, {
27 "export": 'jsx',
28 module: '@emotion/react',
29 "import": pragmaName
30 }], [jsx, _extends({
31 pragma: pragmaName,
32 pragmaFrag: 'React.Fragment'
33 }, options)], [emotion, {
34 sourceMap: sourceMap,
35 autoLabel: autoLabel,
36 labelFormat: labelFormat,
37 cssPropOptimization: true,
38 importMap: importMap
39 }]]
40 };
41});
42
43export default index;