Skip to content

Share dependencies through an npm workspace #3130

@cprecioso

Description

@cprecioso

Description

Turn the user’s package.json into an npm workspace, containing the user project and the ./wasp/* generated projects.

  • Projects refer to one another through workspace dependencies instead of path aliases, copying files, or relative ../../.. paths.
  • Dependencies are installed once overall, not once per package.json
  • Versions are resolved taking into account all of the ranges, not just the current package.json, and de-duplicated.
  • package-lock.json also locks the versions in the generated project, instead of upgrading them to the latest allowable version every time.

Edge cases to look for: what happens when the generated projects…

  • don’t exist yet?
  • need to be recreated?
  • have just been recreated?
  • we’ve updated the Wasp version?
  • is there a situation in which we’d have out-of-sync generated projects or dependencies?

Warning

Apparently, npm doesn't allow multiple subprojects with the same name in the same workspace. We generate the same projects at .wasp/out/ and .wasp/build, so we need to find a solution or workaround.

Steps

  • Check Wasp behaves correctly with package.json#workspaces
  • Check that dependencies are correctly shared
  • Edit the starter package.json's to have the workspaces key
  • Add a check for workspaces in the compiler
  • Adapt wasp deps command
  • Test that dependency checking logic inside waspc still works correctly
  • Add a migration guide and documentation

Related issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions