尽管预设是自动安装的,但我似乎无法让 Babel 与 Parcel 一起使用。它在本地和 Chrome 中工作,但它没有转换 node_modules es6 文件,所以输出仍然有const/let/...
,并且无法在 Safari 中运行。
.babelrc
{
"presets": ["@babel/preset-env","@babel/preset-react"]
}
(我也试过env
和react
)。
package.json 脚本
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html",
为什么会这样?
完整的 package.json (注意这是在为了让它工作而搞砸之后)
{
"name": "my-react-app",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.1.5",
"@babel/preset-env": "^7.1.5",
"@babel/preset-react": "^7.0.0",
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"browserslist": "^4.3.4",
"lodash": "^4.17.11",
"node-sass": "^4.10.0",
"pinyin": "^2.8.3",
"prop-types": "^15.6.2",
"react": "^16.6.1",
"react-dom": "^16.6.1",
"react-notifications": "^1.4.3",
"react-router-dom": "^4.3.1"
},
"devDependencies": {
"cssnano": "^4.1.7",
"sass": "^1.14.3"
}
}
const
仍然使用,获取 .js 文件let
。有什么我想念的想法吗?