/
githubmirror
/
babel
Обзор
Документация
Войти
/
githubmirror
/
babel
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/babel-plugin-transform-jscript/src/index.ts
34 строки
860 B
Huáng Jùnliàng
chore: inline REQUIRED_VERSION(7) special case (#17897)
17 апр 2026, 16:26
Не верифицирован
17 апр 2026, 16:26
3b1954b
Код
Авторство
О чём код?
import { declare } from "@babel/helper-plugin-utils"; import { types as t } from "@babel/core"; export default declare(api => { api.assertVersion(REQUIRED_VERSION("^7.0.0-0 || ^8.0.0")); return { name: "transform-jscript", visitor: { FunctionExpression: { exit(path) { const { node } = path; if (!node.id) return; path.replaceWith( t.callExpression( t.functionExpression( null, [], t.blockStatement([ // @ts-expect-error t.toStatement must return a FunctionDeclaration if node.id is defined t.toStatement(node), t.returnStatement(t.cloneNode(node.id)), ]), ), [], ), ); }, }, }, }; });