babel-gql
Advanced tools
Comparing version 0.1.4-dev.126a90f42 to 0.1.4-dev.611b7dde8
@@ -166,7 +166,7 @@ "use strict"; | ||
ImportDeclaration: (path, state) => { | ||
var _a, _b; | ||
var _a; | ||
const opts = state.opts || {}; | ||
const target = (_b = (_a = opts) === null || _a === void 0 ? void 0 : _a.ownModuleName, (_b !== null && _b !== void 0 ? _b : "babel-gql")); | ||
const targets = new Set(["babel-gql", "@headup/wp", (_a = opts) === null || _a === void 0 ? void 0 : _a.ownModuleName].filter(Boolean)); | ||
const importName = path.node.source.value; | ||
if (importName === target) { | ||
if (targets.has(importName)) { | ||
for (const s of path.node.specifiers) { | ||
@@ -173,0 +173,0 @@ if (!t.isImportSpecifier(s)) { |
@@ -15,5 +15,7 @@ import { FragmentDefinitionNode, OperationDefinitionNode } from "graphql"; | ||
onDone?: OnDone; | ||
active?: boolean; | ||
constructor(options: { | ||
target: string; | ||
onDone?: OnDone; | ||
active?: boolean; | ||
}); | ||
@@ -20,0 +22,0 @@ apply(compiler: any): void; |
@@ -69,2 +69,8 @@ "use strict"; | ||
this.onDone = options.onDone; | ||
if (typeof this.active === "undefined") { | ||
this.active = true; | ||
} | ||
else { | ||
this.active = options.active; | ||
} | ||
} | ||
@@ -92,7 +98,9 @@ apply(compiler) { | ||
} | ||
yield Promise.all(dirtyQueries.map((query) => __awaiter(this, void 0, void 0, function* () { | ||
const path = path_1.default.join(this.target, `${query.queryName}-${query.fullQueryId}.graphql`); | ||
debug("Writing ", path); | ||
yield fs_1.promises.writeFile(path, query.fullQuery); | ||
}))); | ||
if (this.active) { | ||
yield Promise.all(dirtyQueries.map((query) => __awaiter(this, void 0, void 0, function* () { | ||
const path = path_1.default.join(this.target, `${query.queryName}-${query.fullQueryId}.graphql`); | ||
console.log("[babel-gql] Writing ", path); | ||
yield fs_1.promises.writeFile(path, query.fullQuery); | ||
}))); | ||
} | ||
if (this.onDone) { | ||
@@ -159,5 +167,7 @@ yield this.onDone(qm, dirtyQueries.length); | ||
if (this.knownQueries.get(queryName) === query) { | ||
debug("No changes to " + queryName); | ||
// no changes | ||
return; | ||
} | ||
debug("Found changes to query " + queryName); | ||
this.dirtyQueries.add(queryName); | ||
@@ -164,0 +174,0 @@ this.knownQueries.set(queryName, query); |
{ | ||
"name": "babel-gql", | ||
"version": "0.1.4-dev.126a90f42", | ||
"version": "0.1.4-dev.611b7dde8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62572
1003