如何解决Lerna React从带有babel的包中导出组件,但从webpack中导出
我正在我的项目中设置lerna
。
放弃
框架:React
目录结构:
---- packages/
-------------the-component-library
-------------the-common-utils-library
---- apps/
-------------document-management-system
-------------accounts-management-system
在lerna.json中:
"packages": ["packages/*","apps/*"],
问题
如果要从apps/the-component-library
导入内容,则需要构建它。如果我在package.json
的{{1}}中使用babel:效果很好
apps/the-component-library
但是我需要 WORKS
"scripts": {
"start": "babel src --watch --out-dir lib",}
,css-loader
,所以我安装了less-loader
进行编译。
webpack
// DOESN't Work
"scripts": {
"start": "webpack src --watch --out-dir lib",}
正在成功构建 ,但是在尝试导入时出现错误
Webpack
或任何其他软件包。它显示:
apps/document-management-system
webpack不能像babel本身那样导出组件。
其他信息
在Uncaught (in promise) Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in,or you might have mixed up default and named imports.
中:
packages/the-component-library/index.js
PS:我是webpack和babel的新手。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。