{"version":3,"names":["asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","done","Promise","then","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","cloneDeep","require","path","fs","babel","registerCache","nmRE","escapeRegExp","sep","string","replace","cache","transformOpts","exports","setOptions","opts","clear","load","get","extensions","Object","assign","caller","name","cwd","ignore","only","cwdRE","RegExp","transform","input","filename","loadOptionsAsync","sourceRoot","dirname","cached","store","cacheLookup","code","map","transformAsync","sourceMaps","ast","transformSync","OptionManager","init","id","cacheKey","JSON","stringify","version","env","getEnv","fileMtime","statSync","mtime","setDirty"],"sources":["../../src/worker/transform.js"],"sourcesContent":["\"use strict\";\n\nconst cloneDeep = require(\"clone-deep\");\nconst path = require(\"path\");\nconst fs = require(\"fs\");\n\nconst babel = require(\"./babel-core.js\");\nconst registerCache = require(\"../cache.js\");\n\nconst nmRE = escapeRegExp(path.sep + \"node_modules\" + path.sep);\n\nfunction escapeRegExp(string) {\n return string.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\");\n}\n\nlet cache;\nlet transformOpts;\nexports.setOptions = function (opts) {\n if (opts.cache === false && cache) {\n registerCache.clear();\n cache = null;\n } else if (opts.cache !== false && !cache) {\n registerCache.load();\n cache = registerCache.get();\n }\n\n delete opts.cache;\n delete opts.extensions;\n\n transformOpts = {\n ...opts,\n caller: {\n name: \"@babel/register\",\n ...(opts.caller || {}),\n },\n };\n\n let { cwd = \".\" } = transformOpts;\n\n // Ensure that the working directory is resolved up front so that\n // things don't break if it changes later.\n cwd = transformOpts.cwd = path.resolve(cwd);\n\n if (transformOpts.ignore === undefined && transformOpts.only === undefined) {\n const cwdRE = escapeRegExp(cwd);\n\n // Only compile things inside the current working directory.\n transformOpts.only = [new RegExp(\"^\" + cwdRE, \"i\")];\n // Ignore any node_modules inside the current working directory.\n transformOpts.ignore = [\n new RegExp(`^${cwdRE}(?:${path.sep}.*)?${nmRE}`, \"i\"),\n ];\n }\n};\n\nexports.transform = async function (input, filename) {\n const opts = await babel.loadOptionsAsync({\n // sourceRoot can be overwritten\n sourceRoot: path.dirname(filename) + path.sep,\n ...cloneDeep(transformOpts),\n filename,\n });\n\n // Bail out ASAP if the file has been ignored.\n if (opts === null) return null;\n\n const { cached, store } = cacheLookup(opts, filename);\n if (cached) return cached;\n\n const { code, map } = await babel.transformAsync(input, {\n ...opts,\n sourceMaps: opts.sourceMaps === undefined ? \"both\" : opts.sourceMaps,\n ast: false,\n });\n\n return store({ code, map });\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n exports.transformSync = function (input, filename) {\n const opts = new babel.OptionManager().init({\n // sourceRoot can be overwritten\n sourceRoot: path.dirname(filename) + path.sep,\n ...cloneDeep(transformOpts),\n filename,\n });\n\n // Bail out ASAP if the file has been ignored.\n if (opts === null) return null;\n\n const { cached, store } = cacheLookup(opts, filename);\n if (cached) return cached;\n\n const { code, map } = babel.transformSync(input, {\n ...opts,\n sourceMaps: opts.sourceMaps === undefined ? \"both\" : opts.sourceMaps,\n ast: false,\n });\n\n return store({ code, map });\n };\n}\n\nconst id = value => value;\n\nfunction cacheLookup(opts, filename) {\n if (!cache) return { cached: null, store: id };\n\n let cacheKey = `${JSON.stringify(opts)}:${babel.version}`;\n\n const env = babel.getEnv();\n if (env) cacheKey += `:${env}`;\n\n const cached = cache[cacheKey];\n const fileMtime = +fs.statSync(filename).mtime;\n\n if (cached && cached.mtime === fileMtime) {\n return { cached: cached.value, store: id };\n }\n\n return {\n cached: null,\n store(value) {\n cache[cacheKey] = { value, mtime: fileMtime };\n registerCache.setDirty();\n return value;\n },\n };\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,mBAAAC,GAAA,EAAAC,OAAA,EAAAC,MAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,GAAA,EAAAC,GAAA,cAAAC,IAAA,GAAAP,GAAA,CAAAK,GAAA,EAAAC,GAAA,OAAAE,KAAA,GAAAD,IAAA,CAAAC,KAAA,WAAAC,KAAA,IAAAP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