nuxt / nuxt

The Intuitive Vue Framework.
https://nuxt.com
MIT License
54.86k stars 5.02k forks source link

3.7.x: shared-workspace-lockfile=false now breaks monorepo deps (via layers/modules) (!!) #23077

Open peteromano opened 1 year ago

peteromano commented 1 year ago

Environment

Latest pnpm

Working directory: /home/projects/nuxt-starter-qea1r5/packages/apps/my-app 5:21:21 PM Nuxt project info: 5:21:21 PM


πŸ‘‰ Report an issue: https://github.com/nuxt/nuxt/issues/new 5:21:21 PM

πŸ‘‰ Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new

πŸ‘‰ Read documentation: https://nuxt.com

Reproduction

https://stackblitz.com/edit/nuxt-starter-qea1r5

However, if using shared lock-file (default setting), there is no dep issue:

https://stackblitz.com/edit/nuxt-starter-jgqtiw

Describe the bug

Using a pnpm monorepo, layers and/or modules from filesystem workspace, which have dependencies, no longer build correctly after upgrading to 3.7.1, in both dev and production build.

Since trying ^3.7.0, i get this error now:

[nuxt] Could not resolve id yup /workspace/packages/my-app/index.html

1) i have a module which includes a dependency (yup) 2) And a component in the module uses this dependency (yup) 3) module auto-imports the component. 4) my-app uses the module from the pnpm workspace 5) now getting this error on my-app startup (pnpm dev)

This worked fine in 3.6.5, and is a breaking change

i moved from using a module to using a layer:

1) Layer has dep for yup 2) Layer Component imports yup 3) App extends layer 4) App uses layer component 5) [nuxt] Could not resolve id yup /workspace/packages/my-app/index.html

Happens both as "dependency" or "devDependency".

Happens if using <script setup> or just <script>.

Only works if i install yup directly in my-app (which is unacceptable.)

Additional context

DOES NOT work:

image

WORKS:

image

Logs

No response

stackblitz[bot] commented 1 year ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

peteromano commented 1 year ago

Apparently while writing this up, it looks like a Nitro 2.6.3 update fixes the issue (with the vue dependency warning); will continue testing.

Screenshot shows Nitro 2.6.2, running live stackblitz with 2.6.3 works now.

UPDATE: It's still broken on my local setup.

peteromano commented 1 year ago

@danielroe Ok, I ran a more extensive test..

npm_config_shared_workspace_lockfile=false is what is breaking.

With only a single, shared workspace lock file, things seem to work fine.

However, my setup requires that each app/layer/module in the monorepo have its own lock file (which worked in 3.6.5).

Can this be fixed, or do I have no choice but to use a shared lock file??

peteromano commented 1 year ago

Hey @danielroe @pi0 Any eyes/traction/triage on this issue for next patch release? It's extremely important and regression issue for our project.

EDIT: Just noticed 3.7.3 release -- will try that later today or tomorrow to see if fixed.

danielroe commented 1 year ago

It's unlikely to have been fixed in v3.7.3.

peteromano commented 1 year ago

It's unlikely to have been fixed in v3.7.3.

Umm....... I just tried, looks like 3.7.3, and unless something weird with my setup, it actually looks to be working!

Will keep you posted!

danielroe commented 1 year ago

Oh.... well, great! πŸ™Œ

peteromano commented 1 year ago

My layer is still on 3.6.5 (the app extending the layer is on 3.7.3), so ill upgrade that and Ill remove node_modules and do a full re-install etc. to be sure.

peteromano commented 1 year ago

@danielroe Sorry for false positive, this is still an issue :/

peteromano commented 1 year ago

Can this please get planned for next patch release? It's driving me absolutely crazy; completely kills any value to that pnpm configuration. It's particularly a greater concern for us Docker/container users with monorepo..