@redneckz/slice-node-modules
v0.0.7
Published
Copy only needed modules before going to production (packaging of AWS Lambda, for example)
Downloads
10
Maintainers
Readme
slice-node-modules
List only needed modules to package/archive/zip before going to production (packaging of AWS Lambda, for example)
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]
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
});