Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanazharkhan committed Dec 17, 2020
1 parent e4233cd commit 4c5623e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ new lambda.NodejsFunction(this, 'my-handler', {
},
logLevel: LogLevel.SILENT, // defaults to LogLevel.WARNING
keepNames: true, // defaults to false
tsconfig: 'custom-tsconfig.json' // use custom-tsconfig.json instead of default,
metafile: true, // include meta file, defaults to false
banner : '/* comments */', // by default no comments are passed
footer : '/* comments */', // by default no comments are passed
},
});
```
Expand Down
9 changes: 6 additions & 3 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export class Bundling implements cdk.BundlingOptions {

const projectRoot = path.dirname(props.depsLockFilePath);
this.relativeEntryPath = path.relative(projectRoot, path.resolve(props.entry));
this.relativeTsconfigPath = path.relative(projectRoot, path.resolve(props.tsconfig ?? '')); // setting empty string if tsconfig prop is not passed

if (props.tsconfig) {
this.relativeTsconfigPath = path.relative(projectRoot, path.resolve(props.tsconfig));
}

this.externals = [
...props.externalModules ?? ['aws-sdk'], // Mark aws-sdk as external by default (available in the runtime)
Expand Down Expand Up @@ -142,8 +145,8 @@ export class Bundling implements cdk.BundlingOptions {
...loaders.map(([ext, name]) => `--loader:${ext}=${name}`),
...this.props.logLevel ? [`--log-level=${this.props.logLevel}`] : [],
...this.props.keepNames ? ['--keep-names'] : [],
...this.props.tsconfig ? [`--tsconfig=${pathJoin(inputDir, this.relativeTsconfigPath!)}`] : [],
...this.props.metaFile ? [`--metafile=${pathJoin(outputDir, 'index.meta.json')}`] : [],
...this.relativeTsconfigPath ? [`--tsconfig=${pathJoin(inputDir, this.relativeTsconfigPath)}`] : [],
...this.props.metafile ? [`--metafile=${pathJoin(outputDir, 'index.meta.json')}`] : [],
...this.props.banner ? [`--banner='${this.props.banner}'`] : [],
...this.props.footer ? [`--footer='${this.props.footer}'`] : [],
].join(' ');
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface BundlingOptions {
* @see https://esbuild.github.io/api/#metafile
* @default - false
*/
readonly metaFile?: boolean
readonly metafile?: boolean

/**
* Use this to insert an arbitrary string at the beginning of generated JavaScript files.
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ test('esbuild bundling with esbuild options', () => {
logLevel: LogLevel.SILENT,
keepNames: true,
tsconfig,
metaFile: true,
metafile: true,
banner: '/* comments */',
footer: '/* comments */',
forceDockerBundling: true,
Expand Down

0 comments on commit 4c5623e

Please sign in to comment.