【发布时间】:2019-01-29 11:20:27
【问题描述】:
我正在使用 react 开发一个应用程序,它需要在 IE 上运行。我正在使用一个名为query-string 的外部库。它包含箭头函数,而 IE 不知道这些函数,并且由于某种原因,这个库中的代码没有被转译或翻译成旧的 JS。
我在这个项目中遇到了类似的问题,库 popmotion 使用了 find 方法,但我通过安装 Babel polyfill 并将其包含在主文件 App.jsx 中来解决这个问题。我没有弹出反应应用程序,因为我对此很陌生,并且不知道反应在幕后是如何工作的。
这是我的 package.json
{
"name": "ruzovky",
"version": "0.1.0",
"private": true,
"dependencies": {
"babel-polyfill": "^6.26.0",
"classnames": "^2.2.6",
"deepcopy": "^1.0.0",
"node-sass-chokidar": "^1.3.3",
"npm-run-all": "^4.1.3",
"popmotion": "^8.3.4",
"prop-types": "^15.6.2",
"query-string": "^6.1.0",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.4"
},
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "node-sass-chokidar src/ -o src/ --watch",
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build-js": "react-scripts build",
"build": "npm-run-all build-css build-js",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
为了帮助您理解我的问题:除了这个单一库之外,其他所有内容都会被转译,因为 react 会处理所有事情(我可以使用 javascript 创建反应组件,目前还没有浏览器支持)。在我的 node_modules 文件夹中也有 babel-loader 和 webpack。
【问题讨论】:
标签: javascript reactjs babeljs transpiler