@graphql-toolkit/graphql-tag-pluck
Advanced tools
Comparing version 0.7.4 to 0.7.5-alpha-022945b.8
@@ -7,2 +7,21 @@ 'use strict'; | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) { return e; } else { | ||
var n = {}; | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return e[k]; | ||
} | ||
}); | ||
}); | ||
} | ||
n['default'] = e; | ||
return n; | ||
} | ||
} | ||
const parser = require('@babel/parser'); | ||
@@ -108,3 +127,3 @@ const t = require('@babel/types'); | ||
const parseCode = (code, config) => { | ||
const parseCode = async (code, config) => { | ||
// The 'typescript' plug-in has few bugs... It's just better to use the native one | ||
@@ -115,3 +134,3 @@ // even though it affects performance | ||
try { | ||
ts = require('typescript'); | ||
ts = await new Promise(function (resolve) { resolve(_interopNamespace(require('typescript'))); }); | ||
} | ||
@@ -137,3 +156,3 @@ catch (e) { | ||
// React.Components which are provided with null or undefined e.g. <Foo<undefined />> | ||
jsx: config.plugins.includes('jsx') && 'react', | ||
jsx: config.plugins.includes('jsx') && ts.JsxEmit.React, | ||
}, | ||
@@ -378,3 +397,3 @@ }).outputText; | ||
}; | ||
const gqlPluckFromFile = (filePath, options = {}) => { | ||
const gqlPluckFromFile = async (filePath, options = {}) => { | ||
if (typeof filePath != 'string') { | ||
@@ -398,3 +417,3 @@ throw TypeError('Provided file path must be a string'); | ||
}; | ||
const gqlPluckFromCodeString = (code, options = {}) => { | ||
const gqlPluckFromCodeString = async (code, options = {}) => { | ||
if (typeof code != 'string') { | ||
@@ -415,3 +434,3 @@ throw TypeError('Provided code must be a string'); | ||
const out = { returnValue: null }; | ||
const ast = parseCode(code, generateConfig(code, options)); | ||
const ast = await parseCode(code, generateConfig(code, options)); | ||
const visitor = createVisitor(ast['code'], out, options); | ||
@@ -418,0 +437,0 @@ traverse(ast, visitor); |
@@ -10,8 +10,8 @@ export interface GraphQLTagPluckOptions { | ||
} | ||
export declare const gqlPluckFromFile: (filePath: string, options?: GraphQLTagPluckOptions) => string; | ||
export declare const gqlPluckFromCodeString: (code: string, options?: GraphQLTagPluckOptions) => string; | ||
export declare const gqlPluckFromFile: (filePath: string, options?: GraphQLTagPluckOptions) => Promise<string>; | ||
export declare const gqlPluckFromCodeString: (code: string, options?: GraphQLTagPluckOptions) => Promise<string>; | ||
declare const _default: { | ||
fromFile: (filePath: string, options?: GraphQLTagPluckOptions) => string; | ||
fromCodeString: (code: string, options?: GraphQLTagPluckOptions) => string; | ||
fromFile: (filePath: string, options?: GraphQLTagPluckOptions) => Promise<string>; | ||
fromCodeString: (code: string, options?: GraphQLTagPluckOptions) => Promise<string>; | ||
}; | ||
export default _default; |
@@ -101,3 +101,3 @@ import { parse } from '@babel/parser'; | ||
const parseCode = (code, config) => { | ||
const parseCode = async (code, config) => { | ||
// The 'typescript' plug-in has few bugs... It's just better to use the native one | ||
@@ -108,3 +108,3 @@ // even though it affects performance | ||
try { | ||
ts = require('typescript'); | ||
ts = await import('typescript'); | ||
} | ||
@@ -130,3 +130,3 @@ catch (e) { | ||
// React.Components which are provided with null or undefined e.g. <Foo<undefined />> | ||
jsx: config.plugins.includes('jsx') && 'react', | ||
jsx: config.plugins.includes('jsx') && ts.JsxEmit.React, | ||
}, | ||
@@ -371,3 +371,3 @@ }).outputText; | ||
}; | ||
const gqlPluckFromFile = (filePath, options = {}) => { | ||
const gqlPluckFromFile = async (filePath, options = {}) => { | ||
if (typeof filePath != 'string') { | ||
@@ -391,3 +391,3 @@ throw TypeError('Provided file path must be a string'); | ||
}; | ||
const gqlPluckFromCodeString = (code, options = {}) => { | ||
const gqlPluckFromCodeString = async (code, options = {}) => { | ||
if (typeof code != 'string') { | ||
@@ -408,3 +408,3 @@ throw TypeError('Provided code must be a string'); | ||
const out = { returnValue: null }; | ||
const ast = parseCode(code, generateConfig(code, options)); | ||
const ast = await parseCode(code, generateConfig(code, options)); | ||
const visitor = createVisitor(ast['code'], out, options); | ||
@@ -411,0 +411,0 @@ traverse(ast, visitor); |
import { ParserOptions } from '@babel/parser'; | ||
export declare const parseCode: (code: string, config: ParserOptions) => import("@babel/types").File; | ||
export declare const parseCode: (code: string, config: ParserOptions) => Promise<import("@babel/types").File>; |
{ | ||
"name": "@graphql-toolkit/graphql-tag-pluck", | ||
"version": "0.7.4", | ||
"version": "0.7.5-alpha-022945b.8+022945b", | ||
"description": "Pluck graphql-tag template literals", | ||
@@ -14,3 +14,3 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@babel/parser": "7.7.4", | ||
"@babel/parser": "7.7.5", | ||
"@babel/traverse": "7.7.4", | ||
@@ -17,0 +17,0 @@ "@babel/types": "7.7.4" |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
35202
10
874
1
+ Added@babel/parser@7.7.5(transitive)
- Removed@babel/parser@7.7.4(transitive)
Updated@babel/parser@7.7.5