@babel/plugin-transform-eval

Compile eval calls with string literals

Usage no npm install needed!

<script type="module">
  import babelPluginTransformEval from 'https://cdn.skypack.dev/@babel/plugin-transform-eval';
</script>

README

@babel/plugin-transform-eval

This plugin allows Babel to compile eval calls with string literals.

Example

In

eval("(() => 'foo')");

Out

eval("(function () { return 'foo'; })");

Installation

npm install --save-dev @babel/plugin-transform-eval

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@babel/plugin-transform-eval"]
}

Via CLI

babel --plugins @babel/plugin-transform-eval script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-transform-eval"]
});