babel-plugin-inline-import-graphql-ast
Advanced tools
Comparing version 2.0.1-beta.4 to 2.0.1-rc.0
@@ -9,2 +9,4 @@ Object.defineProperty(exports, "__esModule", { | ||
var _path2 = _interopRequireDefault(_path); | ||
var _os = require('os'); | ||
@@ -26,5 +28,17 @@ | ||
var resolve = void 0; | ||
exports.default = function (_ref) { | ||
var t = _ref.types; | ||
return { | ||
manipulateOptions: function manipulateOptions(_ref2) { | ||
var resolveModuleSource = _ref2.resolveModuleSource; | ||
if (!resolve) { | ||
resolve = resolveModuleSource || function (src, file) { | ||
return _path2.default.resolve((0, _path.dirname)(file), src); | ||
}; | ||
} | ||
}, | ||
visitor: { | ||
@@ -55,3 +69,3 @@ ImportDeclaration: { | ||
function createQuery(queryPath, babelPath) { | ||
var absPath = (0, _path.resolve)((0, _path.dirname)(babelPath), queryPath); | ||
var absPath = resolve(queryPath, babelPath); | ||
var source = (0, _fs.readFileSync)(absPath).toString(); | ||
@@ -63,3 +77,3 @@ var ast = null; | ||
processFragments: function processFragments() { | ||
processImports(getImportStatements(source), (0, _path.dirname)(absPath)); | ||
processImports(getImportStatements(source), absPath); | ||
@@ -72,10 +86,10 @@ function getImportStatements(src) { | ||
function processImports(imports, relDir) { | ||
function processImports(imports, relFile) { | ||
imports.forEach(function (statement) { | ||
var fragmentPath = statement.split(' ')[1].slice(1, -1); | ||
var absFragmentPath = (0, _path.resolve)(relDir, fragmentPath); | ||
var absFragmentPath = resolve(fragmentPath, relFile); | ||
var fragmentSource = (0, _fs.readFileSync)(absFragmentPath).toString(); | ||
var subFragments = getImportStatements(fragmentSource); | ||
if (subFragments.length > 0) { | ||
processImports(subFragments, (0, _path.dirname)(absFragmentPath)); | ||
processImports(subFragments, absFragmentPath); | ||
} | ||
@@ -82,0 +96,0 @@ fragmentDefs = [].concat(_toConsumableArray((0, _graphqlTag2.default)(_templateObject, fragmentSource).definitions), _toConsumableArray(fragmentDefs)); |
{ | ||
"name": "babel-plugin-inline-import-graphql-ast", | ||
"version": "2.0.1-beta.4", | ||
"version": "2.0.1-rc.0", | ||
"description": "Babel plugin to make raw files importable", | ||
@@ -5,0 +5,0 @@ "author": "Alexander Roberts <detrohutt@gmail.com>", |
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
11271
95