Class: AWSCDK::LambdaNodejs::BundlingOptions
- Inherits:
-
DockerRunOptions
- Object
- DockerRunOptions
- AWSCDK::LambdaNodejs::BundlingOptions
- Defined in:
- lambda_nodejs/bundling_options.rb
Overview
Bundling options.
Instance Attribute Summary collapse
-
#asset_hash ⇒ String?
readonly
Specify a custom hash for this asset.
-
#banner ⇒ String?
readonly
Use this to insert an arbitrary string at the beginning of generated JavaScript files.
-
#build_args ⇒ Hash{String => String}?
readonly
Build arguments to pass when building the bundling image.
-
#bundle_aws_sdk ⇒ Boolean?
readonly
Includes AWS SDK in the bundle asset.
-
#bundling_file_access ⇒ AWSCDK::BundlingFileAccess?
readonly
Which option to use to copy the source files to the docker container and output files back.
-
#charset ⇒ AWSCDK::LambdaNodejs::Charset?
readonly
The charset to use for esbuild's output.
-
#command ⇒ Array<String>?
readonly
The command to run in the container.
-
#command_hooks ⇒ AWSCDK::LambdaNodejs::ICommandHooks?
readonly
Command hooks.
-
#define ⇒ Hash{String => String}?
readonly
Replace global identifiers with constant expressions.
-
#docker_image ⇒ AWSCDK::DockerImage?
readonly
A custom bundling Docker image.
-
#entrypoint ⇒ Array<String>?
readonly
The entrypoint to run in the container.
-
#environment ⇒ Hash{String => String}?
readonly
The environment variables to pass to the container.
-
#esbuild_args ⇒ Hash{String => String, Boolean}?
readonly
Build arguments to pass into esbuild.
-
#esbuild_version ⇒ String?
readonly
The version of esbuild to use when running in a Docker container.
-
#external_modules ⇒ Array<String>?
readonly
A list of modules that should be considered as externals (already available in the runtime).
-
#footer ⇒ String?
readonly
Use this to insert an arbitrary string at the end of generated JavaScript files.
-
#force_docker_bundling ⇒ Boolean?
readonly
Force bundling in a Docker container even if local bundling is possible.
-
#format ⇒ AWSCDK::LambdaNodejs::OutputFormat?
readonly
Output format for the generated JavaScript files.
-
#inject ⇒ Array<String>?
readonly
This option allows you to automatically replace a global variable with an import from another file.
-
#keep_names ⇒ Boolean?
readonly
Whether to preserve the original
namevalues even in minified code. -
#loader ⇒ Hash{String => String}?
readonly
Use loaders to change how a given input file is interpreted.
-
#log_level ⇒ AWSCDK::LambdaNodejs::LogLevel?
readonly
Log level for esbuild.
-
#main_fields ⇒ Array<String>?
readonly
How to determine the entry point for modules.
-
#metafile ⇒ Boolean?
readonly
This option tells esbuild to write out a JSON file relative to output directory with metadata about the build.
-
#minify ⇒ Boolean?
readonly
Whether to minify files when bundling.
-
#network ⇒ String?
readonly
Docker Networking options.
-
#node_modules ⇒ Array<String>?
readonly
A list of modules that should be installed instead of bundled.
-
#platform ⇒ String?
readonly
Set platform if server is multi-platform capable.
-
#pre_compilation ⇒ Boolean?
readonly
Run compilation using tsc before running file through bundling step.
-
#security_opt ⇒ String?
readonly
Security configuration when running the docker container.
-
#source_map ⇒ Boolean?
readonly
Whether to include source maps when bundling.
-
#source_map_mode ⇒ AWSCDK::LambdaNodejs::SourceMapMode?
readonly
Source map mode to be used when bundling.
-
#sources_content ⇒ Boolean?
readonly
Whether to include original source code in source maps when bundling.
-
#target ⇒ String?
readonly
Target environment for the generated JavaScript code.
-
#tsconfig ⇒ String?
readonly
Normally the esbuild automatically discovers
tsconfig.jsonfiles and reads their contents during a build. -
#user ⇒ String?
readonly
The user to use when running the container.
-
#volumes ⇒ Array<AWSCDK::DockerVolume>?
readonly
Docker volumes to mount.
-
#volumes_from ⇒ Array<String>?
readonly
Where to mount the specified volumes from.
-
#working_directory ⇒ String?
readonly
Working directory inside the container.
Class Method Summary collapse
Instance Method Summary collapse
-
#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
constructor
A new instance of BundlingOptions.
- #to_jsii ⇒ Object
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.
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 = 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 = 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 = 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_hash ⇒ String? (readonly)
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.
194 195 196 |
# File 'lambda_nodejs/bundling_options.rb', line 194 def asset_hash @asset_hash end |
#banner ⇒ String? (readonly)
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:
203 204 205 |
# File 'lambda_nodejs/bundling_options.rb', line 203 def @banner end |
#build_args ⇒ Hash{String => String}? (readonly)
Default: - no build arguments are passed
Build arguments to pass when building the bundling image.
208 209 210 |
# File 'lambda_nodejs/bundling_options.rb', line 208 def build_args @build_args end |
#bundle_aws_sdk ⇒ Boolean? (readonly)
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.
213 214 215 |
# File 'lambda_nodejs/bundling_options.rb', line 213 def bundle_aws_sdk @bundle_aws_sdk end |
#bundling_file_access ⇒ AWSCDK::BundlingFileAccess? (readonly)
Default: - BundlingFileAccess.BIND_MOUNT
Which option to use to copy the source files to the docker container and output files back.
218 219 220 |
# File 'lambda_nodejs/bundling_options.rb', line 218 def bundling_file_access @bundling_file_access end |
#charset ⇒ AWSCDK::LambdaNodejs::Charset? (readonly)
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 |
#command ⇒ Array<String>? (readonly)
Default: - run the command defined in the image
The command to run in the container.
131 132 133 |
# File 'lambda_nodejs/bundling_options.rb', line 131 def command @command end |
#command_hooks ⇒ AWSCDK::LambdaNodejs::ICommandHooks? (readonly)
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 |
#define ⇒ Hash{String => String}? (readonly)
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') }.
243 244 245 |
# File 'lambda_nodejs/bundling_options.rb', line 243 def define @define end |
#docker_image ⇒ AWSCDK::DockerImage? (readonly)
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.
254 255 256 |
# File 'lambda_nodejs/bundling_options.rb', line 254 def docker_image @docker_image end |
#entrypoint ⇒ Array<String>? (readonly)
Default: - run the entrypoint defined in the image
The entrypoint to run in the container.
136 137 138 |
# File 'lambda_nodejs/bundling_options.rb', line 136 def entrypoint @entrypoint end |
#environment ⇒ Hash{String => String}? (readonly)
Default: - no environment variables.
The environment variables to pass to the container.
141 142 143 |
# File 'lambda_nodejs/bundling_options.rb', line 141 def environment @environment end |
#esbuild_args ⇒ Hash{String => String, Boolean}? (readonly)
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",
}
}
});
272 273 274 |
# File 'lambda_nodejs/bundling_options.rb', line 272 def esbuild_args @esbuild_args end |
#esbuild_version ⇒ String? (readonly)
Default: - latest v0
The version of esbuild to use when running in a Docker container.
277 278 279 |
# File 'lambda_nodejs/bundling_options.rb', line 277 def esbuild_version @esbuild_version end |
#external_modules ⇒ Array<String>? (readonly)
Default: - no replacements are made
A list of modules that should be considered as externals (already available in the runtime).
282 283 284 |
# File 'lambda_nodejs/bundling_options.rb', line 282 def external_modules @external_modules end |
#footer ⇒ String? (readonly)
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
291 292 293 |
# File 'lambda_nodejs/bundling_options.rb', line 291 def @footer end |
#force_docker_bundling ⇒ Boolean? (readonly)
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.
300 301 302 |
# File 'lambda_nodejs/bundling_options.rb', line 300 def force_docker_bundling @force_docker_bundling end |
#format ⇒ AWSCDK::LambdaNodejs::OutputFormat? (readonly)
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 |
#inject ⇒ Array<String>? (readonly)
Default: - no code is injected
This option allows you to automatically replace a global variable with an import from another file.
311 312 313 |
# File 'lambda_nodejs/bundling_options.rb', line 311 def inject @inject end |
#keep_names ⇒ Boolean? (readonly)
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.
327 328 329 |
# File 'lambda_nodejs/bundling_options.rb', line 327 def keep_names @keep_names end |
#loader ⇒ Hash{String => String}? (readonly)
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' }.
338 339 340 |
# File 'lambda_nodejs/bundling_options.rb', line 338 def loader @loader end |
#log_level ⇒ AWSCDK::LambdaNodejs::LogLevel? (readonly)
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_fields ⇒ Array<String>? (readonly)
Default: []
How to determine the entry point for modules.
Try ['module', 'main'] to default to ES module versions.
353 354 355 |
# File 'lambda_nodejs/bundling_options.rb', line 353 def main_fields @main_fields end |
#metafile ⇒ Boolean? (readonly)
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.
380 381 382 |
# File 'lambda_nodejs/bundling_options.rb', line 380 def @metafile end |
#minify ⇒ Boolean? (readonly)
Default: false
Whether to minify files when bundling.
385 386 387 |
# File 'lambda_nodejs/bundling_options.rb', line 385 def minify @minify end |
#network ⇒ String? (readonly)
Default: - no networking options
Docker Networking options.
146 147 148 |
# File 'lambda_nodejs/bundling_options.rb', line 146 def network @network end |
#node_modules ⇒ Array<String>? (readonly)
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.
394 395 396 |
# File 'lambda_nodejs/bundling_options.rb', line 394 def node_modules @node_modules end |
#platform ⇒ String? (readonly)
Default: - no platform specified
Set platform if server is multi-platform capable. Requires Docker Engine API v1.38+.
Example value: linux/amd64
153 154 155 |
# File 'lambda_nodejs/bundling_options.rb', line 153 def platform @platform end |
#pre_compilation ⇒ Boolean? (readonly)
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.
403 404 405 |
# File 'lambda_nodejs/bundling_options.rb', line 403 def pre_compilation @pre_compilation end |
#security_opt ⇒ String? (readonly)
Default: - no security options
Security configuration when running the docker container.
158 159 160 |
# File 'lambda_nodejs/bundling_options.rb', line 158 def security_opt @security_opt end |
#source_map ⇒ Boolean? (readonly)
Default: false
Whether to include source maps when bundling.
408 409 410 |
# File 'lambda_nodejs/bundling_options.rb', line 408 def source_map @source_map end |
#source_map_mode ⇒ AWSCDK::LambdaNodejs::SourceMapMode? (readonly)
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_content ⇒ Boolean? (readonly)
Default: true
Whether to include original source code in source maps when bundling.
420 421 422 |
# File 'lambda_nodejs/bundling_options.rb', line 420 def sources_content @sources_content end |
#target ⇒ String? (readonly)
Default: - the node version of the runtime
Target environment for the generated JavaScript code.
426 427 428 |
# File 'lambda_nodejs/bundling_options.rb', line 426 def target @target end |
#tsconfig ⇒ String? (readonly)
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' }.
439 440 441 |
# File 'lambda_nodejs/bundling_options.rb', line 439 def tsconfig @tsconfig end |
#user ⇒ String? (readonly)
Default: - root or image default
The user to use when running the container.
163 164 165 |
# File 'lambda_nodejs/bundling_options.rb', line 163 def user @user end |
#volumes ⇒ Array<AWSCDK::DockerVolume>? (readonly)
Default: - no volumes are mounted
Docker volumes to mount.
168 169 170 |
# File 'lambda_nodejs/bundling_options.rb', line 168 def volumes @volumes end |
#volumes_from ⇒ Array<String>? (readonly)
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_directory ⇒ String? (readonly)
Default: - image default
Working directory inside the container.
179 180 181 |
# File 'lambda_nodejs/bundling_options.rb', line 179 def working_directory @working_directory end |
Class Method Details
.jsii_properties ⇒ Object
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_jsii ⇒ Object
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 |