Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function compileClientFunction (fnCode, dependencies, instantiationCallsiteName, compilationCallsiteName) {
if (fnCode === ASYNC_TO_GENERATOR_OUTPUT_CODE)
throw new ClientFunctionAPIError(compilationCallsiteName, instantiationCallsiteName, RUNTIME_ERRORS.regeneratorInClientFunctionCode);
fnCode = makeFnCodeSuitableForParsing(fnCode);
// NOTE: we need to recompile ES6 code for the browser if we are on newer versions of Node.
fnCode = downgradeES(fnCode);
fnCode = hammerhead.processScript(fnCode, false);
// NOTE: check compiled code for regenerator injection: we have either generator
// recompiled in Node.js 4+ for client or async function declared in function code.
if (REGENERATOR_FOOTPRINTS_RE.test(fnCode))
throw new ClientFunctionAPIError(compilationCallsiteName, instantiationCallsiteName, RUNTIME_ERRORS.regeneratorInClientFunctionCode);
if (!TRAILING_SEMICOLON_RE.test(fnCode))
fnCode += ';';
const dependenciesDefinition = dependencies ? getDependenciesDefinition(dependencies) : '';
return addBabelArtifactsPolyfills(fnCode, dependenciesDefinition);
}