-
Notifications
You must be signed in to change notification settings - Fork 4k
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
aws-lambda-nodejs: Does not support Yarn Berry (3.2.x) Pnp (Plug-and-play) #21161
Comments
A workaround that works, but is not great, is to simply turn off the pnp mode in yarn // .yarnrc.yml
nodeLinker: node-modules |
@vleandersson I saw you commenting on #18175 as well. I didn't realize that one had been closed so I reopened it. There is also another issue that is asking for the library to be re-written to use the esbuild API instead of the CLI. I am not opposed to updating this module to support those use cases, but the core team will not be able to pick this up to design an implement a solution. I think if the community is able to come up with a design and willing to implement a solution with @jogold help we would be able to provide a final review. There are a couple of things that concern me with this module and our ability to support it long term.
|
Tossing in another vote for using ESBuild via the API so we can leverage plugins. I quite literally cannot use |
I'm going to close this issue in favor of the other two linked issues. |
|
Describe the bug
Intro
When building using a mono-repo with Yarns Pnp (plug-and-play) mode, AWS CLIs
NodejsFunction
fails to bundle dependencies. This results in errors likeCould not resolve YYY: import XXX from YYY
. Using the pureesbuild
script, we can easily manage to replicate the issue. But don't be fooled by the reference of an issue in another package - as they got a solution for it.Diving into the details a bit more
Using a simple monorepo setup by Yarn, we got a parent module (root) with a package.json with only esbuild installed. In the workspace package, we have all our CDK managed resources, as well as a package.json referencing all our build and lambda dependencies.
For yarn without pnp, this works fine, as running eslint in the root folder will still have access to the packages for all child workspaces. Pnp disallows this, leaving esbuild with only access to the root packages.
Esbuilds solution
The solution esbuild came up with is a simple plugin, connecting yarn pnp and eslint. This was born from this discussion
Why this does not work with
NodejsFunction
The implementation for
NodejsFunction
is currently relying on esbuilds CLI. The direction of the community seems to be that the recommended way is to use the Node js API instead, allowing a larger access to esbuild options, including plugins.That we are not allowed to add plugins to the Esbuild CLI seems to be a design choice that will not change in the near future
Expected Behavior
Current Behavior
yarn berry pnp
is not supportedReproduction Steps
NodejsFunction
cdk synth
Possible Solution
Suggestion
We change the command we run for esbuild to execute a node command, targeting an
esbuild.config.js
file. I've drafted a simple implementation that works;We could then expose the plugins option and add documentation for how to enable pnp with yarn here.
Additional Information/Context
No response
CDK CLI Version
2.31.0
Framework Version
Yarn berry 3
Node.js Version
16.15.0
OS
macOS Monterey
Language
Typescript
Language Version
typescript 4.7.4
Other information
No response
The text was updated successfully, but these errors were encountered: