可能遇见的问题:
- react-jsx-dev-runtime.development.js:117 Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
- 参考: https://stackoverflow.com/questions/61706057/webpack-typscript-library-import-is-undefined-in-react-project 我这里用到的是webpack5.所以没法使用4的一些插件因为不支持,我只配置了
libraryTarget: 'umd', globalObject: 'this',
externals: { react: { commonjs: 'react', commonjs2: 'react', amd: 'react', root: 'React', }, 'react-dom': { commonjs: 'react-dom', commonjs2: 'react-dom', amd: 'react-dom', root: 'ReactDOM', }, },
此外,gitingore中忽略的文件可能导致npm publish 比如dist文件夹等的时候也忽略掉,所以如果你的文件需要发布到npm 的时候请不要写到gitinonre中
npm:
https://www.npmjs.com/package/llc-calendar
git:
https://github.com/luochenLing/llc-calendar