index.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var helperPluginUtils = require('@babel/helper-plugin-utils');
  4. var transformReactJSX = require('@babel/plugin-transform-react-jsx');
  5. var transformReactJSXDevelopment = require('@babel/plugin-transform-react-jsx-development');
  6. var transformReactDisplayName = require('@babel/plugin-transform-react-display-name');
  7. var transformReactPure = require('@babel/plugin-transform-react-pure-annotations');
  8. var helperValidatorOption = require('@babel/helper-validator-option');
  9. function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
  10. var transformReactJSX__default = /*#__PURE__*/_interopDefault(transformReactJSX);
  11. var transformReactJSXDevelopment__default = /*#__PURE__*/_interopDefault(transformReactJSXDevelopment);
  12. var transformReactDisplayName__default = /*#__PURE__*/_interopDefault(transformReactDisplayName);
  13. var transformReactPure__default = /*#__PURE__*/_interopDefault(transformReactPure);
  14. new helperValidatorOption.OptionValidator("@babel/preset-react");
  15. function normalizeOptions(options = {}) {
  16. {
  17. let {
  18. pragma,
  19. pragmaFrag
  20. } = options;
  21. const {
  22. pure,
  23. throwIfNamespace = true,
  24. runtime = "classic",
  25. importSource,
  26. useBuiltIns,
  27. useSpread
  28. } = options;
  29. if (runtime === "classic") {
  30. pragma = pragma || "React.createElement";
  31. pragmaFrag = pragmaFrag || "React.Fragment";
  32. }
  33. const development = !!options.development;
  34. return {
  35. development,
  36. importSource,
  37. pragma,
  38. pragmaFrag,
  39. pure,
  40. runtime,
  41. throwIfNamespace,
  42. useBuiltIns,
  43. useSpread
  44. };
  45. }
  46. }
  47. var index = helperPluginUtils.declarePreset((api, opts) => {
  48. api.assertVersion(7);
  49. const {
  50. development,
  51. importSource,
  52. pragma,
  53. pragmaFrag,
  54. pure,
  55. runtime,
  56. throwIfNamespace
  57. } = normalizeOptions(opts);
  58. return {
  59. plugins: [[development ? transformReactJSXDevelopment__default.default : transformReactJSX__default.default, {
  60. importSource,
  61. pragma,
  62. pragmaFrag,
  63. runtime,
  64. throwIfNamespace,
  65. pure,
  66. useBuiltIns: !!opts.useBuiltIns,
  67. useSpread: opts.useSpread
  68. }], transformReactDisplayName__default.default, pure !== false && transformReactPure__default.default].filter(Boolean)
  69. };
  70. });
  71. exports.default = index;
  72. //# sourceMappingURL=index.js.map