@babel/plugin-transform-jscript
Example
In
JavaScript
var foo = function bar() {};
Out
JavaScript
"use strict";
var foo = (function() {
function bar() {}
return bar;
})();
Installation
- npm
- Yarn
- pnpm
npm install --save-dev @babel/plugin-transform-jscript
yarn add --dev @babel/plugin-transform-jscript
pnpm add --save-dev @babel/plugin-transform-jscript
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["@babel/plugin-transform-jscript"]
}
Via CLI
Shell
babel --plugins @babel/plugin-transform-jscript script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-jscript"],
});