@hh.ru/babel-plugin-static-value-extractor
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -86,5 +86,20 @@ "use strict"; | ||
var invalidateFileCache = function invalidateFileCache(filePath, staleCacheEntriesSet) { | ||
var cacheEntry = cachedFiles[filePath]; | ||
cacheEntry.importsDeclarations.forEach(function (file) { | ||
if (cachedFiles[file] && cachedFiles[file].reverseImports) { | ||
cachedFiles[file].reverseImports = cachedFiles[file].reverseImports.filter(function (file) { | ||
return file !== filePath; | ||
}); | ||
} | ||
}); | ||
cacheEntry.reverseImports && cacheEntry.reverseImports.forEach(function (file) { | ||
return staleCacheEntriesSet.add(file); | ||
}); | ||
staleCacheEntriesSet.add(filePath); | ||
}; | ||
var prepareCache = function prepareCache(opts) { | ||
var basePath = opts.basePath; | ||
var invalidFiles = new Set(); | ||
var changedFiles = []; | ||
Object.keys(cachedFiles).forEach(function (filePath) { | ||
@@ -96,27 +111,15 @@ var cachedMtime = cachedFiles[filePath].cachedMtime; | ||
if (!_fs["default"].existsSync(fullPath) || cachedMtime !== _fs["default"].statSync(fullPath).mtimeMs) { | ||
invalidFiles.add(filePath); | ||
changedFiles.push(filePath); | ||
} | ||
}); | ||
var invalidPageComponents = []; | ||
invalidFiles.forEach(function (filePath) { | ||
cachedFiles[filePath].importsDeclarations.forEach(function (file) { | ||
if (cachedFiles[file] && cachedFiles[file].reverseImports) { | ||
cachedFiles[file].reverseImports = cachedFiles[file].reverseImports.filter(function (file) { | ||
return file !== filePath; | ||
}); | ||
} | ||
}); | ||
invalidPageComponents.push.apply(invalidPageComponents, _toConsumableArray(traceToPageComponent(filePath))); | ||
var staleCacheEntries = new Set(); | ||
var changedPageComponents = []; | ||
changedFiles.forEach(function (filePath) { | ||
invalidateFileCache(filePath, staleCacheEntries); | ||
changedPageComponents.push.apply(changedPageComponents, _toConsumableArray(traceToPageComponent(filePath))); | ||
}); | ||
new Set(invalidPageComponents).forEach(function (filePath) { | ||
cachedFiles[filePath].importsDeclarations.forEach(function (file) { | ||
if (cachedFiles[file] && cachedFiles[file].reverseImports) { | ||
cachedFiles[file].reverseImports = cachedFiles[file].reverseImports.filter(function (file) { | ||
return file !== filePath; | ||
}); | ||
} | ||
}); | ||
delete cachedFiles[filePath]; | ||
new Set(changedPageComponents).forEach(function (filePath) { | ||
return invalidateFileCache(filePath, staleCacheEntries); | ||
}); | ||
invalidFiles.forEach(function (filePath) { | ||
staleCacheEntries.forEach(function (filePath) { | ||
return delete cachedFiles[filePath]; | ||
@@ -190,13 +193,8 @@ }); | ||
if (!cachedFiles[topLevelFile]) { | ||
var _fs$statSync2 = _fs["default"].statSync(topLevelFile), | ||
mtimeMs = _fs$statSync2.mtimeMs; | ||
_extractStaticValueImportedFilesFromFile(topLevelFile, opts); | ||
cachedFiles[topLevelFile] = { | ||
cachedMtime: mtimeMs, | ||
cachedFiles[topLevelFile] = _objectSpread({}, cachedFiles[topLevelFile], { | ||
propsList: staticPropsList, | ||
importsDeclarations: [], | ||
reverseImports: null | ||
}; | ||
}); | ||
} | ||
@@ -203,0 +201,0 @@ |
{ | ||
"name": "@hh.ru/babel-plugin-static-value-extractor", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30191
501