create-react-app 项目中的 dygraphs 缩小构建错误
dygraphs minification build error in a create-react-app project
我已将 dygraphs 添加到使用 create-react-app
创建的大型现有项目中。一切运行良好,我正在使用通用语法导入 dygraphs:
import Dygraph from 'dygraphs';
然而,当我尝试使用 npm run build
构建我的项目时,ES6 位的 dygraphs 导致构建失败:
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
..dev/node_modules/dygraphs/src/dygraph-utils.js:325
Read more here: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
在 link 之后并查看第 325 行,缩小器被 ES6 =>
运算符绊倒了。在 node_modules/dygraphs 下查看,有 src
和 src-es5
目录。我将 src
重命名为 src-es6
并创建了一个 symlink:
src -> src-es5
使用此方法一切运行和构建都很好,但它似乎不是最佳解决方案。提供的 link 建议来自 create-react-app 装备的 ejecting
并自己处理构建,但这不是一个选项。
关于更正确的处理方法有什么建议吗?是否有从 es5 src 目录中 import Dygraph
的特定方法?
我已将 dygraphs 添加到使用 create-react-app
创建的大型现有项目中。一切运行良好,我正在使用通用语法导入 dygraphs:
import Dygraph from 'dygraphs';
然而,当我尝试使用 npm run build
构建我的项目时,ES6 位的 dygraphs 导致构建失败:
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file:
..dev/node_modules/dygraphs/src/dygraph-utils.js:325
Read more here: https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-build-fails-to-minify
在 link 之后并查看第 325 行,缩小器被 ES6 =>
运算符绊倒了。在 node_modules/dygraphs 下查看,有 src
和 src-es5
目录。我将 src
重命名为 src-es6
并创建了一个 symlink:
src -> src-es5
使用此方法一切运行和构建都很好,但它似乎不是最佳解决方案。提供的 link 建议来自 create-react-app 装备的 ejecting
并自己处理构建,但这不是一个选项。
关于更正确的处理方法有什么建议吗?是否有从 es5 src 目录中 import Dygraph
的特定方法?