@anders-nom/babel-plugin-import-graphql-string
Advanced tools
Comparing version 2.8.1-9 to 2.8.1-10
@@ -44,15 +44,25 @@ "use strict"; | ||
function _getSources(filepath, resolve, acc) { | ||
var path = filepath.replace(/'/g, ''); | ||
var importSrc = (0, _fs.readFileSync)(path).toString(); | ||
var nestedPaths = getFilepaths(importSrc, filepath, resolve); | ||
var srcAndPath = { | ||
src: importSrc, | ||
path | ||
}; | ||
var srcs = nestedPaths.length > 0 ? _toConsumableArray(nestedPaths.reduce(function (srcArr, fp) { | ||
return _toConsumableArray(srcArr).concat(_toConsumableArray(getSources(fp, resolve, []))); | ||
}, [])).concat([srcAndPath]) : [srcAndPath]; | ||
return _toConsumableArray(srcs).concat(_toConsumableArray(acc)); | ||
} | ||
function getSources(filepath, resolve) { | ||
var acc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
var previouslyImported = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; | ||
var importSrc = (0, _fs.readFileSync)(filepath.replace(/'/g, '')).toString(); | ||
var nestedPaths = getFilepaths(importSrc, filepath, resolve).filter(function (path) { | ||
return !previouslyImported.some(function (prevPath) { | ||
return path === prevPath; | ||
}); | ||
return _getSources(filepath, resolve, acc).filter(function (srcAndPath, index, array) { | ||
return array.findIndex(function (item) { | ||
return item.path === srcAndPath.path; | ||
}) === index; | ||
}).map(function (srcAndPath) { | ||
return srcAndPath.src; | ||
}); | ||
var srcs = nestedPaths.length > 0 ? _toConsumableArray(nestedPaths.reduce(function (srcArr, fp) { | ||
return _toConsumableArray(srcArr).concat(_toConsumableArray(getSources(fp, resolve, [], _toConsumableArray(nestedPaths).concat(_toConsumableArray(previouslyImported))))); | ||
}, [])).concat([importSrc]) : [importSrc]; | ||
return _toConsumableArray(srcs).concat(_toConsumableArray(acc)); | ||
} |
@@ -57,3 +57,3 @@ "use strict"; | ||
return imports.reduce(function (acc, fp) { | ||
return _toConsumableArray(acc).concat(_toConsumableArray(customImport.getSources(fp, resolve, [], imports))); | ||
return _toConsumableArray(acc).concat(_toConsumableArray(customImport.getSources(fp, resolve, []))); | ||
}, []).map(stripImportStatements).join('') + stripImportStatements(source); | ||
@@ -60,0 +60,0 @@ } |
{ | ||
"name": "@anders-nom/babel-plugin-import-graphql-string", | ||
"version": "2.8.1-9", | ||
"version": "2.8.1-10", | ||
"description": "Babel plugin to make .gql/.graphql files importable", | ||
@@ -5,0 +5,0 @@ "author": "A.J. Roberts <detrohutt@gmail.com>", |
25657
482