Skip to content

Commit

Permalink
Merge pull request #5 from beforeyoubid/bug/bundling-aws-libraries
Browse files Browse the repository at this point in the history
avoid bundling aws libraries as they come by default
  • Loading branch information
alice-byb authored Apr 18, 2023
2 parents 932590a + 4c3c67b commit 363ad0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-esbuild-layers",
"version": "0.1.0",
"version": "0.1.1",
"author": {
"name": "Bailey Sheather",
"email": "[email protected]",
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# serverless-esbuild-layers

[![Test Coverage](https://api.codeclimate.com/v1/badges/e5f4215f1f3f63aad0eb/test_coverage)](https://codeclimate.com/github/beforeyoubid/serverless-esbuild-layers/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/e5f4215f1f3f63aad0eb/maintainability)](https://codeclimate.com/github/beforeyoubid/serverless-esbuild-layers/maintainability)

Plugin for the [Serverless framework][serverless] that allows you to leverage Lambda layers to separate your node modules into layers attached to relevant functions.

This helps to keep the overall function size down.
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ export const DEFAULT_CONFIG: Config = {
clean: true,
minify: false,
};

export const DEFAULT_AWS_MODULES: string[] = ['aws-sdk', 'aws-xray-sdk'];
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nodeExternalsPlugin from 'esbuild-node-externals';
import isBuiltinModule from 'is-builtin-module';

import type { Maybe, FunctionWithConfig, Layer, Config } from './types';
import { DEFAULT_CONFIG } from './constants';
import { DEFAULT_CONFIG, DEFAULT_AWS_MODULES } from './constants';

import { exec as execNonPromise, ExecOptions, ExecException } from 'child_process';
import util from 'util';
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function getExternalModules(serverless: Serverless, layerRefName: s
.reduce((list, listsOfMods) => list.concat(...listsOfMods), [])
.filter(module => !isBuiltinModule(module))
);
return Array.from(imports);
return Array.from(imports).filter(dep => !DEFAULT_AWS_MODULES.includes(dep));
}

export function compileConfig(userConfig: Partial<Config>): Config {
Expand Down

0 comments on commit 363ad0e

Please sign in to comment.