如何告诉babel完全忽略es6进口?我使用带有全局变量的nomodules用于旧浏览器和新浏览器的模块
给定b.js
import a from "./a.js";
const x = a.b();
我想要
// Nothing
var x = a.b();
我得到了什么
require function call (undefined)
我的HTML(简体)
<html>
<h2>Example</h2>
<script nomodule src="./a.es5.min.js"></script>
<script nomodule src="./b.es5.min.js"></script>
<script type="module" src="b.js"></script>
</html>
babel rc
{
"presets": [
[
"env",
{
"targets": {
"browsers": ["> 0.1%", "last 3 versions", "ie 10", "ie 11"]
}
}
]
]
}
partial package.json
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1"
},