Skip to content

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

@zheeeng

Description

@zheeeng

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeat: deps optimizerEsbuild Dependencies OptimizationperformancePerformance related enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions