GT2/Ejectable/node_modules/@expo/metro-config/build/metro-expo-babel-transforme...

1 line
3.4 KiB
Plaintext
Raw Normal View History

2021-08-16 00:14:59 +00:00
{"version":3,"file":"metro-expo-babel-transformer.js","sourceRoot":"","sources":["../src/metro-expo-babel-transformer.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,2BAAkC;AAClC,gEAAuC;AAEvC,MAAM,aAAa,GAAG;IACpB,iBAAY,CAAC,UAAU,CAAC;IACxB,oEAAoE;IACpE,sEAAsE;IACtE,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,OAAO;IACnD,uDAAuD;CACxD,CAAC;AAEF,IAAI,WAAW,GAAQ,IAAI,CAAC;AAE5B,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,IAAI,WAAW,EAAE;QACf,OAAO,WAAW,CAAC;KACpB;IACD,MAAM,YAAY,GAAG,sBAAW,CAAC,MAAM,CAAC,WAAW,EAAE,sCAAsC,CAAC,CAAC;IAC7F,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CACb,yEAAyE;YACvE,sDAAsD;YACtD,yEAAyE;YACzE,kCAAkC,CACrC,CAAC;KACH;IACD,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,SAAS,CAAC,KAKlB;IACC,mDAAmD;IACnD,KAAK,CAAC,OAAO,CAAC,sBAAsB,GAAG,sBAAW,CAAC,MAAM,CACvD,KAAK,CAAC,OAAO,CAAC,WAAW,EACzB,mBAAmB,CACpB,CAAC;IACF,OAAO,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED,mBAAmB;AACnB,SAAS,WAAW;IAClB,MAAM,GAAG,GAAG,gBAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,WAAW;IACX,SAAS;CACV,CAAC","sourcesContent":["import crypto from 'crypto';\nimport { readFileSync } from 'fs';\nimport resolveFrom from 'resolve-from';\n\nconst cacheKeyParts = [\n readFileSync(__filename),\n // Since babel-preset-fbjs cannot be safely resolved relative to the\n // project root, use this environment variable that we define earlier.\n process.env.EXPO_METRO_CACHE_KEY_VERSION || '3.3.0',\n // require('babel-preset-fbjs/package.json').version,\n];\n\nlet transformer: any = null;\n\nfunction resolveTransformer(projectRoot: string) {\n if (transformer) {\n return transformer;\n }\n const resolvedPath = resolveFrom.silent(projectRoot, 'metro-react-native-babel-transformer');\n if (!resolvedPath) {\n throw new Error(\n 'Missing package \"metro-react-native-babel-transformer\" in the project. ' +\n 'This usually means `react-native` is not installed. ' +\n 'Please verify that dependencies in package.json include \"react-native\" ' +\n 'and run `yarn` or `npm install`.'\n );\n }\n transformer = require(resolvedPath);\n return transformer;\n}\n\n/**\n * Extends the default `metro-react-native-babel-transformer`\n * and uses babel-preset-expo as the default instead of metro-react-native-babel-preset.\n * This enables users to safely transpile an Expo project without\n * needing to explicitly define a `babel.config.js`\n *\n * @param filename string\n * @param options BabelTransformerOptions\n * @param plugins $PropertyType<BabelCoreOptions, 'plugins'>\n * @param src string\n *\n * @returns\n */\nfunction transform(props: {\n filename: string;\n options: Record<string, any> & { projectRoot: string };\n plugins?: unknown;\n src: string;\n}) {\n // Use babel-preset-expo by default if available...\n props.options.extendsBabelConfigPath = resolveFrom.silent(\n props.options.projectRoot,\n 'babel-preset-expo'\n );\n return resolveTransformer(props.options.projectRoot).transform(props);\n}\n\n// Matches upstream\nfunction getCacheKey(): string {\n const key = crypto.createHash('md5');\n cacheKeyParts.forEach(part => key.update(part));\n return key.digest('hex');\n}\n\nmodule.exports = {\n getCacheKey,\n transform,\n};\n"]}