Skip to content

Commit

Permalink
Merge branch 'master' into merge-back/1.148.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 10, 2022
2 parents 69a50f1 + ab313a4 commit 5c33179
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/issue-label-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,6 @@ env:
{"area":"@aws-cdk/yaml-cfn","keywords":["(aws-yaml-cfn)","(yaml-cfn)"],"labels":["@aws-cdk/aws-yaml-cfn"],"assignees":["skinny85"]},
{"area":"@aws-cdk/aws-apprunner","keywords":["apprunner","aws-apprunner"],"labels":["@aws-cdk/aws-apprunner"],"assignees":["corymhall"]},
{"area":"@aws-cdk/aws-lightsail","keywords":["lightsail","aws-lightsail"],"labels":["@aws-cdk/aws-lightsail"],"assignees":["corymhall"]},
{"area":"@aws-cdk/aws-aps","keywords":["aps","aws-aps","prometheus"],"labels":["@aws-cdk/aws-aps"],"assignees":["corymhall"]}
{"area":"@aws-cdk/aws-aps","keywords":["aps","aws-aps","prometheus"],"labels":["@aws-cdk/aws-aps"],"assignees":["corymhall"]},
{"area":"@aws-cdk/triggers","keywords":["trigger","aws-cdk/triggers","triggers"],"labels":["@aws-cdk/triggers"],"assignees":["otaviomacedo"]}
]
8 changes: 6 additions & 2 deletions packages/@aws-cdk/aws-lambda-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Docker container even if `esbuild` is available in your environment. This can be

## Configuring `esbuild`

The `NodejsFunction` construct exposes some [esbuild options](https://esbuild.github.io/api/#build-api)
The `NodejsFunction` construct exposes [esbuild options](https://esbuild.github.io/api/#build-api)
via properties under `bundling`:

```ts
Expand Down Expand Up @@ -198,7 +198,11 @@ new lambda.NodejsFunction(this, 'my-handler', {
charset: lambda.Charset.UTF8, // do not escape non-ASCII characters, defaults to Charset.ASCII
format: lambda.OutputFormat.ESM, // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js 14.x)
mainFields: ['module', 'main'], // prefer ECMAScript versions of dependencies
inject: ['./my-shim.js', './other-shim.js'] // allows to automatically replace a global variable with an import from another file
inject: ['./my-shim.js', './other-shim.js'], // allows to automatically replace a global variable with an import from another file
esbuildArgs: { // Pass additional arguments to esbuild
"--log-limit": "0",
"--splitting": true,
},
},
});
```
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class Bundling implements cdk.BundlingOptions {
...this.props.charset ? [`--charset=${this.props.charset}`] : [],
...this.props.mainFields ? [`--main-fields=${this.props.mainFields.join(',')}`] : [],
...this.props.inject ? this.props.inject.map(i => `--inject:${i}`) : [],
...this.props.esbuildArgs ? [Object.entries(this.props.esbuildArgs).map(([key, value]) => `${key}="${value}"`).join(' ')] : [],
];

let depsCommand = '';
Expand Down
22 changes: 21 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,32 @@ export interface BundlingOptions {
*/
readonly esbuildVersion?: string;

/**
* Build arguments to pass into esbuild.
*
* For example, to add the [--log-limit](https://esbuild.github.io/api/#log-limit) flag:
*
* ```text
* new NodejsFunction(scope, id, {
* ...
* bundling: {
* esbuildArgs: {
* "--log-limit": "0",
* }
* }
* });
* ```
*
* @default - no additional esbuild arguments are passed
*/
readonly esbuildArgs?: { [key: string]: string | boolean };

/**
* Build arguments to pass when building the bundling image.
*
* @default - no build arguments are passed
*/
readonly buildArgs?: { [key:string] : string };
readonly buildArgs?: { [key: string]: string };

/**
* Force bundling in a Docker container even if local bundling is
Expand Down
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ test('esbuild bundling with esbuild options', () => {
},
format: OutputFormat.ESM,
inject: ['./my-shim.js'],
esbuildArgs: {
'--log-limit': '0',
'--resolve-extensions': '.ts,.js',
'--splitting': 'true',
},
});

// Correctly bundles with esbuild
Expand All @@ -218,7 +223,8 @@ test('esbuild bundling with esbuild options', () => {
assetHashType: AssetHashType.OUTPUT,
bundling: expect.objectContaining({
command: [
'bash', '-c',
'bash',
'-c',
[
'esbuild --bundle "/asset-input/lib/handler.ts"',
'--target=es2020 --platform=node --format=esm --outfile="/asset-output/index.mjs"',
Expand All @@ -227,6 +233,7 @@ test('esbuild bundling with esbuild options', () => {
'--log-level=silent --keep-names --tsconfig=/asset-input/lib/custom-tsconfig.ts',
'--metafile=/asset-output/index.meta.json --banner:js="/* comments */" --footer:js="/* comments */"',
'--charset=utf8 --main-fields=module,main --inject:./my-shim.js',
'--log-limit="0" --resolve-extensions=".ts,.js" --splitting="true"',
].join(' '),
],
}),
Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/pipelines/lib/codepipeline/codebuild-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ export class CodeBuildStep extends ShellStep {
* it finishes its `post_build` phase.
*
* @param variableName the name of the variable for reference.
* @example
* // Access the output of one CodeBuildStep in another CodeBuildStep
* declare const pipeline: pipelines.CodePipeline;
*
* const step1 = new pipelines.CodeBuildStep('Step1', {
* commands: ['export MY_VAR=hello'],
* });
*
* const step2 = new pipelines.CodeBuildStep('Step2', {
* env: {
* IMPORTED_VAR: step1.exportedVariable('MY_VAR'),
* },
* commands: ['echo $IMPORTED_VAR'],
* });
*/
public exportedVariable(variableName: string): string {
if (this.exportedVarsRendered && !this.exportedVariables.has(variableName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ export abstract class CodePipelineSource extends Step implements ICodePipelineAc
* - `RegistryId`
*
* @see https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html#reference-variables-list
* @example
* // Access the CommitId of a GitHub source in the synth
* const source = pipelines.CodePipelineSource.gitHub('owner/repo', 'main');
*
* const pipeline = new pipelines.CodePipeline(scope, 'MyPipeline', {
* synth: new pipelines.ShellStep('Synth', {
* input: source,
* commands: [],
* env: {
* 'COMMIT_ID': source.sourceAttribute('CommitId'),
* }
* })
* });
*/
public sourceAttribute(name: string): string {
return makeCodePipelineOutput(this, name);
Expand Down

0 comments on commit 5c33179

Please sign in to comment.