quasarframework / quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time
https://quasar.dev
MIT License
25.79k stars 3.5k forks source link

Bug: yarn workspaces in monorepo not working #8078

Open MichaelJCole opened 3 years ago

MichaelJCole commented 3 years ago

Describe the bug I'm trying to replace Next.js with Quasar in this PostGraphile starter project.

I am getting this error:

 ERROR  Failed to compile with 1 errors                                                                                                                                             7:07:23 PM
This dependency was not found:

* /home/michael/xxx/app/@app/client/.quasar/client-entry.js in multi (webpack)-dev-server/client?http://0.0.0.0:8080 (webpack)/hot/dev-server.js ./.quasar/client-entry.js

To install it, you can run: npm install --save /home/michael/xxx/app/@app/client/.quasar/client-entry.js

Codepen/jsFiddle/Codesandbox (required) See git repo

To Reproduce

Clone the starter and replace Next.js client with Quasar

git clone https://github.com/graphile/starter
cd starter

# Move the old Next.js client out of the way
mkdir -p StarterTemplateStuff
mv @app/client StarterTemplateStuff/client

# Create a new project.  In this example it's Quasar.
yarn global add @quasar/cli
quasar create @app/client

Accept all the defaults. Yarn install will fail. Make some fixes for yarn workspaces:

# Now, integrate with the main project:
# 1. Change @app/client/package.json to match package.json
yarn global add json
json -I -f @app/client/package.json -e 'this.name="@app/client"'
json -I -f @app/client/package.json -e 'this.version="0.0.0"'

# 2. Remove Next.js SSR from server
sed -i -e "s|await middleware.installSSR(app);|// await middleware.installSSR(app);|" @app/server/src/app.ts

# 3. Server looks for these files in client
cp -rf StarterTemplateStuff/client/src/graphql @app/client/src

# Install Quasar dependencies and start
cd @app/client 
yarn
quasar dev

# output
 ERROR  Failed to compile with 1 errors                                                                                                                                             7:16:20 PM

This dependency was not found:

* /home/michael/temp/starter/@app/client/.quasar/client-entry.js in multi (webpack)-dev-server/client?http://0.0.0.0:8080 (webpack)/hot/dev-server.js ./.quasar/client-entry.js

To install it, you can run: npm install --save /home/michael/temp/starter/@app/client/.quasar/client-entry.js

Workaround:

# Reset the project
cd ../..
git reset --hard
rm -rf @app/client

# Install w/ defaults, EXCEPT use `npm`
quasar create @app/client
quasar dev

# compiles and runs

Expected behavior quasar to dev w/o errors using yarn workspaces

Platform (please complete the following information): OS: Ubuntu 20.04 Node: v14.15.0 NPM: 6.14.8 Yarn: 1.22.10 Browsers: iOS: Android: Electron:

Additional context

I'm not familiar with this repo, but it seems to reproduce an error referenced in other issues, but lacked a reproducible repo.

https://github.com/quasarframework/quasar/issues/4890 https://github.com/quasarframework/quasar/issues/4835 https://github.com/quasarframework/quasar/pull/4457

hawkeye64 commented 3 years ago

@MichaelJCole I use Yarn Workspaces at work and have now for the past year, with NO issues. Obviously, client is a quasar project.

image

$ yarn workspaces info
yarn workspaces v1.22.5
{
  "@ivt/client": {
    "location": "packages/client",
    "workspaceDependencies": [
      "@ivt/shareable"
    ],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/shareable": {
    "location": "packages/shareable",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/server": {
    "location": "packages/webserver",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/alarms": {
    "location": "packages/services/alarms",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/analytic": {
    "location": "packages/services/analytics",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/archive": {
    "location": "packages/services/archive",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/classification": {
    "location": "packages/services/classification_venv",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/dio": {
    "location": "packages/services/dio_venv",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/liveview": {
    "location": "packages/services/liveview",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/monitor": {
    "location": "packages/services/monitor",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/ptz": {
    "location": "packages/services/ptz",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  },
  "@ivt/weather": {
    "location": "packages/services/weather",
    "workspaceDependencies": [],
    "mismatchedWorkspaceDependencies": []
  }
}
Done in 0.18s.

You can try creating your quasar project outside of the workspace and then move it in when done.

MichaelJCole commented 3 years ago

@hawkeye64 this issue wasn't about YOUR experience with yarn workspaces.

It was a reproduction for the issue I was having, and how it was related to the linked unresolved issues.

"You can try creating your quasar project outside of the workspace and then move it in when done." -- indicates POSSIBLE issue.

You don't have to fix issues @hawkeye64 , and I don't have to patreon denial.

rstoenescu commented 3 years ago

Everyone pls calm down. This issue needs investigating.

hawkeye64 commented 3 years ago

@MichaelJCole Sorry if I ruffled some feathers. I really do apologize.

"You can try creating your quasar project outside of the workspace and then move it in when done."

All I meant by this is to see if it worked for you as part of an investigation. I have used workspaces many times. I have had not had any quasar issues with them. I mean, this could be as simple as you using yarn to keep quasar globally (which I don't), or it may not. The hardest part of this deal is recreating the scenario to a minimal test scenario. Using a larger one just obfisticates what's happening in your case.

MichaelJCole commented 3 years ago

Ok, yes. Thank you for listening. I apologize for being a jerk about the Patreon. I really do appreciate the hard work you've all put into Quasar. It's been a crazy year.

This issue is not critical to me. I moved on from PostGraphile for a variety of reasons. While debugging my last technical issue, I noticed I could create reproducible behavior similar to that in the linked Quasar issues.

The hardest part of this deal is recreating the scenario to a minimal test scenario. Using a larger one just obfisticates what's happening in your case.

I completely agree. yarn workspaces are new to me. I pivoted away from that template because of it's complexity.

Anyways, if this git issue isn't actionable, then let's close it and move forward. Thank you!

hawkeye64 commented 3 years ago

@MichaelJCole I'll let @rstoenescu decide

mesqueeb commented 2 years ago

Maybe unrelated to this issue but I have a npm7 monorepo using workspaces and on Quasar v1 the reactivity & HMR worked throughout the entire monorepo, but with Quasar v2 HMR stopped working.

For example, I have to restart the server if I make a change in an util that's in a separate package in the monorepo.