@hh.ru/babel-plugin-static-value-extractor
Advanced tools
Comparing version 0.4.1 to 0.5.0
@@ -69,3 +69,3 @@ 'use strict'; | ||
extractStaticValueFromCode(_fs2.default.readFileSync(file, ENCODING), _extends({}, opts, { | ||
extractStaticValueFromCode(_fs2.default.readFileSync(file), _extends({}, opts, { | ||
filename: file | ||
@@ -75,2 +75,4 @@ }), cb); | ||
var cachedFiles = {}; | ||
var extractStaticValueImportedFilesFromFile = exports.extractStaticValueImportedFilesFromFile = function extractStaticValueImportedFilesFromFile(file) { | ||
@@ -80,3 +82,2 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var cachedFiles = {}; | ||
var staticPropsList = []; | ||
@@ -87,4 +88,11 @@ | ||
if (opts.include && !opts.include.find(function (includePath) { | ||
return file.search(includePath) !== -1; | ||
})) { | ||
return; | ||
} | ||
extractStaticValueFromFile(file, opts, function (_staticPropsList, _importsDeclarations) { | ||
staticPropsList = staticPropsList.concat(_staticPropsList); | ||
cachedFiles[file] = _staticPropsList; | ||
importsDeclarations = _importsDeclarations; | ||
@@ -96,3 +104,4 @@ }); | ||
_extractStaticValueImportedFilesFromFile(file, opts, staticPropsList); | ||
cachedFiles[file] = true; | ||
} else { | ||
staticPropsList = staticPropsList.concat(cachedFiles[file]); | ||
} | ||
@@ -102,4 +111,11 @@ }); | ||
_extractStaticValueImportedFilesFromFile(file, opts); | ||
if (cachedFiles[file]) { | ||
staticPropsList = cachedFiles[file]; | ||
} else { | ||
_extractStaticValueImportedFilesFromFile(file, opts); | ||
cachedFiles[file] = staticPropsList; | ||
} | ||
var values = [].concat(_toConsumableArray(new Set(staticPropsList))); | ||
cb(values); | ||
@@ -132,2 +148,4 @@ | ||
cachedFiles = {}; | ||
if (content !== previousContent) { | ||
@@ -134,0 +152,0 @@ _fs2.default.mkdirSync(saveFilePath, { recursive: true }); |
{ | ||
"name": "@hh.ru/babel-plugin-static-value-extractor", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "devDependencies": { |
@@ -17,3 +17,4 @@ # babel-plugin-static-value-extractor | ||
saveFileExt: — расширение файла, | ||
pathsToReplace: — webpackAliases | ||
pathsToReplace: — webpackAliases, | ||
include: — массив строк путей файлов для которых нужно извлекать значения статических свойств, | ||
template: — функция которая возвращает шаблон контента(string), в качестве аргумента передается объект с ключами названий Файлов и значением массивов извлеченных значений, если не передать контентом сохраненного файла будет JSON представление.', | ||
@@ -20,0 +21,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
68933
17
212
52