@graphql-tools/graphql-tag-pluck
Advanced tools
Comparing version 8.1.0 to 8.2.0-alpha-20240122214141-b6f0c62780dc5474a252177bf549f5718d0225fc
@@ -71,2 +71,5 @@ "use strict"; | ||
break; | ||
case '.astro': | ||
plugins.push('typescript', 'jsx'); | ||
break; | ||
default: | ||
@@ -73,0 +76,0 @@ plugins.push('jsx', ...dynamicFlowPlugins); |
@@ -30,2 +30,3 @@ "use strict"; | ||
'.svelte', | ||
'.astro', | ||
]; | ||
@@ -44,6 +45,17 @@ // tslint:disable-next-line: no-implicit-dependencies | ||
} | ||
// tslint:disable-next-line: no-implicit-dependencies | ||
async function parseWithAstro(astroCompiler, fileData) { | ||
const fileInTsx = await astroCompiler.transform(fileData); | ||
return fileInTsx.code; | ||
} | ||
function parseWithAstroSync( | ||
// tslint:disable-next-line: no-implicit-dependencies | ||
astroCompiler, fileData) { | ||
const fileInTsx = astroCompiler.transform(fileData, undefined); | ||
return fileInTsx.code; | ||
} | ||
/** | ||
* Asynchronously plucks GraphQL template literals from a single file. | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -63,2 +75,5 @@ * @param filePath Path to the file containing the code. Required to detect the file type | ||
} | ||
else if (fileExt === '.astro') { | ||
code = await pluckAstroFileScript(code); | ||
} | ||
return parseCode({ code, filePath, options }).map(t => new graphql_1.Source(t.content, filePath, t.loc.start)); | ||
@@ -70,3 +85,3 @@ }; | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -86,2 +101,5 @@ * @param filePath Path to the file containing the code. Required to detect the file type | ||
} | ||
else if (fileExt === '.astro') { | ||
code = pluckAstroFileScriptSync(code); | ||
} | ||
return parseCode({ code, filePath, options }).map(t => new graphql_1.Source(t.content, filePath, t.loc.start)); | ||
@@ -139,2 +157,14 @@ }; | ||
`)); | ||
const MissingAstroCompilerError = new Error((0, utils_js_1.freeText)(` | ||
GraphQL template literals cannot be plucked from a Astro template code without having the "@astrojs/compiler" package installed. | ||
Please install it and try again. | ||
Via NPM: | ||
$ npm install @astrojs/compiler | ||
Via Yarn: | ||
$ yarn add @astrojs/compiler | ||
`)); | ||
async function pluckVueFileScript(fileData) { | ||
@@ -184,1 +214,22 @@ let vueTemplateCompiler; | ||
} | ||
async function pluckAstroFileScript(fileData) { | ||
let astroCompiler; | ||
try { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
astroCompiler = await Promise.resolve().then(() => tslib_1.__importStar(require('@astrojs/compiler'))); | ||
} | ||
catch (e) { | ||
throw MissingAstroCompilerError; | ||
} | ||
return parseWithAstro(astroCompiler, fileData); | ||
} | ||
function pluckAstroFileScriptSync(fileData) { | ||
let astroCompiler; | ||
try { | ||
astroCompiler = require('astrojs-compiler-sync'); | ||
} | ||
catch (e) { | ||
throw MissingAstroCompilerError; | ||
} | ||
return parseWithAstroSync(astroCompiler, fileData); | ||
} |
@@ -69,2 +69,5 @@ import { getExtNameFromFilePath } from './libs/extname.js'; | ||
break; | ||
case '.astro': | ||
plugins.push('typescript', 'jsx'); | ||
break; | ||
default: | ||
@@ -71,0 +74,0 @@ plugins.push('jsx', ...dynamicFlowPlugins); |
@@ -26,2 +26,3 @@ import { Source } from 'graphql'; | ||
'.svelte', | ||
'.astro', | ||
]; | ||
@@ -40,6 +41,17 @@ // tslint:disable-next-line: no-implicit-dependencies | ||
} | ||
// tslint:disable-next-line: no-implicit-dependencies | ||
async function parseWithAstro(astroCompiler, fileData) { | ||
const fileInTsx = await astroCompiler.transform(fileData); | ||
return fileInTsx.code; | ||
} | ||
function parseWithAstroSync( | ||
// tslint:disable-next-line: no-implicit-dependencies | ||
astroCompiler, fileData) { | ||
const fileInTsx = astroCompiler.transform(fileData, undefined); | ||
return fileInTsx.code; | ||
} | ||
/** | ||
* Asynchronously plucks GraphQL template literals from a single file. | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -59,2 +71,5 @@ * @param filePath Path to the file containing the code. Required to detect the file type | ||
} | ||
else if (fileExt === '.astro') { | ||
code = await pluckAstroFileScript(code); | ||
} | ||
return parseCode({ code, filePath, options }).map(t => new Source(t.content, filePath, t.loc.start)); | ||
@@ -65,3 +80,3 @@ }; | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -81,2 +96,5 @@ * @param filePath Path to the file containing the code. Required to detect the file type | ||
} | ||
else if (fileExt === '.astro') { | ||
code = pluckAstroFileScriptSync(code); | ||
} | ||
return parseCode({ code, filePath, options }).map(t => new Source(t.content, filePath, t.loc.start)); | ||
@@ -132,2 +150,14 @@ }; | ||
`)); | ||
const MissingAstroCompilerError = new Error(freeText(` | ||
GraphQL template literals cannot be plucked from a Astro template code without having the "@astrojs/compiler" package installed. | ||
Please install it and try again. | ||
Via NPM: | ||
$ npm install @astrojs/compiler | ||
Via Yarn: | ||
$ yarn add @astrojs/compiler | ||
`)); | ||
async function pluckVueFileScript(fileData) { | ||
@@ -177,1 +207,22 @@ let vueTemplateCompiler; | ||
} | ||
async function pluckAstroFileScript(fileData) { | ||
let astroCompiler; | ||
try { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
astroCompiler = await import('@astrojs/compiler'); | ||
} | ||
catch (e) { | ||
throw MissingAstroCompilerError; | ||
} | ||
return parseWithAstro(astroCompiler, fileData); | ||
} | ||
function pluckAstroFileScriptSync(fileData) { | ||
let astroCompiler; | ||
try { | ||
astroCompiler = require('astrojs-compiler-sync'); | ||
} | ||
catch (e) { | ||
throw MissingAstroCompilerError; | ||
} | ||
return parseWithAstroSync(astroCompiler, fileData); | ||
} |
{ | ||
"name": "@graphql-tools/graphql-tag-pluck", | ||
"version": "8.1.0", | ||
"version": "8.2.0-alpha-20240122214141-b6f0c62780dc5474a252177bf549f5718d0225fc", | ||
"description": "Pluck graphql-tag template literals", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -117,3 +117,3 @@ import { Source } from 'graphql'; | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mts`, `.cts`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -128,3 +128,3 @@ * @param filePath Path to the file containing the code. Required to detect the file type | ||
* | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte` | ||
* Supported file extensions include: `.js`, `.mjs`, `.cjs`, `.jsx`, `.ts`, `.mjs`, `.cjs`, `.tsx`, `.flow`, `.flow.js`, `.flow.jsx`, `.vue`, `.svelte`, `.astro` | ||
* | ||
@@ -131,0 +131,0 @@ * @param filePath Path to the file containing the code. Required to detect the file type |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
63077
1528
2