vite-plugin-chunk-split
vite-plugin-chunk-split copied to clipboard
monorepo: Cannot find package
I have both react and react-dom installed and running the example, it gives an error saying the packages cannot be found
I suspect that this is due to me having a monorepo...? it seems that the plugin is trying to find the packages under the root instead of apps/...
我这边也有相同的问题 当package.json type指定module时会报react包找不到 当package.json删除type为默认时 报require的错误 提示Vite 的 CJS Node API 构建已经被废弃 但是插件的导入方式是esm的导入方式
和monorepo没关系,我这边也遇到这个问题了
使用"react-vendor": [/react/]
代替 "react-vendor": [”react“]
就可以了
@rickyzhangca @MissFlower @sanyuan0704
和monorepo没关系,我这边也遇到这个问题了 使用
"react-vendor": [/react/]
代替"react-vendor": [”react“]
就可以了@rickyzhangca @MissFlower @sanyuan0704
这样确实好使了 不过这是命中了正则的逻辑 固定包名的逻辑应该还是有问题
我想问另一个问题 就是如果package.json的type使用默认的commonjs 插件好像走的是cjs的代码 但是插件是用esm的导入方式
固定包名的处理,应该是 Rollup 的返回参数有所变化,亦或者是 vite 5 废弃了私有 api 的使用,使用其提供的兼容库替代后,导致原有的匹配逻辑出现问题。
主要的匹配逻辑是这两块:
- https://github.com/sanyuan0704/vite-plugin-chunk-split/blob/master/src/index.ts
- https://github.com/sanyuan0704/vite-plugin-chunk-split/blob/master/src/staticImportScan.ts
ref:https://vitejs.dev/guide/migration#remove-resolvepackageentry-and-resolvepackagedata-apis