Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
map(fullContext, (requireRequest, name) => [
// const name$0 = require(path);
b.variableDeclaration('const', [
b.variableDeclarator(b.identifier(`${name}$0`), requireIt(requireRequest).toAST()),
]),
// const name = name$0[name] || name$0.default || name$0;
b.variableDeclaration('const', [
b.variableDeclarator(
b.identifier(name),
b.logicalExpression(
'||',
b.identifier(`${name}$0['${name}']`),
b.logicalExpression(
'||',
b.identifier(`${name}$0.default`),
b.identifier(`${name}$0`)
)
)
),
]),
])
)
// 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')]
)
)]
));
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('Node'),
b.callExpression(
b.identifier('require'),
[b.literal('./Node')]
)
b.thisExpression(), b.identifier(`read${child_type}`)),
[])]));
if (fieldref === null) {
read_stmts.push(
b.whileStatement(
b.binaryExpression(
'<',
b.memberExpression(
b.thisExpression(), b.identifier('cursor')),
b.memberExpression(
b.thisExpression(), b.identifier('length'))),
b.blockStatement([read_stmt])));
} else {
read_stmts.push(
b.forStatement(
b.variableDeclaration(
'let',
[b.variableDeclarator(
b.identifier('i'),
b.literal(0))]),
b.binaryExpression(
'<',
b.identifier('i'),
b.identifier(`${child_name}_length`)),
b.updateExpression(
'++',
b.identifier('i'),
false),
b.blockStatement([read_stmt])
));
}
write_stmts.push(
];
if (graphql.length) {
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQL'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql')]
)
)]
));
}
if (opts.relay) {
declarations.push(b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('Node'),
b.callExpression(
b.identifier('require'),
[b.literal('./types/Node')]
)
)]
));
}
declarations = declarations.concat(types.map(function(item) {
return b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier(item),
b.callExpression(
b.identifier('require'),
if (path.scope.lookup('process') === null) {
processPath = path;
}
return false;
}
});
if (processPath === undefined) {
return Promise.resolve();
}
const processModulePath = await getModulePath('.', 'process', context);
const processIndex = getModuleIndex(processModulePath, state);
const body = processPath.get('body');
body.get(body.value.length - 1).insertBefore(
b.variableDeclaration(
'var',
[
b.variableDeclarator(
b.identifier('process'),
b.memberExpression(
b.callExpression(
b.identifier('__paeckchen_require__'),
[
b.literal(processIndex)
]
),
b.identifier('exports'),
false
)
)
]
var id = node.left.declarations[0].id;
node.left = id;
nodes.push(util.template("variable-declare", {
KEY: id
}));
}
return node;
});
//
var argumentsId = util.aliasArguments(generateUid, node);
if (argumentsId) {
nodes.push(b.variableDeclaration("var", [
b.variableDeclarator(argumentsId, b.identifier("arguments"))
]));
}
//
var block = b.blockStatement([]);
block.body = node;
var func = b.functionExpression(null, [], block, false);
//
var templateName = "function-call";
if (traverse.hasType(node, "ThisExpression")) templateName += "-this";
if (traverse.hasType(node, "ReturnStatement", traverse.FUNCTION_TYPES)) templateName += "-return";
function importModule(identifier: ESTree.Identifier, moduleIndex: number): ESTree.VariableDeclaration {
return b.variableDeclaration(
'var',
[
b.variableDeclarator(
identifier,
b.callExpression(
b.identifier('__paeckchen_require__'),
[
b.literal(moduleIndex)
]
)
)
]
);
}
declarations = declarations.concat(types.map(function(item) {
return b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier(item),
b.callExpression(
b.identifier('require'),
[b.literal('./types/' + item)]
)
)]
);
}));
moduleExportsExpression(specifier.exported.name),
b.memberExpression(
b.memberExpression(
tempIdentifier,
b.identifier('exports'),
false
),
b.literal(specifier.local.name),
true
)
)
)
);
path.replace(
b.variableDeclaration(
'var',
[
b.variableDeclarator(
tempIdentifier,
b.callExpression(
b.identifier('__paeckchen_require__'),
[
b.literal(reexportModuleIndex)
]
)
)
]
),
...exports
);
}
)
];
}
return [
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('GraphQLRelay'),
b.callExpression(
b.identifier('require'),
[b.literal('graphql-relay')]
)
)]
),
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('connectionDefinitions'),
b.memberExpression(
b.identifier('GraphQLRelay'),
b.identifier('connectionDefinitions'),
false
)
)]
)
];
}