diff --git a/README.md b/README.md index 11e8ae5d..37254fd3 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ custom: strip: false ``` -### Lamba Layer +### Lambda Layer Another method for dealing with large dependencies is to put them into a [Lambda Layer](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). Simply add the `layer` option to the configuration. @@ -439,6 +439,35 @@ zipinfo .serverless/xxx.zip ``` (If you can't see the library, you might need to adjust your package include/exclude configuration in `serverless.yml`.) +## Optimising packaging time + +If you wish to exclude most of the files in your project, and only include the source files of your lambdas and their dependencies you may well use an approach like this: + +```yaml +package: + individually: false + include: + - "./src/lambda_one/**" + - "./src/lambda_two/**" + exclude: + - "**" +``` + +This will be very slow. Serverless adds a default `"**"` include. If you are using the `cacheLocation` parameter to this plugin, this will result in all of the cached files' names being loaded and then subsequently discarded because of the exclude pattern. To avoid this happening you can add a negated include pattern, as is observed in https://github.com/serverless/serverless/pull/5825. + +Use this approach instead: + +```yaml +package: + individually: false + include: + - "!./**" + - "./src/lambda_one/**" + - "./src/lambda_two/**" + exclude: + - "**" +``` + ## Contributors * [@dschep](https://github.com/dschep) - Lead developer & maintainer * [@azurelogic](https://github.com/azurelogic) - logging & documentation fixes diff --git a/lib/pip.js b/lib/pip.js index 3da432af..323a92fb 100644 --- a/lib/pip.js +++ b/lib/pip.js @@ -610,10 +610,9 @@ function installAllRequirements() { !fse.existsSync(symlinkPath) && reqsInstalledAt != symlinkPath ) { - // Windows can't symlink so we have to copy on Windows, - // it's not as fast, but at least it works + // Windows can't symlink so we have to use junction on Windows if (process.platform == 'win32') { - fse.copySync(reqsInstalledAt, symlinkPath); + fse.symlink(reqsInstalledAt, symlinkPath, 'junction'); } else { fse.symlink(reqsInstalledAt, symlinkPath); }