match-curriculum / node_modules / @babel / preset-react / lib / index.js.map
index.js.map
Raw
{"version":3,"file":"index.js","sources":["../src/normalize-options.ts","../src/index.ts"],"sourcesContent":["import {\n  OptionValidator,\n  findSuggestion,\n} from \"@babel/helper-validator-option\";\nconst v = new OptionValidator(\"@babel/preset-react\");\n\nexport default function normalizeOptions(options: any = {}) {\n  if (process.env.BABEL_8_BREAKING) {\n    if (\"useSpread\" in options) {\n      throw new Error(\n        '@babel/preset-react: Since Babel 8, an inline object with spread elements is always used, and the \"useSpread\" option is no longer available. Please remove it from your config.',\n      );\n    }\n\n    if (\"useBuiltIns\" in options) {\n      const useBuiltInsFormatted = JSON.stringify(options.useBuiltIns);\n      throw new Error(\n        `@babel/preset-react: Since \"useBuiltIns\" is removed in Babel 8, you can remove it from the config.\n- Babel 8 now transforms JSX spread to object spread. If you need to transpile object spread with\n\\`useBuiltIns: ${useBuiltInsFormatted}\\`, you can use the following config\n{\n  \"plugins\": [\n    [\"@babel/plugin-proposal-object-rest-spread\", { \"loose\": true, \"useBuiltIns\": ${useBuiltInsFormatted} }]\n  ],\n  \"presets\": [\"@babel/preset-react\"]\n}`,\n      );\n    }\n\n    const TopLevelOptions = {\n      development: \"development\",\n      importSource: \"importSource\",\n      pragma: \"pragma\",\n      pragmaFrag: \"pragmaFrag\",\n      pure: \"pure\",\n      runtime: \"runtime\",\n      throwIfNamespace: \"throwIfNamespace\",\n    };\n    v.validateTopLevelOptions(options, TopLevelOptions);\n    const development = v.validateBooleanOption(\n      TopLevelOptions.development,\n      options.development,\n      false,\n    );\n    let importSource = v.validateStringOption(\n      TopLevelOptions.importSource,\n      options.importSource,\n    );\n    let pragma = v.validateStringOption(TopLevelOptions.pragma, options.pragma);\n    let pragmaFrag = v.validateStringOption(\n      TopLevelOptions.pragmaFrag,\n      options.pragmaFrag,\n    );\n    const pure = v.validateBooleanOption(TopLevelOptions.pure, options.pure);\n    const runtime = v.validateStringOption(\n      TopLevelOptions.runtime,\n      options.runtime,\n      \"automatic\",\n    );\n    const throwIfNamespace = v.validateBooleanOption(\n      TopLevelOptions.throwIfNamespace,\n      options.throwIfNamespace,\n      true,\n    );\n\n    const validRuntime = [\"classic\", \"automatic\"];\n\n    if (runtime === \"classic\") {\n      pragma = pragma || \"React.createElement\";\n      pragmaFrag = pragmaFrag || \"React.Fragment\";\n    } else if (runtime === \"automatic\") {\n      importSource = importSource || \"react\";\n    } else {\n      throw new Error(\n        `@babel/preset-react: 'runtime' must be one of ['automatic', 'classic'] but we have '${runtime}'\\n` +\n          `- Did you mean '${findSuggestion(runtime, validRuntime)}'?`,\n      );\n    }\n\n    return {\n      development,\n      importSource,\n      pragma,\n      pragmaFrag,\n      pure,\n      runtime,\n      throwIfNamespace,\n    };\n  } else {\n    let { pragma, pragmaFrag } = options;\n\n    const {\n      pure,\n      throwIfNamespace = true,\n      runtime = \"classic\",\n      importSource,\n      useBuiltIns,\n      useSpread,\n    } = options;\n\n    if (runtime === \"classic\") {\n      pragma = pragma || \"React.createElement\";\n      pragmaFrag = pragmaFrag || \"React.Fragment\";\n    }\n\n    const development = !!options.development;\n\n    return {\n      development,\n      importSource,\n      pragma,\n      pragmaFrag,\n      pure,\n      runtime,\n      throwIfNamespace,\n      useBuiltIns,\n      useSpread,\n    };\n  }\n}\n","import { declarePreset } from \"@babel/helper-plugin-utils\";\nimport transformReactJSX from \"@babel/plugin-transform-react-jsx\";\nimport transformReactJSXDevelopment from \"@babel/plugin-transform-react-jsx-development\";\nimport transformReactDisplayName from \"@babel/plugin-transform-react-display-name\";\nimport transformReactPure from \"@babel/plugin-transform-react-pure-annotations\";\nimport normalizeOptions from \"./normalize-options\";\n\nexport interface Options {\n  development?: boolean;\n  importSource?: string;\n  pragma?: string;\n  pragmaFrag?: string;\n  pure?: string;\n  runtime?: \"automatic\" | \"classic\";\n  throwIfNamespace?: boolean;\n  useBuiltIns?: boolean;\n  useSpread?: boolean;\n}\n\nexport default declarePreset((api, opts: Options) => {\n  api.assertVersion(7);\n\n  const {\n    development,\n    importSource,\n    pragma,\n    pragmaFrag,\n    pure,\n    runtime,\n    throwIfNamespace,\n  } = normalizeOptions(opts);\n\n  return {\n    plugins: [\n      [\n        development ? transformReactJSXDevelopment : transformReactJSX,\n        process.env.BABEL_8_BREAKING\n          ? {\n              importSource,\n              pragma,\n              pragmaFrag,\n              runtime,\n              throwIfNamespace,\n              pure,\n            }\n          : {\n              importSource,\n              pragma,\n              pragmaFrag,\n              runtime,\n              throwIfNamespace,\n              pure,\n              useBuiltIns: !!opts.useBuiltIns,\n              useSpread: opts.useSpread,\n            },\n      ],\n      transformReactDisplayName,\n      pure !== false && transformReactPure,\n    ].filter(Boolean),\n  };\n});\n"],"names":["OptionValidator","normalizeOptions","options","pragma","pragmaFrag","pure","throwIfNamespace","runtime","importSource","useBuiltIns","useSpread","development","declarePreset","api","opts","assertVersion","plugins","transformReactJSXDevelopment","transformReactJSX","transformReactDisplayName","transformReactPure","filter","Boolean"],"mappings":";;;;;;;;;;;;;;;;;;AAIU,IAAIA,qCAAJ,CAAoB,qBAApB,EAAV;AAEe,SAASC,gBAAT,CAA0BC,OAAY,GAAG,EAAzC,EAA6C;AAkFnD,EAAA;IACL,IAAI;MAAEC,MAAF;AAAUC,MAAAA,UAAAA;AAAV,KAAA,GAAyBF,OAA7B,CAAA;IAEA,MAAM;MACJG,IADI;AAEJC,MAAAA,gBAAgB,GAAG,IAFf;AAGJC,MAAAA,OAAO,GAAG,SAHN;MAIJC,YAJI;MAKJC,WALI;AAMJC,MAAAA,SAAAA;AANI,KAAA,GAOFR,OAPJ,CAAA;;IASA,IAAIK,OAAO,KAAK,SAAhB,EAA2B;MACzBJ,MAAM,GAAGA,MAAM,IAAI,qBAAnB,CAAA;MACAC,UAAU,GAAGA,UAAU,IAAI,gBAA3B,CAAA;AACD,KAAA;;AAED,IAAA,MAAMO,WAAW,GAAG,CAAC,CAACT,OAAO,CAACS,WAA9B,CAAA;IAEA,OAAO;MACLA,WADK;MAELH,YAFK;MAGLL,MAHK;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