amis-rpc-design/node_modules/@babel/register/lib/worker/cache.js.map

1 line
6.5 KiB
Plaintext
Raw Normal View History

2023-10-07 19:42:30 +08:00
{"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,I