Skip to content

Copy only needed modules before going to production (packaging of AWS Lambda, for example)

License

Notifications You must be signed in to change notification settings

redneckz/slice-node-modules

Repository files navigation

slice-node-modules

List only needed modules to package/archive/zip before going to production (packaging of AWS Lambda, for example)

NPM Version Build Status Coverage Status Bundle size

Installation

npm install --save-dev @redneckz/slice-node-modules

Using npx:

npx @redneckz/slice-node-modules \
  [-e <source file>] [-p <package.json>] \
  [--dev|-D] \
  [--print0|-0] \
  [--include <glob>] [--exclude <glob>] \
  [--zip <zip file>]

How-to

List all packages used by some-package:

$ # Parse dependencies from source files (-e stands for entry file)
$ npx @redneckz/slice-node-modules -e some-package/lib/index.js
$ # or from package.json
$ npx @redneckz/slice-node-modules -p some-package/package.json

Dev. dependencies:

$ npx @redneckz/slice-node-modules -e some-package/lib/index.js --dev

Filtering options --include/--exclude:

$ npx @redneckz/slice-node-modules -e some-package/lib/index.js --exclude 'aws-*'

Zero-separated (for xargs, for example):

$ npx @redneckz/slice-node-modules -e some-package/lib/index.js --print0

AWS Lambda Packaging

In case of monorepo (just for example):

$ npx @redneckz/slice-node-modules \
  -e monorepo-root/packages/some-lambda/lib/index.js \
  --exclude 'aws-*' \
  --zip some-lambda.zip

AWS Lambda config (CloudFormation):

const logLambda = new Function(this, 'some-lambda', {
  code: new AssetCode('some-lambda.zip'),
  handler: 'monorepo-root/packages/some-lambda/lib/index.handler',
  runtime: Runtime.NODEJS_12_X
});

License

MIT

About

Copy only needed modules before going to production (packaging of AWS Lambda, for example)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published