Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
b.callExpression(
b.identifier('require'),
[b.literal('../resolve-map')]
)
)]
)
);
// Require the graphql library
if (graphql.length) {
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQL'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql')]
)
)]
));
}
// Relay needs the Node interface along with the globalIdField
if (opts.relay) {
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQLRelay'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql-relay')]
)
)]
));
function convertImport(tempIdentifier: ESTree.Identifier, specifier: ESTree.ImportSpecifier
| ESTree.ImportDefaultSpecifier | ESTree.ImportNamespaceSpecifier): ESTree.VariableDeclarator {
if (n.ImportSpecifier.check(specifier)) {
// e.g. import { a as b, c } from './dep';
return b.variableDeclarator(
b.identifier(specifier.local.name),
b.memberExpression(
b.memberExpression(
tempIdentifier,
b.identifier('exports'),
false
),
b.literal(specifier.imported.name),
true
)
);
} else if (n.ImportDefaultSpecifier.check(specifier)) {
// e.g. import dep from './dep';
return b.variableDeclarator(
b.identifier(specifier.local.name),
b.memberExpression(
b.memberExpression(
tempIdentifier,
b.identifier('exports'),
false
),
b.literal('default'),
true
)
function mapLiteral(node: CNode) {
let value;
value = node.base.value;
if (value === 'NaN') {
return b.literal(NaN);
} else if (IS_STRING.test(value)) {
return b.literal(value.match(STRING_INSIDE_QUOTES)[1]);
} else if (IS_NUMBER.test(value)) {
return b.literal(Number(value));
} else if (IS_REGEX.test(value)) {
return b.literal(stringToRegex(value));
}
return b.identifier(value);
}
function buildImports(opts) {
if (!opts.relay) {
return [];
}
if (opts.es6) {
return [
b.importDeclaration(
[importSpecifier('connectionDefinitions')],
b.literal('graphql-relay')
)
];
}
return [
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQLRelay'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql-relay')]
)
)]
),
b.variableDeclaration('var',
function cjsImport(graphql, types, opts) {
var declarations = [
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('getEntityResolver'),
b.callExpression(
b.identifier('require'),
[b.literal('./util/entity-resolver')]
)
)]
)
];
if (graphql.length) {
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQL'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql')]
)
)]
));
}
module.exports = function buildResolver(model) {
return b.callExpression(
b.identifier('getEntityResolver'),
[b.literal(model.name)]
);
};
true
)
)
)
);
path.replace(
b.variableDeclaration(
'var',
[
b.variableDeclarator(
tempIdentifier,
b.callExpression(
b.identifier('__paeckchen_require__'),
[
b.literal(reexportModuleIndex)
]
)
)
]
),
...exports
);
}
export function buildValue(data: any): ESTree.ObjectExpression|ESTree.ArrayExpression|ESTree.Literal {
if (data === null) {
return b.literal(null);
}
switch (typeof data) {
case 'number':
case 'string':
case 'boolean':
return b.literal(data);
default:
if (Array.isArray(data)) {
return buildArray(data);
}
return buildObject(data);
}
};
[b.variableDeclarator(
b.identifier(item),
b.callExpression(
b.identifier('require'),
[b.literal('./types/' + item)]
)
)]
);
}));
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('resolveMap'),
b.callExpression(
b.identifier('require'),
[b.literal('./resolve-map')]
)
)]
));
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('types'),
b.callExpression(
b.identifier('require'),
[b.literal('./types')]
)
)]
));
declarations = declarations.concat(graphql.map(function(item) {
return b.variableDeclaration('var',