We want to write a Babel Plugin, which move 'const versionRegex = /(/d+)\.(/d+)\.(/d+)/gi' out of function scope and put it into global scope. Code: function getVersion(versionString) { const versionRegex = /(\d+)\.(\d+)\.(\d+)/gi var x = /foo/.text(
For example we have current code: function add(a, b) { console.log(a, b) return a + b } function subtract(a, b) { console.log(a, b) return a - b } add(, ) subtract(, ) console.log('sup dawg') We want to transform the code to: function add(a, b) { con
The code we want to trasform: 2 ** 3; a ** b; a **b * c; a ** b ** c; (a+1) ** (b+1); transform to: Math.pow(2, 3); Math.pow(a, b); Math.pow(a, b) * c; Math.pow(a, Math.pow(b, c)); Math.pow(a+1, b+1); Code: export default function (babel) { const { t
a = () => {}, // Support for the experimental syntax 'classProperties' isn't currently enabled yarn add @babel/plugin-proposal-class-properties --dev @babel/plugin-transform-runtime 有async await 时候, 要用中间件 redux-thunk
Continue with previous post: https://www.cnblogs.com/Answer1215/p/12342540.html Now we need to think about functionExpression and ArrowFunction: function add(a, b) { console.log(a, b) return a + b } function subtract(a, b) { console.log(a, b) return