Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monorepo: Cannot find package #33

Open
rickyzhangca opened this issue Nov 21, 2023 · 5 comments
Open

monorepo: Cannot find package #33

rickyzhangca opened this issue Nov 21, 2023 · 5 comments

Comments

@rickyzhangca
Copy link

I have both react and react-dom installed and running the example, it gives an error saying the packages cannot be found

image
@rickyzhangca
Copy link
Author

rickyzhangca commented Nov 21, 2023

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/...

@rickyzhangca rickyzhangca changed the title Cannot find package monorepo: Cannot find package Nov 21, 2023
@MissFlower
Copy link

我这边也有相同的问题 当package.json type指定module时会报react包找不到 当package.json删除type为默认时 报require的错误 提示Vite 的 CJS Node API 构建已经被废弃 但是插件的导入方式是esm的导入方式

@lorenzohee
Copy link

和monorepo没关系,我这边也遇到这个问题了
使用"react-vendor": [/react/] 代替 "react-vendor": [”react“] 就可以了

@rickyzhangca @MissFlower @sanyuan0704

@MissFlower
Copy link

和monorepo没关系,我这边也遇到这个问题了 使用"react-vendor": [/react/] 代替 "react-vendor": [”react“] 就可以了

@rickyzhangca @MissFlower @sanyuan0704

image
这样确实好使了 不过这是命中了正则的逻辑 固定包名的逻辑应该还是有问题

我想问另一个问题 就是如果package.json的type使用默认的commonjs 插件好像走的是cjs的代码 但是插件是用esm的导入方式
image

@greenhat616
Copy link
Contributor

greenhat616 commented Dec 6, 2023

固定包名的处理,应该是 Rollup 的返回参数有所变化,亦或者是 vite 5 废弃了私有 api 的使用,使用其提供的兼容库替代后,导致原有的匹配逻辑出现问题。

主要的匹配逻辑是这两块:

ref:https://vitejs.dev/guide/migration#remove-resolvepackageentry-and-resolvepackagedata-apis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants