winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.07k stars 198 forks source link

Winglibs don't work with yarn or pnpm #6129

Open eladcon opened 8 months ago

eladcon commented 8 months ago

I tried this:

try @winglibs/cognito with yarn as the package manager

This happened:

An error has occurred:
Failed to compile.

error: Unable to load "@cdktf/provider-aws": Module not found in "/private/tmp/a2/node_modules/@winglibs/cognito/platform/tfaws.w"
  --> node_modules/@winglibs/cognito/platform/tfaws.w:3:1
  |
3 | bring "@cdktf/provider-aws" as aws;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unable to load "@cdktf/provider-aws": Module not found in "/private/tmp/a2/node_modules/@winglibs/cognito/platform/tfaws.w"

I expected this:

No response

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

MarkMcCulloh commented 8 months ago

Wing's ecosystem makes heavy use of peer dependencies. yarn does not have a builtin way to install peer dependencies. In addition to that, the now-default PnP mechanism that yarn uses is likely not something we're going to support anytime soon.

Given that, I don't think yarn is something we will support. npm is the only officially supported package manager for now while pnpm and bun both unofficially work as well.

A workaround if yarn must be used, it must not be with the PnP nodeLinker mode and any peer dependencies must be manually installed. For example, to use @winglibs/cognito you must run yarn add @winglibs/cognito @cdktf/provider-aws cdktf constructs

To close out this issue we should officially document package manager support level.

ekeren commented 8 months ago

Does this issue only surface when installing a @winglib? Or are there issues if I install wing with yarn add (not globally)

Chriscbr commented 4 months ago

In the meantime we might be able to soften the blow of these errors by raise a compiler warning if there's a yarn.lock or pnpm-lock.yaml file in the project, e.g.

Warning: We noticed you have a pnpm/yarn/bun lockfile. Wing hasn't been tested with package managers besides npm, so it may be unable to resolve dependencies to Wing libraries when using these tools. See https://github.com/winglang/wing/issues/6129 for more details.