UNPKG

1.81 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 _excluded = ["pragma", "sourceMap", "autoLabel", "labelFormat", "importMap"];
8var pragmaName = '___EmotionJSX'; // pull out the emotion options and pass everything else to the jsx transformer
9// this means if @babel/plugin-transform-react-jsx adds more options, it'll just work
10// and if @emotion/babel-plugin adds more options we can add them since this lives in
11// the same repo as @emotion/babel-plugin
12
13var index = (function (api, _temp) {
14 var _ref = _temp === void 0 ? {} : _temp;
15 _ref.pragma;
16 var sourceMap = _ref.sourceMap,
17 autoLabel = _ref.autoLabel,
18 labelFormat = _ref.labelFormat,
19 importMap = _ref.importMap,
20 options = _objectWithoutPropertiesLoose(_ref, _excluded);
21
22 if (options.runtime) {
23 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');
24 }
25
26 return {
27 plugins: [[pragmatic, {
28 "export": 'jsx',
29 module: '@emotion/react',
30 "import": pragmaName
31 }], [jsx, _extends({
32 pragma: pragmaName,
33 pragmaFrag: 'React.Fragment'
34 }, options)], [emotion, {
35 sourceMap: sourceMap,
36 autoLabel: autoLabel,
37 labelFormat: labelFormat,
38 cssPropOptimization: true,
39 importMap: importMap
40 }]]
41 };
42});
43
44export { index as default };