Skip to content

Commit

Permalink
Merge pull request #24 from lifeomic/support-external
Browse files Browse the repository at this point in the history
feat: new argument --external
  • Loading branch information
shawnzhu authored Apr 17, 2024
2 parents 078a133 + 616aa18 commit 5eadbe5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ bundle({
});
```

Notice that it could specify esbuild cli argument `--external` by using blamda CLI.
Or using blamda CLI:

```SHELL
blamda --entries=src/*Lambda.ts --external=dtrace-provider
```
68 changes: 38 additions & 30 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,41 @@ import * as yargs from 'yargs';
import { bundle } from '../bundle';

const main = async () => {
const { entries, outdir, node, includeAwsSdk, artifactPrefix } = await yargs(
process.argv.slice(2),
)
.option('entries', {
type: 'string',
description: 'The lambda entrypoints to bundle. Can be a glob pattern.',
demandOption: true,
})
.option('outdir', {
type: 'string',
description: 'The output directory for lambda artifacts',
demandOption: true,
})
.option('node', {
type: 'number',
description: 'The Node version to target.',
demandOption: true,
})
.option('include-aws-sdk', {
type: 'boolean',
description: 'Allow opting out from excluding the aws sdk',
default: false,
})
.option('artifact-prefix', {
type: 'string',
description: 'The artifact prefix within the built zip file',
default: '',
})
.strict()
.parse();
const { entries, outdir, node, includeAwsSdk, artifactPrefix, external } =
await yargs(process.argv.slice(2))
.option('entries', {
type: 'string',
description: 'The lambda entrypoints to bundle. Can be a glob pattern.',
demandOption: true,
})
.option('outdir', {
type: 'string',
description: 'The output directory for lambda artifacts',
demandOption: true,
})
.option('node', {
type: 'number',
description: 'The Node version to target.',
demandOption: true,
})
.option('include-aws-sdk', {
type: 'boolean',
description: 'Allow opting out from excluding the aws sdk',
default: false,
})
.option('artifact-prefix', {
type: 'string',
description: 'The artifact prefix within the built zip file',
default: '',
})
.option('external', {
type: 'string',
description: 'package name to exclude from the bundle',
array: true,
default: '',
})
.strict()
.parse();

await bundle({
entries,
Expand All @@ -43,6 +48,9 @@ const main = async () => {
cwd: process.cwd(),
includeAwsSdk,
artifactPrefix,
esbuild: {
external: Array.isArray(external) ? external : [external],
},
});
};

Expand Down

0 comments on commit 5eadbe5

Please sign in to comment.