Babel 7内联替换变量

时间:2018-05-25 11:16:46

标签: webpack electron babel electron-builder

我有一个使用电子网络包的电子项目,似乎包括babel 7。

我设法升级了除babel-plugin-inline-replace-variables之外的所有插件和预设

知道解决方案是什么吗?

2 个答案:

答案 0 :(得分:0)

很遗憾,public class SwipeListener : SimpleOnGestureListener, View.IOnTouchListener { private const int SWIPE_THRESHOLD = 100; private const int SWIPE_VELOCITY_THRESHOLD = 100; private readonly GestureDetector gestureDetector; public SwipeListener(Context ctx) { this.gestureDetector = new GestureDetector(ctx, this); } public Boolean OnTouch(View v, MotionEvent e) { return this.gestureDetector.OnTouchEvent(e); } public event EventHandler OnSwipeRight; public event EventHandler OnSwipeLeft; public event EventHandler OnSwipeTop; public event EventHandler OnSwipeBottom; public override Boolean OnDown(MotionEvent e) { return true; } public override Boolean OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { Boolean result = false; float diffY = e2.GetY() - e1.GetY(); float diffX = e2.GetX() - e1.GetX(); if (Math.Abs(diffX) > Math.Abs(diffY)) { if (Math.Abs(diffX) > SWIPE_THRESHOLD && Math.Abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) { if (diffX > 0) { SwipeRight(); } else { SwipeLeft(); } result = true; } } else if (Math.Abs(diffY) > SWIPE_THRESHOLD && Math.Abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) { if (diffY > 0) { SwipeBottom(); } else { SwipeTop(); } result = true; } return result; } public void SwipeRight() { this.OnSwipeRight?.Invoke(this, EventArgs.Empty); } public void SwipeLeft() { this.OnSwipeLeft?.Invoke(this, EventArgs.Empty); } public void SwipeTop() { this.OnSwipeTop?.Invoke(this, EventArgs.Empty); } public void SwipeBottom() { this.OnSwipeBottom?.Invoke(this, EventArgs.Empty); } } 不支持Babel 7。

有一个名为babel-plugin-search-and-replace的类似插件,它将替换您在babel运行时选择的字符串。最棒的是,它支持Babel 7!

首先将其作为开发依赖项安装到您的项目中:
babel-plugin-inline-replace-variables

然后在npm i babel-plugin-search-and-replace --save-dev.babelrc配置文件中进行配置:

babel.config.js

答案 1 :(得分:-1)

似乎babel-plugin-inline-replace-variables看起来不会在不久的将来支持babel 7

将electronic-webpack降级为@ ^ 1.13.0,撤消其余的beta babel 7插件/预设更改修复了我的问题......