-
Notifications
You must be signed in to change notification settings - Fork 417
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
Support optional use of Yarn for packaging (instead of NPM) #286
Comments
What's the status on this? Why doesn't this work while using |
Because the plugin internally uses npm - and these are orthogonal in some regions (esp. workspaces and links - and finally the lock files). Regarding the timeline: I'll try my best to phase this in asap. In general, it would work like this: But first, from the architecture of the project, the packager itself (npm) should be abstracted into separate classes, so that yarn just can be added as additional packager. This approach will keep the way open for other packagers. |
Thanks! Would |
No, only |
@HyperBrain Thank you very much for the package. |
@OlzhasAlexandrov Thanks for the hint :) I will consider it. As soon as I have something available in a PR, I'll write here, so that people can start testing and verifying. |
Update: Seems the first version of the Yarn packager works:
This output is Yarn, not npm!
I will try to prepare a PR tomorrow, so that we have something that we can base further ideas (especially options and their defaults) onto. Stay tuned. |
At everyone here: The initial PR is available and ready for testing. I'll continue with the unit tests and proper documentation there. Please use BUT: Bear in mind, that the PR is based on the just released version 5 of the plugin and you need to switch to the new configuration layout in serverless.yml to make it work with yarn. (low risk and easy) [UPDATE: use the |
I will merge the PR in the next few days. As mentioned in the PR, flat support is dropped for now. The feature in general should be functional. If we encounter any issues, we should create separate issues for them and fix them or add missing stuff separately. |
Does this have any impact for those of us not using webpack? The "Excluding development dependencies..." step takes awhile for me and I figure yarn would be faster than npm. Edit: Nevermind, just saw the repository is specifically webpack. |
@bfsmith |
Any idea why I'm getting |
@dashmug Then it does not find the yarn executable during packging (I assume you enabled it with `webpack: pacakger: yarn). Is it available in the serverless' command environment (path)? The plugin spawns |
Yes, I think it might be just specific to my setup. I believe one of the following (or both) reasons may have caused it.
|
(2) Might be the problem. As far as I remember the installation of global modules (like npm or yarn) is put into the specific node installation and tightly bound to the node version. I experienced that with So you should install yarn into the Node 6.10 context too, and it should work. |
Released with 5.1.0 |
Nice work @HyperBrain I'm impressed! |
@HyperBrain It turns out I got that error on v5.0.0 and I thought this PR was included in that release. Updated to v5.1.0 now and it worked flawlessly despite Good job! |
Is this meant to work with yarn workspaces? I'm getting Also, for some reason I only have this issue when deploying to API Gateway and not when using serverless-offline. |
@dekryptic I did not try it with yarn workspaces, but the lockfile error normally means, that Yarn would change the lockfile during a Yarn install, i.e. the lockfile does not represent the contents of the package json. Do you have anything in your setup that changes only the package.json but does not update the lockfile? Can you try the very same with the latest
That is expected. |
@HyperBrain Thank you for the quick response. I've upgraded to 5.1.5, but I think the problem is related to the nature of yarn workspaces. The basic premise is that you can have multiple package.json's in your subdirectories that specify your project's dependencies, so almost by definition the lockfile would have packages that are not present in the base package.json file. Well, at least this is what I understand. |
@dekryptic Yeah. I think you're right. Maybe the best way would be that you create a separate feature request for support of Yarn workspaces. We could then do explicit experiments for that and document the behavior of Yarn, its lockfiles and the workspaces there to be able to find a proper solution. |
Hey! 👋
As discussed here with @HyperBrain, it'd be great if we could optionally use Yarn for packaging files, instead of NPM. 🙂
In particular, since
serverless-webpack
completely relies on NPM and uses it for packaging files, I'm having issues usingserverless-webpack
with Yarn Workspaces.Currently, the bundled file is very huge (4 MB when used with
Yarn Workspaces
) compared to the same project when not used withYarn Workspaces
(25 kB).serverless-webpack
bundles all the dependencies in one file even when usingwebpack-node-externals
andwebpackIncludeModules
.Thanks! 😃
The text was updated successfully, but these errors were encountered: