-
Notifications
You must be signed in to change notification settings - Fork 416
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 yarn 2 version #642
Comments
There is also an issue with using the "yarn list" command that happens before the install. Sadly, yarn 2 has not implemented the yarn list command. yarnpkg/berry#720 |
It looks like |
I tried your feature proposals but I have some issues
And install still fail
|
@reskir This issue is still open, in the interim have you found a workaround that works with serverless-webpack? I'm planning to patch it locally, wondering if there's a better solution? |
I have built my own plugin which perfectly fits with our monorepo project and yarn 2. These plugins are not silver bullets, they were created for specific needs, so I strongly recommend writing your own |
Thanks @reskir is your plugin something that you can share as a base to start with if it at least solves part of the problem? |
@theseyi the main challenge is to gather all dependencies for the lambda function. So what we have done – separate each function to separate folders with Write hook for compilying assets on The function should accept two arguments – the root directory of const transformDirectory = async (
babelOptions,
shouldTranspile,
srcDir,
destDir,
fileList = []
) => {
// mkdirp to ensure destDir exists
const [files] = await Promise.all([readdir(srcDir), mkdirp(destDir)]);
const config = {
appRoot, //lambdaRoot
monoRoot
};
for (const file of files) {
if (config.monoRoot && file === 'node_modules') {
continue;
}
const srcFilePath = path.join(srcDir, file);
const destFilePath = path.join(destDir, file);
const fileStats = await stat(srcFilePath);
if (fileStats.isDirectory()) {
await transformDirectory(
babelOptions,
shouldTranspile,
srcFilePath,
destFilePath,
fileList
);
} else if (shouldTranspile(srcFilePath)) {
await babelFile(babelOptions, srcFilePath, destFilePath);
} else {
await copyFile(srcFilePath, destFilePath);
}
}
return fileList;
}; |
I faced the same problem with Yarn berry monorepo and just passed
I started with removing the abandoned options of After that I found
and modified their package names so that they won't be duplicated. Then I'm wondering Here's my patch could be used with |
@shinnoki Thank you. I'm on the same path (Yarn2 monorepo). Applying your patch, for me the package command still fails, if dependencies are excluded (e. g. for webpack incompatible modules) – but only, if I have multiple functions and set individual packing to be true. Having a single function works, but fails if I add a second. Relevant parts of my config: // webpack.config.js
// ...
externals: [
nodeExternals(),
nodeExternals({ modulesDir: path.resolve(__dirname, "../../node_modules") }),
], package:
individually: true
// serverless.yml webpack config
custom:
webpack:
webpackConfig: "./webpack.config.js"
keepOutputDirectory: true
packager: "yarn"
packagerOptions:
noFrozenLockfile: true
includeModules:
nodeModulesRelativeDir: "../../"
forceExclude: |
Any update on this issue and adding support for Yarn2 to this plugin? |
I've found this serverless plugin https://github.com/Butterwire/serverless-plugin-monorepo to automatically create symlinks during deployment. Unfortunately, I still run into this error:
|
Was someone able to have the plugin working with yarn 2? Getting the same error // serverless.ts
// ...
custom: {
webpack: {
packager: 'yarn',
packagerOptions: {
noFrozenLockfile: true,
},
includeModules: {
nodeModulesRelativeDir: '../../',
forceInclude: ['bull'],
forceExclude: [
'aws-sdk'
],
},
},
}, // webpack.config.ts
// ...
externals: [
nodeExternals({
allowlist: ['bull'],
modulesDir: path.resolve(__dirname, '../../node_modules'),
}),
'aws-sdk',
], |
Have you tried to launch |
Hi @j0k3r. I've got this Any way to take out this flag? |
Even if we removed the
I've removed the yarn.lock from the root directory and I've added the directory as workspace (not sure if there are workspaces conflicts because the parent directory it's also a workspace), but the problem persists. |
Bump on this - I'm running into this too with yarn version 3.1.0 & latest |
Has anyone had any luck with this? I've tried everything, nothing seems to work or make sense. |
@mrowles I ended up setting the version |
@francisu were you ever able to get this working with either yarn v1 or berry? |
I'm using serverless-webpack 5.5.4 with yarn 3 (berry) and it's working fine. I do specify "includeModules: false" in my serverless configuration and have my own webpack.config. |
@francisu got it, thanks for responding. I've started to get my feet wet in the serverless world. a couple questions if you don't mind:
many thanks |
I did this work a long time ago so I'm not fresh on the details. I remember hitting various problems which I think are reflected in the webpack.config.js file. I'm using version 5.66 of webpack. |
thanks @francisu ! |
@fabioDMFerreira were you ever able to get this working? |
Yes, I had @eugene-kim. I can't remember the exact solution, but it was resolved after changing dependencies versions. These are some packages versions we are using in our project. |
@fabioDMFerreira Same, but what are your tsconfig, webpack.config and serverless.yml > custom > webpack settings (specifically around this packing modules) - I've tried everything under the sun. I either get it compiling with no deps packed and it's tiny (throws tslib req errors in AWS) or it's huge with all deps. |
tsconfig.json
serverless.ts
webpack.config.js
There is nothing special in my files. @mrowles Do you have a small open source repository where you have this issue? |
@fabioDMFerreira Thanks mate, appreciate it. Your config looks pretty normal tbh + I've definitely tried this setup before. It has to be something weird I'm doing. I'll keep hacking away in the meantime. |
I just got packaging to work as expected for myself. Not sure if this is relevant to other situations, but I figured I'd share. I'm using yarn berry (3.1.1) and even after applying the changes that @shinnoki shared (many thanks, btw!) to remove yarn v1 cli options, packaging was an issue. Updating my nmSelfReferences: false Removed the self references that were messing up with webpack and causing out of memory errors. More info on |
Thanks @shinnoki for the patch! It is working great for a small package of the monorepo. But I'm running into errors with a larger one. The build throw a lot of warnings, which I think can not be simply ignored:
Is it something you encountered also? .yarnrc.yml
root package.json
package.json
serverless.yml
webpack.config.js (all my projects starts with @pw/*)
|
Could you please just allow an option like this 🙏 const args = [ 'install' ];
// Convert supported packagerOptions
if (!packagerOptions.noNonInteractive) {
args.push('--non-interactive');
} It is so annoying to have to patch the lib in postinstall 😕 |
Add support for
Yarn 2.*
Description
For bug reports:
Running
sls package
with yarn 2.22.2 results in error:What did you expect should have happened?
Build package without any errors
What was the config you used?
For feature proposals:
Update this command
serverless-webpack/lib/packagers/yarn.js
Line 120 in 38135e4
So it will executed succesfully with
yarn 2.*
version. Example:yarn install --immutable --immutable-cache
https://yarnpkg.com/cli/install
Additional Data
The text was updated successfully, but these errors were encountered: