@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-05-10T17:05:56.887Z") @Stability(value=Stable) public interface NodejsFunctionProps extends software.amazon.jsii.JsiiSerializable, FunctionOptions
Example:
NodejsFunction.Builder.create(this, "my-handler")
.bundling(BundlingOptions.builder()
.minify(true) // minify code, defaults to false
.sourceMap(true) // include source map, defaults to false
.sourceMapMode(SourceMapMode.INLINE) // defaults to SourceMapMode.DEFAULT
.sourcesContent(false) // do not include original source into source map, defaults to true
.target("es2020") // target environment for the generated JavaScript code
.loader(Map.of( // Use the 'dataurl' loader for '.png' files
".png", "dataurl"))
.define(Map.of( // Replace strings during build time
"process.env.API_KEY", JSON.stringify("xxx-xxxx-xxx"),
"process.env.PRODUCTION", JSON.stringify(true),
"process.env.NUMBER", JSON.stringify(123)))
.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 */") // requires esbuild >= 0.9.0, defaults to none
.footer("/* comments */") // requires esbuild >= 0.9.0, defaults to none
.charset(Charset.UTF8) // do not escape non-ASCII characters, defaults to Charset.ASCII
.format(OutputFormat.ESM) // ECMAScript module output format, defaults to OutputFormat.CJS (OutputFormat.ESM requires Node.js 14.x)
.mainFields(List.of("module", "main")) // prefer ECMAScript versions of dependencies
.inject(List.of("./my-shim.js", "./other-shim.js")) // allows to automatically replace a global variable with an import from another file
.esbuildArgs(Map.of( // Pass additional arguments to esbuild
"--log-limit", "0",
"--splitting", true))
.build())
.build();
| Modifier and Type | Interface and Description |
|---|---|
static class |
NodejsFunctionProps.Builder
A builder for
NodejsFunctionProps |
static class |
NodejsFunctionProps.Jsii$Proxy
An implementation for
NodejsFunctionProps |
| Modifier and Type | Method and Description |
|---|---|
static NodejsFunctionProps.Builder |
builder() |
default Boolean |
getAwsSdkConnectionReuse()
Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript.
|
default BundlingOptions |
getBundling()
Bundling options.
|
default String |
getDepsLockFilePath()
The path to the dependencies lock file (`yarn.lock` or `package-lock.json`).
|
default String |
getEntry()
Path to the entry file (JavaScript or TypeScript).
|
default String |
getHandler()
The name of the exported handler in the entry file.
|
default String |
getProjectRoot()
The path to the directory containing project config files (`package.json` or `tsconfig.json`).
|
default Runtime |
getRuntime()
The runtime environment.
|
getAllowAllOutbound, getAllowPublicSubnet, getArchitecture, getArchitectures, getCodeSigningConfig, getCurrentVersionOptions, getDeadLetterQueue, getDeadLetterQueueEnabled, getDeadLetterTopic, getDescription, getEnvironment, getEnvironmentEncryption, getEphemeralStorageSize, getEvents, getFilesystem, getFunctionName, getInitialPolicy, getInsightsVersion, getLayers, getLogRetention, getLogRetentionRetryOptions, getLogRetentionRole, getMemorySize, getProfiling, getProfilingGroup, getReservedConcurrentExecutions, getRole, getSecurityGroup, getSecurityGroups, getTimeout, getTracing, getVpc, getVpcSubnetsgetMaxEventAge, getOnFailure, getOnSuccess, getRetryAttempts@Stability(value=Stable) @Nullable default Boolean getAwsSdkConnectionReuse()
This sets the AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable
to 1.
Default: true
@Stability(value=Stable) @Nullable default BundlingOptions getBundling()
Default: - use default bundling options: no minify, no sourcemap, all modules are bundled.
@Stability(value=Stable) @Nullable default String getDepsLockFilePath()
This will be used as the source for the volume mounted in the Docker container.
Modules specified in nodeModules will be installed using the right
installer (npm or yarn) along with this lock file.
Default: - the path is found by walking up parent directories searching for a `yarn.lock` or `package-lock.json` file
@Stability(value=Stable) @Nullable default String getEntry()
Default: - Derived from the name of the defining file and the construct's id. If the `NodejsFunction` is defined in `stack.ts` with `my-handler` as id (`new NodejsFunction(this, 'my-handler')`), the construct will look at `stack.my-handler.ts` and `stack.my-handler.js`.
@Stability(value=Stable) @Nullable default String getHandler()
Default: handler
@Stability(value=Stable) @Nullable default String getProjectRoot()
Default: - the directory containing the `depsLockFilePath`
@Stability(value=Stable) @Nullable default Runtime getRuntime()
Only runtimes of the Node.js family are supported.
Default: Runtime.NODEJS_14_X
@Stability(value=Stable) static NodejsFunctionProps.Builder builder()
builder in interface EventInvokeConfigOptionsbuilder in interface FunctionOptionsNodejsFunctionProps.Builder of NodejsFunctionPropsCopyright © 2023. All rights reserved.