可能遇見的問題:
- 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