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

User dev experience enhancement of using pnpm linking local package. #8175

Open
4 tasks done
zheeeng opened this issue May 14, 2022 · 3 comments
Open
4 tasks done

User dev experience enhancement of using pnpm linking local package. #8175

zheeeng opened this issue May 14, 2022 · 3 comments
Labels
enhancement New feature or request feat: deps optimizer Esbuild Dependencies Optimization performance Performance related enhancement

Comments

@zheeeng
Copy link
Contributor

zheeeng commented May 14, 2022

Clear and concise description of the problem

In development, there is a common workflow for linking a developing lib to vite app. I use these steps:

  1. Link foo pkg to global by executing pnpm link --global under foo workspace.
  2. Link in foo pkg to vite app by executing pnpm link --global foo.
  3. Continuously watch foo's modification and produce dist artifacts for debugging the program in vite side.

There are some issues with this usage.

  1. The security machanism of vite disallows us import pkg which is outside of the vite app workspace. We have to configure the vite.config.ts through server.fs.strict or server.fs.allow. The most convenient way is to turn off the strict restriction in dev env.

  2. The vite optmizeDeps rules won't transpile the linked cjs/umd format lib to esm, caused by some my own reasons, we can't emit the lib as esm format. By comparison, if we publish the cjs/umd lib, vite can handle it well by the pre-bundle machanism.

  3. We can't list the linked lib as the optimizeDeps in monorepo vite app, since vite bootstrap fails to force resolving the lib(it is located in pnpm-global).

  4. Even if we have some ways to pre-bundle the lib, we expect to having the hmr machanism for debugging the lib or vite app.

There are some related issues/documents but not about linking local pkg.

#7138
#7008

Suggested solution

Some enhancement or doc guidance to this workflow.

Alternative

No response

Additional context

No response

Validations

@bluwy
Copy link
Member

bluwy commented May 15, 2022

Thanks for collecting the points into an issue. I think this can be another thing Vite 3 can do out-of-the-box. no1 to no4 all seem to be something that can be handled automatically.

Re pnpm link --global, I just checked again and it seems that pnpm-global only happens in pnpm6, so maybe the issue doesn't exist for pnpm7? Nonetheless the enhancement for local packages are still valid though.

@bluwy bluwy added enhancement New feature or request and removed enhancement: pending triage labels May 15, 2022
@bluwy bluwy added this to the 3.0 milestone May 15, 2022
@zheeeng zheeeng changed the title UX enhancement of using pnpm linking local package. User dev experience enhancement of using pnpm linking local package. May 16, 2022
@bluwy bluwy removed this from the 3.0 milestone Jun 20, 2022
@zheeeng
Copy link
Contributor Author

zheeeng commented Jun 21, 2022

@bluwy Hey, does there still has a plan to land this enhancement in v3.0?

@bluwy
Copy link
Member

bluwy commented Jun 21, 2022

I haven't got to tackle this for Vite 3 as a lot has changed for optimizeDeps. I removed it from the milestone as we're close to releasing a beta and stable now, but I also think this enhancement can be added post 3.0 transparently as it won't be breaking.

@bluwy bluwy added the feat: deps optimizer Esbuild Dependencies Optimization label Jun 23, 2022
@patak-dev patak-dev added the performance Performance related enhancement label Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat: deps optimizer Esbuild Dependencies Optimization performance Performance related enhancement
Projects
None yet
Development

No branches or pull requests

3 participants