Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props: Props = {}) {
super(
template.expression(
props.code,
props.options as TemplateBuilderOptions
)(props.replacements as PublicReplacements),
props
);
}
}
const keys = activeValues.map(([key, val]: [string, any]) =>
t.objectProperty(
t.identifier(key),
t.objectExpression([
t.objectProperty(t.identifier('style'), template.expression(
val.style,
)({}) as any),
]),
),
);
import type { NodePath } from "@babel/traverse";
import nameFunction from "@babel/helper-function-name";
import template from "@babel/template";
import * as t from "@babel/types";
const buildAnonymousExpressionWrapper = template.expression(`
(function () {
var REF = FUNCTION;
return function NAME(PARAMS) {
return REF.apply(this, arguments);
};
})()
`);
const buildNamedExpressionWrapper = template.expression(`
(function () {
var REF = FUNCTION;
function NAME(PARAMS) {
return REF.apply(this, arguments);
}
return NAME;
})()
import type { NodePath } from "@babel/traverse";
import nameFunction from "@babel/helper-function-name";
import template from "@babel/template";
import * as t from "@babel/types";
const buildAnonymousExpressionWrapper = template.expression(`
(function () {
var REF = FUNCTION;
return function NAME(PARAMS) {
return REF.apply(this, arguments);
};
})()
`);
const buildNamedExpressionWrapper = template.expression(`
(function () {
var REF = FUNCTION;
function NAME(PARAMS) {
return REF.apply(this, arguments);
}
return NAME;
})()
`);
const buildDeclarationWrapper = template(`
function NAME(PARAMS) { return REF.apply(this, arguments); }
function REF() {
REF = FUNCTION;
return REF.apply(this, arguments);
}
`);
if (!esm) {
bindings = [];
for (const dep of helpers.getDependencies(helperName)) {
const id = (dependencies[dep] = t.identifier(t.toIdentifier(dep)));
tree.body.push(template.statement.ast`
var ${id} = require("${`./${dep}`}");
`);
bindings.push(id.name);
}
}
const helper = helpers.get(
helperName,
dep => dependencies[dep],
esm ? null : template.expression.ast`module.exports`,
bindings
);
tree.body.push(...helper.nodes);
return babel.transformFromAst(tree, null, {
filename: helperFilename,
presets: [
[
"@babel/preset-env",
{ modules: false, exclude: ["@babel/plugin-transform-typeof-symbol"] },
],
],
plugins: [
[
transformRuntime,
{ corejs, useESModules: esm, version: runtimeVersion },
export function expression(tpl: string, vars: { [x: string]: OneOrMore }): t.Expression {
return template.expression(tpl, {
placeholderPattern: PLACEHOLDER_PATTERN,
})(vars);
}
const keys = activeValues.map(([key, val]: [string, any]) =>
t.objectProperty(
t.identifier(key),
t.objectExpression([
t.objectProperty(t.identifier('style'), template.expression(val.style)({}) as any),
])
)
);