Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function evaluate(babel, path, state) {
let result = evaluateSimple(path)
if (result.confident) {
return {
value: compileRule(result.value),
dependencies: [],
}
}
try {
result = evaluateComplex(
path,
babel.types,
state.file.opts.filename,
text => {
return babel.transformSync(text, {
babelrc: false,
filename: state.file.opts.filename,
plugins: [
// Include this plugin to avoid extra config when using { module: false } for webpack
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-export-namespace-from',
// We don't support dynamic imports when evaluating, but don't wanna syntax error
// This will replace dynamic imports with an object that does nothing
// eslint-disable-next-line no-undef
require.resolve('linaria/lib/babel/dynamic-import-noop'),
],