amis-rpc-design/node_modules/@babel/register/lib/worker/cache.js.map
2023-10-07 19:42:30 +08:00

1 line
6.5 KiB
Plaintext

{"version":3,"names":["path","require","fs","os","findCacheDir","FILENAME","process","env","BABEL_CACHE_PATH","exports","initializeCacheFilename","join","name","homedir","tmpdir","babel","version","getEnv","data","cacheDirty","cacheDisabled","isCacheDisabled","_process$env$BABEL_DI","BABEL_DISABLE_CACHE","save","serialised","JSON","stringify","err","message","console","error","stack","v","w","split","versions","node","mkdirSync","sync","dirname","recursive","writeFileSync","e","code","warn","load","on","nextTick","cacheContent","readFileSync","parse","_unused","get","setDirty","clear"],"sources":["../../src/worker/cache.js"],"sourcesContent":["\"use strict\";\n\nconst path = require(\"path\");\nconst fs = require(\"fs\");\nconst os = require(\"os\");\nconst findCacheDir = require(\"find-cache-dir\");\n\nlet FILENAME = process.env.BABEL_CACHE_PATH;\n\n// This function needs to be exported before requiring ./babel-core, because\n// there is a circular dependency between these two files.\nexports.initializeCacheFilename = function () {\n FILENAME ||= path.join(\n findCacheDir({ name: \"@babel/register\" }) || os.homedir() || os.tmpdir(),\n `.babel.${babel.version}.${babel.getEnv()}.json`,\n );\n};\n\nconst babel = require(\"./babel-core.js\");\n\nlet data = {};\n\nlet cacheDirty = false;\n\nlet cacheDisabled = false;\n\nfunction isCacheDisabled() {\n return process.env.BABEL_DISABLE_CACHE ?? cacheDisabled;\n}\n\nexports.save = save;\n/**\n * Write stringified cache to disk.\n */\nfunction save() {\n if (isCacheDisabled() || !cacheDirty) return;\n cacheDirty = false;\n\n let serialised = \"{}\";\n\n try {\n serialised = JSON.stringify(data);\n } catch (err) {\n if (err.message === \"Invalid string length\") {\n err.message = \"Cache too large so it's been cleared.\";\n console.error(err.stack);\n } else {\n throw err;\n }\n }\n\n try {\n fs.mkdirSync(path.dirname(FILENAME), { recursive: true });\n fs.writeFileSync(FILENAME, serialised);\n } catch (e) {\n switch (e.code) {\n // workaround https://github.com/nodejs/node/issues/31481\n // todo: remove the ENOENT error check when we drop node.js 13 support\n case \"ENOENT\":\n case \"EACCES\":\n case \"EPERM\":\n console.warn(\n `Babel could not write cache to file: ${FILENAME}\ndue to a permission issue. Cache is disabled.`,\n );\n cacheDisabled = true;\n break;\n case \"EROFS\":\n console.warn(\n `Babel could not write cache to file: ${FILENAME}\nbecause it resides in a readonly filesystem. Cache is disabled.`,\n );\n cacheDisabled = true;\n break;\n default:\n throw e;\n }\n }\n}\n\n/**\n * Load cache from disk and parse.\n */\n\nexports.load = function load() {\n if (isCacheDisabled()) {\n data = {};\n return;\n }\n\n process.on(\"exit\", save);\n process.nextTick(save);\n\n let cacheContent;\n\n try {\n cacheContent = fs.readFileSync(FILENAME);\n } catch (e) {\n switch (e.code) {\n // check EACCES only as fs.readFileSync will never throw EPERM on Windows\n // https://github.com/libuv/libuv/blob/076df64dbbda4320f93375913a728efc40e12d37/src/win/fs.c#L735\n case \"EACCES\":\n console.warn(\n `Babel could not read cache file: ${FILENAME}\ndue to a permission issue. Cache is disabled.`,\n );\n cacheDisabled = true;\n /* fall through */\n default:\n return;\n }\n }\n\n try {\n data = JSON.parse(cacheContent);\n } catch {}\n};\n\n/**\n * Retrieve data from cache.\n */\nexports.get = function get() {\n return data;\n};\n\n/**\n * Set the cache dirty bit.\n */\nexports.setDirty = function setDirty() {\n cacheDirty = true;\n};\n\n/**\n * Clear the cache object.\n */\nexports.clear = function clear() {\n data = {};\n};\n"],"mappings":"AAAA,YAAY;;AAEZ,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMC,EAAE,GAAGD,OAAO,CAAC,IAAI,CAAC;AACxB,MAAME,EAAE,GAAGF,OAAO,CAAC,IAAI,CAAC;AACxB,MAAMG,YAAY,GAAGH,OAAO,CAAC,gBAAgB,CAAC;AAE9C,IAAII,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,gBAAgB;AAI3CC,OAAO,CAACC,uBAAuB,GAAG,YAAY;EAC5CL,QAAQ,KAARA,QAAQ,GAAKL,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