0
바벨 플러그인에서 두 가지 대체품을 원합니다. 두 번째 교체 작업은 첫 번째 작업이 완료된 후에 만 수행해야합니다.바벨 플러그인 (방문자 패턴) - 작동 방식
module.exports = function(babel) {
const t = babel.types;
return {
visitor: {
FunctionExpression: function(path) {
//Conversion to arrow functions
path.replaceWith(t.arrowFunctionExpression(path.node.params, path.node.body, false));
},
ThisExpression: function(path) {
//Converting all this expressions to identifiers so that it won't get translated differently
path.replaceWith(t.identifier("this"));
}
}
};
}
"FunctionExpression"의 AST 트리에서 "ThisExpression"은 트리 아래 어딘가에 있습니다. 두 번째 변환이 완료된 후에 만 첫 번째 변환이 발생하도록하고 싶습니다. 이것을 어떻게 성취합니까?