Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getBlocksUsage = code => {
try {
const plugin = new BabelPluginGetBlocksUsage()
transform(code, {
plugins: [babelPluginSyntaxJsx, plugin.plugin]
})
return plugin.state.usage
} catch (e) {
console.log(e)
}
}
const getCompiledCode = ({code, scope}) => {
const codeToCompile = `
(function (${Object.keys(scope).join(', ')}, mountNode) {
${code}
});`
return transform(codeToCompile, TRANSFORM_PRESETS).code
}
}).then(({args, argv}) => {
const code = transform(`
class Demo extends React.Component {
${value}
}
ReactDOM.render(, document.getElementById('${this.playerId}'))
`, {
presets: ['es2015', 'react']
}).code
args.push(code)
const Fn = Function
new Fn(...args).apply(this, argv)
this.source[2] = value
}).catch((err) => {
renderSource(code) {
let finalCode = code.replace('mountNode', `document.getElementById("demo-${this.props.demo.order}")`);
finalCode = finalCode.replace(/import[^;]+?;/g, '');
const transformedCode = transform(finalCode, {
presets: ['es2015', 'react'],
plugins: ['proposal-class-properties', 'proposal-object-rest-spread'],
}).code;
const args = ['context', 'React', 'ReactDOM', 'PropTypes', 'jsonp', 'ComponentCard'];
const argv = [this, React, ReactDOM, PropTypes, jsonp, ComponentCard];
Object.keys(Components).forEach(name => {
args.push(name);
argv.push(Components[name]);
});
args.push(transformedCode);
ReactDOM.unmountComponentAtNode(document.getElementById(`demo-${this.props.demo.order}`));
export default function compileJs(code) {
if (!code) {
return ''
}
return transform(code, transformOptions).code || ''
}
const compiler = code =>
babel.transform(code, {
plugins: [importExportPlugin, jsxPlugin]
}).code;
const babelTransformCode = options => code =>
Babel.transform(code, options).code;