Class: AWSCDK::LambdaNodejs::BundlingOptions

Inherits:
DockerRunOptions
  • Object
show all
Defined in:
lambda_nodejs/bundling_options.rb

Overview

Bundling options.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command: nil, entrypoint: nil, environment: nil, network: nil, platform: nil, security_opt: nil, user: nil, volumes: nil, volumes_from: nil, working_directory: nil, asset_hash: nil, banner: nil, build_args: nil, bundle_aws_sdk: nil, bundling_file_access: nil, charset: nil, command_hooks: nil, define: nil, docker_image: nil, esbuild_args: nil, esbuild_version: nil, external_modules: nil, footer: nil, force_docker_bundling: nil, format: nil, inject: nil, keep_names: nil, loader: nil, log_level: nil, main_fields: nil, metafile: nil, minify: nil, node_modules: nil, pre_compilation: nil, source_map: nil, source_map_mode: nil, sources_content: nil, target: nil, tsconfig: nil) ⇒ BundlingOptions

Returns a new instance of BundlingOptions.

Parameters:

  • command (Array<String>, nil) (defaults to: nil)

    The command to run in the container.

  • entrypoint (Array<String>, nil) (defaults to: nil)

    The entrypoint to run in the container.

  • environment (Hash{String => String}, nil) (defaults to: nil)

    The environment variables to pass to the container.

  • network (String, nil) (defaults to: nil)
  • platform (String, nil) (defaults to: nil)

    Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

  • security_opt (String, nil) (defaults to: nil)

    Security configuration when running the docker container.

  • user (String, nil) (defaults to: nil)

    The user to use when running the container.

  • volumes (Array<AWSCDK::DockerVolume>, nil) (defaults to: nil)

    Docker volumes to mount.

  • volumes_from (Array<String>, nil) (defaults to: nil)

    Where to mount the specified volumes from.

  • working_directory (String, nil) (defaults to: nil)

    Working directory inside the container.

  • asset_hash (String, nil) (defaults to: nil)

    Specify a custom hash for this asset.

  • banner (String, nil) (defaults to: nil)

    Use this to insert an arbitrary string at the beginning of generated JavaScript files.

  • build_args (Hash{String => String}, nil) (defaults to: nil)

    Build arguments to pass when building the bundling image.

  • bundle_aws_sdk (Boolean, nil) (defaults to: nil)

    Includes AWS SDK in the bundle asset.

  • bundling_file_access (AWSCDK::BundlingFileAccess, nil) (defaults to: nil)

    Which option to use to copy the source files to the docker container and output files back.

  • charset (AWSCDK::LambdaNodejs::Charset, nil) (defaults to: nil)

    The charset to use for esbuild's output.

  • command_hooks (AWSCDK::LambdaNodejs::ICommandHooks, nil) (defaults to: nil)

    Command hooks.

  • define (Hash{String => String}, nil) (defaults to: nil)

    Replace global identifiers with constant expressions.

  • docker_image (AWSCDK::DockerImage, nil) (defaults to: nil)

    A custom bundling Docker image.

  • esbuild_args (Hash{String => String, Boolean}, nil) (defaults to: nil)

    Build arguments to pass into esbuild.

  • esbuild_version (String, nil) (defaults to: nil)

    The version of esbuild to use when running in a Docker container.

  • external_modules (Array<String>, nil) (defaults to: nil)

    A list of modules that should be considered as externals (already available in the runtime).

  • footer (String, nil) (defaults to: nil)

    Use this to insert an arbitrary string at the end of generated JavaScript files.

  • force_docker_bundling (Boolean, nil) (defaults to: nil)

    Force bundling in a Docker container even if local bundling is possible.

  • format (AWSCDK::LambdaNodejs::OutputFormat, nil) (defaults to: nil)

    Output format for the generated JavaScript files.

  • inject (Array<String>, nil) (defaults to: nil)

    This option allows you to automatically replace a global variable with an import from another file.

  • keep_names (Boolean, nil) (defaults to: nil)

    Whether to preserve the original name values even in minified code.

  • loader (Hash{String => String}, nil) (defaults to: nil)

    Use loaders to change how a given input file is interpreted.

  • log_level (AWSCDK::LambdaNodejs::LogLevel, nil) (defaults to: nil)

    Log level for esbuild.

  • main_fields (Array<String>, nil) (defaults to: nil)

    How to determine the entry point for modules.

  • metafile (Boolean, nil) (defaults to: nil)

    This option tells esbuild to write out a JSON file relative to output directory with metadata about the build.

  • minify (Boolean, nil) (defaults to: nil)

    Whether to minify files when bundling.

  • node_modules (Array<String>, nil) (defaults to: nil)

    A list of modules that should be installed instead of bundled.

  • pre_compilation (Boolean, nil) (defaults to: nil)

    Run compilation using tsc before running file through bundling step.

  • source_map (Boolean, nil) (defaults to: nil)

    Whether to include source maps when bundling.

  • source_map_mode (AWSCDK::LambdaNodejs::SourceMapMode, nil) (defaults to: nil)

    Source map mode to be used when bundling.

  • sources_content (Boolean, nil) (defaults to: nil)

    Whether to include original source code in source maps when bundling.

  • target (String, nil) (defaults to: nil)

    Target environment for the generated JavaScript code.

  • tsconfig (String, nil) (defaults to: nil)

    Normally the esbuild automatically discovers tsconfig.json files and reads their contents during a build.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lambda_nodejs/bundling_options.rb', line 46

def initialize(command: nil, entrypoint: nil, environment: nil, network: nil, platform: nil, security_opt: nil, user: nil, volumes: nil, volumes_from: nil, working_directory: nil, asset_hash: nil, banner: nil, build_args: nil, bundle_aws_sdk: nil, bundling_file_access: nil, charset: nil, command_hooks: nil, define: nil, docker_image: nil, esbuild_args: nil, esbuild_version: nil, external_modules: nil, footer: nil, force_docker_bundling: nil, format: nil, inject: nil, keep_names: nil, loader: nil, log_level: nil, main_fields: nil, metafile: nil, minify: nil, node_modules: nil, pre_compilation: nil, source_map: nil, source_map_mode: nil, sources_content: nil, target: nil, tsconfig: nil)
  @command = command
  Jsii::Type.check_type(@command, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "command") unless @command.nil?
  @entrypoint = entrypoint
  Jsii::Type.check_type(@entrypoint, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "entrypoint") unless @entrypoint.nil?
  @environment = environment
  Jsii::Type.check_type(@environment, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "environment") unless @environment.nil?
  @network = network
  Jsii::Type.check_type(@network, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "network") unless @network.nil?
  @platform = platform
  Jsii::Type.check_type(@platform, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "platform") unless @platform.nil?
  @security_opt = security_opt
  Jsii::Type.check_type(@security_opt, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "securityOpt") unless @security_opt.nil?
  @user = user
  Jsii::Type.check_type(@user, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "user") unless @user.nil?
  @volumes = volumes.is_a?(Array) ? volumes.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::DockerVolume.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : volumes
  Jsii::Type.check_type(@volumes, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLkRvY2tlclZvbHVtZSJ9LCJraW5kIjoiYXJyYXkifX0=")), "volumes") unless @volumes.nil?
  @volumes_from = volumes_from
  Jsii::Type.check_type(@volumes_from, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "volumesFrom") unless @volumes_from.nil?
  @working_directory = working_directory
  Jsii::Type.check_type(@working_directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "workingDirectory") unless @working_directory.nil?
  @asset_hash = asset_hash
  Jsii::Type.check_type(@asset_hash, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assetHash") unless @asset_hash.nil?
  @banner = banner
  Jsii::Type.check_type(@banner, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "banner") unless @banner.nil?
  @build_args = build_args
  Jsii::Type.check_type(@build_args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildArgs") unless @build_args.nil?
  @bundle_aws_sdk = bundle_aws_sdk
  Jsii::Type.check_type(@bundle_aws_sdk, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "bundleAwsSDK") unless @bundle_aws_sdk.nil?
  @bundling_file_access = bundling_file_access
  Jsii::Type.check_type(@bundling_file_access, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5CdW5kbGluZ0ZpbGVBY2Nlc3MifQ==")), "bundlingFileAccess") unless @bundling_file_access.nil?
  @charset = charset
  Jsii::Type.check_type(@charset, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX25vZGVqcy5DaGFyc2V0In0=")), "charset") unless @charset.nil?
  @command_hooks = command_hooks
  Jsii::Type.check_type(@command_hooks, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX25vZGVqcy5JQ29tbWFuZEhvb2tzIn0=")), "commandHooks") unless @command_hooks.nil?
  @define = define
  Jsii::Type.check_type(@define, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "define") unless @define.nil?
  @docker_image = docker_image
  Jsii::Type.check_type(@docker_image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Eb2NrZXJJbWFnZSJ9")), "dockerImage") unless @docker_image.nil?
  @esbuild_args = esbuild_args
  Jsii::Type.check_type(@esbuild_args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InVuaW9uIjp7InR5cGVzIjpbeyJwcmltaXRpdmUiOiJzdHJpbmcifSx7InByaW1pdGl2ZSI6ImJvb2xlYW4ifV19fSwia2luZCI6Im1hcCJ9fQ==")), "esbuildArgs") unless @esbuild_args.nil?
  @esbuild_version = esbuild_version
  Jsii::Type.check_type(@esbuild_version, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "esbuildVersion") unless @esbuild_version.nil?
  @external_modules = external_modules
  Jsii::Type.check_type(@external_modules, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "externalModules") unless @external_modules.nil?
  @footer = footer
  Jsii::Type.check_type(@footer, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "footer") unless @footer.nil?
  @force_docker_bundling = force_docker_bundling
  Jsii::Type.check_type(@force_docker_bundling, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "forceDockerBundling") unless @force_docker_bundling.nil?
  @format = format
  Jsii::Type.check_type(@format, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX25vZGVqcy5PdXRwdXRGb3JtYXQifQ==")), "format") unless @format.nil?
  @inject = inject
  Jsii::Type.check_type(@inject, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "inject") unless @inject.nil?
  @keep_names = keep_names
  Jsii::Type.check_type(@keep_names, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "keepNames") unless @keep_names.nil?
  @loader = loader
  Jsii::Type.check_type(@loader, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "loader") unless @loader.nil?
  @log_level = log_level
  Jsii::Type.check_type(@log_level, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX25vZGVqcy5Mb2dMZXZlbCJ9")), "logLevel") unless @log_level.nil?
  @main_fields = main_fields
  Jsii::Type.check_type(@main_fields, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "mainFields") unless @main_fields.nil?
  @metafile = metafile
  Jsii::Type.check_type(@metafile, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "metafile") unless @metafile.nil?
  @minify = minify
  Jsii::Type.check_type(@minify, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "minify") unless @minify.nil?
  @node_modules = node_modules
  Jsii::Type.check_type(@node_modules, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "nodeModules") unless @node_modules.nil?
  @pre_compilation = pre_compilation
  Jsii::Type.check_type(@pre_compilation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "preCompilation") unless @pre_compilation.nil?
  @source_map = source_map
  Jsii::Type.check_type(@source_map, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "sourceMap") unless @source_map.nil?
  @source_map_mode = source_map_mode
  Jsii::Type.check_type(@source_map_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfbGFtYmRhX25vZGVqcy5Tb3VyY2VNYXBNb2RlIn0=")), "sourceMapMode") unless @source_map_mode.nil?
  @sources_content = sources_content
  Jsii::Type.check_type(@sources_content, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "sourcesContent") unless @sources_content.nil?
  @target = target
  Jsii::Type.check_type(@target, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "target") unless @target.nil?
  @tsconfig = tsconfig
  Jsii::Type.check_type(@tsconfig, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "tsconfig") unless @tsconfig.nil?
end

Instance Attribute Details

#asset_hashString? (readonly)

Note:

Default: - asset hash is calculated based on the bundled output

Specify a custom hash for this asset.

For consistency, this custom hash will be SHA256 hashed and encoded as hex. The resulting hash will be the asset hash.

NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated.

Returns:

  • (String, nil)


194
195
196
# File 'lambda_nodejs/bundling_options.rb', line 194

def asset_hash
  @asset_hash
end
Note:

Default: - no comments are passed

Use this to insert an arbitrary string at the beginning of generated JavaScript files.

This is similar to footer which inserts at the end instead of the beginning.

This is commonly used to insert comments:

Returns:

  • (String, nil)


203
204
205
# File 'lambda_nodejs/bundling_options.rb', line 203

def banner
  @banner
end

#build_argsHash{String => String}? (readonly)

Note:

Default: - no build arguments are passed

Build arguments to pass when building the bundling image.

Returns:

  • (Hash{String => String}, nil)


208
209
210
# File 'lambda_nodejs/bundling_options.rb', line 208

def build_args
  @build_args
end

#bundle_aws_sdkBoolean? (readonly)

Note:

Default: - false if true the aws-sdk will be included in the asset bundle and not be resolved to the Lambda provided sdk.

Includes AWS SDK in the bundle asset.

Returns:

  • (Boolean, nil)


213
214
215
# File 'lambda_nodejs/bundling_options.rb', line 213

def bundle_aws_sdk
  @bundle_aws_sdk
end

#bundling_file_accessAWSCDK::BundlingFileAccess? (readonly)

Note:

Default: - BundlingFileAccess.BIND_MOUNT

Which option to use to copy the source files to the docker container and output files back.

Returns:



218
219
220
# File 'lambda_nodejs/bundling_options.rb', line 218

def bundling_file_access
  @bundling_file_access
end

#charsetAWSCDK::LambdaNodejs::Charset? (readonly)

Note:

Default: Charset.ASCII

The charset to use for esbuild's output.

By default esbuild's output is ASCII-only. Any non-ASCII characters are escaped using backslash escape sequences. Using escape sequences makes the generated output slightly bigger, and also makes it harder to read. If you would like for esbuild to print the original characters without using escape sequences, use Charset.UTF8.



229
230
231
# File 'lambda_nodejs/bundling_options.rb', line 229

def charset
  @charset
end

#commandArray<String>? (readonly)

Note:

Default: - run the command defined in the image

The command to run in the container.

Returns:

  • (Array<String>, nil)


131
132
133
# File 'lambda_nodejs/bundling_options.rb', line 131

def command
  @command
end

#command_hooksAWSCDK::LambdaNodejs::ICommandHooks? (readonly)

Note:

Default: - do not run additional commands

Command hooks.



234
235
236
# File 'lambda_nodejs/bundling_options.rb', line 234

def command_hooks
  @command_hooks
end

#defineHash{String => String}? (readonly)

Note:

Default: - no replacements are made

Replace global identifiers with constant expressions.

For example, { 'process.env.DEBUG': 'true' }.

Another example, { 'process.env.API_KEY': JSON.stringify('xxx-xxxx-xxx') }.

Returns:

  • (Hash{String => String}, nil)


243
244
245
# File 'lambda_nodejs/bundling_options.rb', line 243

def define
  @define
end

#docker_imageAWSCDK::DockerImage? (readonly)

Note:

Default: - use the Docker image provided by aws-cdk-lib/aws-lambda-nodejs

A custom bundling Docker image.

This image should have esbuild installed globally. If you plan to use node_modules it should also have npm, yarn, bun or pnpm depending on the lock file you're using.

See https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda-nodejs/lib/Dockerfile for the default image provided by aws-cdk-lib/aws-lambda-nodejs.

Returns:



254
255
256
# File 'lambda_nodejs/bundling_options.rb', line 254

def docker_image
  @docker_image
end

#entrypointArray<String>? (readonly)

Note:

Default: - run the entrypoint defined in the image

The entrypoint to run in the container.

Returns:

  • (Array<String>, nil)


136
137
138
# File 'lambda_nodejs/bundling_options.rb', line 136

def entrypoint
  @entrypoint
end

#environmentHash{String => String}? (readonly)

Note:

Default: - no environment variables.

The environment variables to pass to the container.

Returns:

  • (Hash{String => String}, nil)


141
142
143
# File 'lambda_nodejs/bundling_options.rb', line 141

def environment
  @environment
end

#esbuild_argsHash{String => String, Boolean}? (readonly)

Note:

Default: - no additional esbuild arguments are passed

Build arguments to pass into esbuild.

For example, to add the --log-limit flag:

new NodejsFunction(scope, id, {
  ...
  bundling: {
    esbuildArgs: {
      "--log-limit": "0",
    }
  }
});

Returns:

  • (Hash{String => String, Boolean}, nil)


272
273
274
# File 'lambda_nodejs/bundling_options.rb', line 272

def esbuild_args
  @esbuild_args
end

#esbuild_versionString? (readonly)

Note:

Default: - latest v0

The version of esbuild to use when running in a Docker container.

Returns:

  • (String, nil)


277
278
279
# File 'lambda_nodejs/bundling_options.rb', line 277

def esbuild_version
  @esbuild_version
end

#external_modulesArray<String>? (readonly)

Note:

Default: - no replacements are made

A list of modules that should be considered as externals (already available in the runtime).

Returns:

  • (Array<String>, nil)


282
283
284
# File 'lambda_nodejs/bundling_options.rb', line 282

def external_modules
  @external_modules
end
Note:

Default: - no comments are passed

Use this to insert an arbitrary string at the end of generated JavaScript files.

This is similar to banner which inserts at the beginning instead of the end.

This is commonly used to insert comments

Returns:

  • (String, nil)


291
292
293
# File 'lambda_nodejs/bundling_options.rb', line 291

def footer
  @footer
end

#force_docker_bundlingBoolean? (readonly)

Note:

Default: false

Force bundling in a Docker container even if local bundling is possible.

This is useful if your function relies on node modules that should be installed (node_modules) in a Lambda compatible environment.

Returns:

  • (Boolean, nil)


300
301
302
# File 'lambda_nodejs/bundling_options.rb', line 300

def force_docker_bundling
  @force_docker_bundling
end

#formatAWSCDK::LambdaNodejs::OutputFormat? (readonly)

Note:

Default: OutputFormat.CJS

Output format for the generated JavaScript files.



305
306
307
# File 'lambda_nodejs/bundling_options.rb', line 305

def format
  @format
end

#injectArray<String>? (readonly)

Note:

Default: - no code is injected

This option allows you to automatically replace a global variable with an import from another file.

Returns:

  • (Array<String>, nil)

See Also:



311
312
313
# File 'lambda_nodejs/bundling_options.rb', line 311

def inject
  @inject
end

#keep_namesBoolean? (readonly)

Note:

Default: false

Whether to preserve the original name values even in minified code.

In JavaScript the name property on functions and classes defaults to a nearby identifier in the source code.

However, minification renames symbols to reduce code size and bundling sometimes need to rename symbols to avoid collisions. That changes value of the name property for many of these cases. This is usually fine because the name property is normally only used for debugging. However, some frameworks rely on the name property for registration and binding purposes. If this is the case, you can enable this option to preserve the original name values even in minified code.

Returns:

  • (Boolean, nil)


327
328
329
# File 'lambda_nodejs/bundling_options.rb', line 327

def keep_names
  @keep_names
end

#loaderHash{String => String}? (readonly)

Note:

Default: - use esbuild default loaders

Use loaders to change how a given input file is interpreted.

Configuring a loader for a given file type lets you load that file type with an import statement or a require call.

For example, { '.png': 'dataurl' }.

Returns:

  • (Hash{String => String}, nil)

See Also:



338
339
340
# File 'lambda_nodejs/bundling_options.rb', line 338

def loader
  @loader
end

#log_levelAWSCDK::LambdaNodejs::LogLevel? (readonly)

Note:

Default: LogLevel.WARNING

Log level for esbuild.

This is also propagated to the package manager and applies to its specific install command.



346
347
348
# File 'lambda_nodejs/bundling_options.rb', line 346

def log_level
  @log_level
end

#main_fieldsArray<String>? (readonly)

Note:

Default: []

How to determine the entry point for modules.

Try ['module', 'main'] to default to ES module versions.

Returns:

  • (Array<String>, nil)


353
354
355
# File 'lambda_nodejs/bundling_options.rb', line 353

def main_fields
  @main_fields
end

#metafileBoolean? (readonly)

Note:

Default: false

This option tells esbuild to write out a JSON file relative to output directory with metadata about the build.

The metadata in this JSON file follows this schema (specified using TypeScript syntax):

{
  outputs: {
    [path: string]: {
      bytes: number
      inputs: {
        [path: string]: { bytesInOutput: number }
      }
      imports: { path: string }[]
      exports: string[]
    }
  }
}

This data can then be analyzed by other tools. For example, bundle buddy can consume esbuild's metadata format and generates a treemap visualization of the modules in your bundle and how much space each one takes up.

Returns:

  • (Boolean, nil)

See Also:



380
381
382
# File 'lambda_nodejs/bundling_options.rb', line 380

def metafile
  @metafile
end

#minifyBoolean? (readonly)

Note:

Default: false

Whether to minify files when bundling.

Returns:

  • (Boolean, nil)


385
386
387
# File 'lambda_nodejs/bundling_options.rb', line 385

def minify
  @minify
end

#networkString? (readonly)

Note:

Default: - no networking options

Docker Networking options.

Returns:

  • (String, nil)


146
147
148
# File 'lambda_nodejs/bundling_options.rb', line 146

def network
  @network
end

#node_modulesArray<String>? (readonly)

Note:

Default: - all modules are bundled

A list of modules that should be installed instead of bundled.

Modules are installed in a Lambda compatible environment only when bundling runs in Docker.

Returns:

  • (Array<String>, nil)


394
395
396
# File 'lambda_nodejs/bundling_options.rb', line 394

def node_modules
  @node_modules
end

#platformString? (readonly)

Note:

Default: - no platform specified

Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.

Example value: linux/amd64

Returns:

  • (String, nil)


153
154
155
# File 'lambda_nodejs/bundling_options.rb', line 153

def platform
  @platform
end

#pre_compilationBoolean? (readonly)

Note:

Default: false

Run compilation using tsc before running file through bundling step.

This usually is not required unless you are using new experimental features that are only supported by typescript's tsc compiler. One example of such feature is emit_decorator_metadata.

Returns:

  • (Boolean, nil)


403
404
405
# File 'lambda_nodejs/bundling_options.rb', line 403

def pre_compilation
  @pre_compilation
end

#security_optString? (readonly)

Note:

Default: - no security options

Security configuration when running the docker container.

Returns:

  • (String, nil)


158
159
160
# File 'lambda_nodejs/bundling_options.rb', line 158

def security_opt
  @security_opt
end

#source_mapBoolean? (readonly)

Note:

Default: false

Whether to include source maps when bundling.

Returns:

  • (Boolean, nil)


408
409
410
# File 'lambda_nodejs/bundling_options.rb', line 408

def source_map
  @source_map
end

#source_map_modeAWSCDK::LambdaNodejs::SourceMapMode? (readonly)

Note:

Default: SourceMapMode.DEFAULT

Source map mode to be used when bundling.



414
415
416
# File 'lambda_nodejs/bundling_options.rb', line 414

def source_map_mode
  @source_map_mode
end

#sources_contentBoolean? (readonly)

Note:

Default: true

Whether to include original source code in source maps when bundling.

Returns:

  • (Boolean, nil)

See Also:



420
421
422
# File 'lambda_nodejs/bundling_options.rb', line 420

def sources_content
  @sources_content
end

#targetString? (readonly)

Note:

Default: - the node version of the runtime

Target environment for the generated JavaScript code.

Returns:

  • (String, nil)

See Also:



426
427
428
# File 'lambda_nodejs/bundling_options.rb', line 426

def target
  @target
end

#tsconfigString? (readonly)

Note:

Default: - automatically discovered by esbuild

Normally the esbuild automatically discovers tsconfig.json files and reads their contents during a build.

However, you can also configure a custom tsconfig.json file to use instead.

This is similar to entry path, you need to provide path to your custom tsconfig.json.

This can be useful if you need to do multiple builds of the same code with different settings.

For example, { 'tsconfig': 'path/custom.tsconfig.json' }.

Returns:

  • (String, nil)


439
440
441
# File 'lambda_nodejs/bundling_options.rb', line 439

def tsconfig
  @tsconfig
end

#userString? (readonly)

Note:

Default: - root or image default

The user to use when running the container.

Returns:

  • (String, nil)


163
164
165
# File 'lambda_nodejs/bundling_options.rb', line 163

def user
  @user
end

#volumesArray<AWSCDK::DockerVolume>? (readonly)

Note:

Default: - no volumes are mounted

Docker volumes to mount.

Returns:



168
169
170
# File 'lambda_nodejs/bundling_options.rb', line 168

def volumes
  @volumes
end

#volumes_fromArray<String>? (readonly)

Note:

Default: - no containers are specified to mount volumes from

Where to mount the specified volumes from.



174
175
176
# File 'lambda_nodejs/bundling_options.rb', line 174

def volumes_from
  @volumes_from
end

#working_directoryString? (readonly)

Note:

Default: - image default

Working directory inside the container.

Returns:

  • (String, nil)


179
180
181
# File 'lambda_nodejs/bundling_options.rb', line 179

def working_directory
  @working_directory
end

Class Method Details

.jsii_propertiesObject



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lambda_nodejs/bundling_options.rb', line 441

def self.jsii_properties
  {
    :command => "command",
    :entrypoint => "entrypoint",
    :environment => "environment",
    :network => "network",
    :platform => "platform",
    :security_opt => "securityOpt",
    :user => "user",
    :volumes => "volumes",
    :volumes_from => "volumesFrom",
    :working_directory => "workingDirectory",
    :asset_hash => "assetHash",
    :banner => "banner",
    :build_args => "buildArgs",
    :bundle_aws_sdk => "bundleAwsSDK",
    :bundling_file_access => "bundlingFileAccess",
    :charset => "charset",
    :command_hooks => "commandHooks",
    :define => "define",
    :docker_image => "dockerImage",
    :esbuild_args => "esbuildArgs",
    :esbuild_version => "esbuildVersion",
    :external_modules => "externalModules",
    :footer => "footer",
    :force_docker_bundling => "forceDockerBundling",
    :format => "format",
    :inject => "inject",
    :keep_names => "keepNames",
    :loader => "loader",
    :log_level => "logLevel",
    :main_fields => "mainFields",
    :metafile => "metafile",
    :minify => "minify",
    :node_modules => "nodeModules",
    :pre_compilation => "preCompilation",
    :source_map => "sourceMap",
    :source_map_mode => "sourceMapMode",
    :sources_content => "sourcesContent",
    :target => "target",
    :tsconfig => "tsconfig",
  }
end

Instance Method Details

#to_jsiiObject



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lambda_nodejs/bundling_options.rb', line 485

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "command" => @command,
    "entrypoint" => @entrypoint,
    "environment" => @environment,
    "network" => @network,
    "platform" => @platform,
    "securityOpt" => @security_opt,
    "user" => @user,
    "volumes" => @volumes,
    "volumesFrom" => @volumes_from,
    "workingDirectory" => @working_directory,
    "assetHash" => @asset_hash,
    "banner" => @banner,
    "buildArgs" => @build_args,
    "bundleAwsSDK" => @bundle_aws_sdk,
    "bundlingFileAccess" => @bundling_file_access,
    "charset" => @charset,
    "commandHooks" => @command_hooks,
    "define" => @define,
    "dockerImage" => @docker_image,
    "esbuildArgs" => @esbuild_args,
    "esbuildVersion" => @esbuild_version,
    "externalModules" => @external_modules,
    "footer" => @footer,
    "forceDockerBundling" => @force_docker_bundling,
    "format" => @format,
    "inject" => @inject,
    "keepNames" => @keep_names,
    "loader" => @loader,
    "logLevel" => @log_level,
    "mainFields" => @main_fields,
    "metafile" => @metafile,
    "minify" => @minify,
    "nodeModules" => @node_modules,
    "preCompilation" => @pre_compilation,
    "sourceMap" => @source_map,
    "sourceMapMode" => @source_map_mode,
    "sourcesContent" => @sources_content,
    "target" => @target,
    "tsconfig" => @tsconfig,
  })
  result.compact
end