feat: refactoring project
This commit is contained in:
12
node_modules/babel-loader/lib/cache.js
generated
vendored
12
node_modules/babel-loader/lib/cache.js
generated
vendored
@@ -105,18 +105,24 @@ const handleCache = /*#__PURE__*/function () {
|
||||
options = {},
|
||||
cacheIdentifier,
|
||||
cacheDirectory,
|
||||
cacheCompression
|
||||
cacheCompression,
|
||||
logger
|
||||
} = params;
|
||||
const file = path.join(directory, filename(source, cacheIdentifier, options));
|
||||
try {
|
||||
// No errors mean that the file was previously cached
|
||||
// we just need to return it
|
||||
logger.debug(`reading cache file '${file}'`);
|
||||
return yield read(file, cacheCompression);
|
||||
} catch (err) {}
|
||||
} catch (err) {
|
||||
// conitnue if cache can't be read
|
||||
logger.debug(`discarded cache as it can not be read`);
|
||||
}
|
||||
const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir();
|
||||
|
||||
// Make sure the directory exists.
|
||||
try {
|
||||
logger.debug(`creating cache folder '${directory}'`);
|
||||
yield makeDir(directory);
|
||||
} catch (err) {
|
||||
if (fallback) {
|
||||
@@ -127,12 +133,14 @@ const handleCache = /*#__PURE__*/function () {
|
||||
|
||||
// Otherwise just transform the file
|
||||
// return it to the user asap and write it in cache
|
||||
logger.debug(`applying Babel transform`);
|
||||
const result = yield transform(source, options);
|
||||
|
||||
// Do not cache if there are external dependencies,
|
||||
// since they might change and we cannot control it.
|
||||
if (!result.externalDependencies.length) {
|
||||
try {
|
||||
logger.debug(`writing result to cache file '${file}'`);
|
||||
yield write(file, cacheCompression, result);
|
||||
} catch (err) {
|
||||
if (fallback) {
|
||||
|
||||
Reference in New Issue
Block a user