【发布时间】:2018-06-06 01:15:03
【问题描述】:
我有一个想要在 npm 中发布的组件,我只是通过从项目的 components 文件夹中导入它来测试它。
我设法发布了它,但现在我得到了:
./node_modules/@//index.js 模块中的错误 解析失败:意外的令牌 (11:8) 您可能需要一个适当的 loader 来处理这种文件类型。
我的 index.js 如下:
import React from "react"
import Main from "./bootstrap/containers/main"
export default class BootstrapTable extends React.Component {
constructor(props) {
super(props)
}
render() {
return (
<Main {...this.props} changePage={(p) => this.props.changePage(p)}/>
)
}
}
旁注:我不需要更改 webpack 配置,因为它应该可以正常工作,就像我目前使用的许多其他包一样。
【问题讨论】:
-
所以需要转成commonjs + es/js。
-
谢谢!现在看这个:jasonwatmore.com/post/2018/04/14/…