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

Solve double installation issue in restructuring #1640

Open
sodic opened this issue Jan 17, 2024 · 4 comments
Open

Solve double installation issue in restructuring #1640

sodic opened this issue Jan 17, 2024 · 4 comments
Labels
bug Something isn't working post-0.12.0 restructuring

Comments

@sodic
Copy link
Contributor

sodic commented Jan 17, 2024

Note

Could be solved by #1838

[no longer up to date] How to reproduce:

  1. Checkout filip-project-install-step
  2. Go to waspc/examples/todo-typescript
  3. Run rm -r .wasp node_modules package-lock.json migrations; cabal run wasp-cli db migrate-dev -- --name init && cabal run wasp-cli start
  4. Open the browser, you should see a white screen and a console full of errors caused by a double react installation

How to fix (temporarily):

  • Run ./fix and restart the app (with cabal run wasp-cli start). This script deletes the redundant react installation and Vite's cache.

Ideas on approaching the issue:

  • How does the SDK resolve React? How does the user's code resolve React? How does our web app's code resolve React? We should figure out who uses which React installation

  • This question is related to the first bullet, but it might make sense to figure out what triggered this behavior now. The problem only appeared after I merged the auth stuff into the restructuring branches.

    To compare the old build output with the new output, I recommend:

    1. Checking out the last commit before the auth merge: git checkout ea5a4c
    2. Running rm -r .wasp node_modules package-lock.json migrations; cabal run wasp-cli db migrate-dev -- --name init && cabal run wasp-cli start
    3. Comparing the resulting .wasp folder with the folder you get when running the same command on the latest commit (here's a good extension for this).

Possible solutions:

  • Prevent NPM (or Vite) from installing a package if it's already available (i.e., there's a node_modules folder higher up the directory tree with the installed package, as is the case for us)
  • Use NPM workspaces (maybe): https://iws.io/2022/invalid-hook-multiple-react-instances
  • List React as SDK's peerDependency - tried it, doesn't work (see here)
  • Ask Fran Zekan what he thinks
@infomiho infomiho self-assigned this Jan 18, 2024
@infomiho
Copy link
Contributor

I believe we solved this issues by using the dedupe option in Vite. There were some build issues afterwards, but they seemed unrelated. I'll let @sodic close this when he thinks it's appropriate

@sodic
Copy link
Contributor Author

sodic commented Jan 18, 2024

I wouldn't close it until we figure out what's causing those build issues. Since they weren't happening unless we do dedupe, they probably are related.

@infomiho
Copy link
Contributor

infomiho commented Jan 19, 2024

Some suggestions from the author of the React plugin for Vite that we use: vitejs/vite-plugin-react-swc#184 (comment)

@sodic
Copy link
Contributor Author

sodic commented Jan 21, 2024

This issue is not react-specific. For example, if one of our inner dependencies (i.e, package.json files inside web-app and server) specifies prisma/client as a dependency, the runtime resolves to the wrong prisma/client installation and breaks.

We've temporarily avoided this problem by moving all the stuff that depends on prisma/client into sdk/package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working post-0.12.0 restructuring
Projects
None yet
Development

No branches or pull requests

2 participants