# API Reference ## Constructs ### TypeScriptAsset Bundles the entry points and creates a CDK asset which is uploaded to the bootstrapped CDK S3 bucket during deployment. The asset can be used by other constructs. #### Initializers ```typescript import { TypeScriptAsset } from '@mrgrain/cdk-esbuild' new TypeScriptAsset(scope: Construct, id: string, props: TypeScriptAssetProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | scope | constructs.Construct | *No description.* | | id | string | *No description.* | | props | TypeScriptAssetProps | *No description.* | --- ##### `scope`Required - *Type:* constructs.Construct --- ##### `id`Required - *Type:* string --- ##### `props`Required - *Type:* TypeScriptAssetProps --- #### Methods | **Name** | **Description** | | --- | --- | | toString | Returns a string representation of this construct. | | with | Applies one or more mixins to this construct. | | addResourceMetadata | Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. | | grantRead | Grants read permissions to the principal on the assets bucket. | --- ##### `toString` ```typescript public toString(): string ``` Returns a string representation of this construct. ##### `with` ```typescript public with(mixins: ...IMixin[]): IConstruct ``` Applies one or more mixins to this construct. Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple `with()` calls if subsequent mixins should apply to added constructs. ###### `mixins`Required - *Type:* ...constructs.IMixin[] The mixins to apply. --- ##### `addResourceMetadata` ```typescript public addResourceMetadata(resource: CfnResource, resourceProperty: string): void ``` Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. This can be used by tools such as SAM CLI to provide local experience such as local invocation and debugging of Lambda functions. Asset metadata will only be included if the stack is synthesized with the "aws:cdk:enable-asset-metadata" context key defined, which is the default behavior when synthesizing via the CDK Toolkit. > [https://github.com/aws/aws-cdk/issues/1432](https://github.com/aws/aws-cdk/issues/1432) ###### `resource`Required - *Type:* aws-cdk-lib.CfnResource The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface]. --- ###### `resourceProperty`Required - *Type:* string The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function). --- ##### `grantRead` ```typescript public grantRead(grantee: IGrantable): void ``` Grants read permissions to the principal on the assets bucket. ###### `grantee`Required - *Type:* aws-cdk-lib.aws_iam.IGrantable --- #### Static Functions | **Name** | **Description** | | --- | --- | | isConstruct | Checks if `x` is a construct. | --- ##### `isConstruct` ```typescript import { TypeScriptAsset } from '@mrgrain/cdk-esbuild' TypeScriptAsset.isConstruct(x: any) ``` Checks if `x` is a construct. Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked. Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead. ###### `x`Required - *Type:* any Any object. --- #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | node | constructs.Node | The tree node. | | assetHash | string | A hash of this asset, which is available at construction time. | | assetPath | string | The path to the asset, relative to the current Cloud Assembly. | | bucket | aws-cdk-lib.aws_s3.IBucket | The S3 bucket in which this asset resides. | | httpUrl | string | Attribute which represents the S3 HTTP URL of this asset. | | isFile | boolean | Indicates if this asset is a single file. | | isZipArchive | boolean | Indicates if this asset is a zip archive. | | s3BucketName | string | Attribute that represents the name of the bucket this asset exists in. | | s3ObjectKey | string | Attribute which represents the S3 object key of this asset. | | s3ObjectUrl | string | Attribute which represents the S3 URL of this asset. | --- ##### `node`Required ```typescript public readonly node: Node; ``` - *Type:* constructs.Node The tree node. --- ##### `assetHash`Required ```typescript public readonly assetHash: string; ``` - *Type:* string A hash of this asset, which is available at construction time. As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed. --- ##### `assetPath`Required ```typescript public readonly assetPath: string; ``` - *Type:* string The path to the asset, relative to the current Cloud Assembly. If asset staging is disabled, this will just be the original path. If asset staging is enabled it will be the staged path. --- ##### `bucket`Required ```typescript public readonly bucket: IBucket; ``` - *Type:* aws-cdk-lib.aws_s3.IBucket The S3 bucket in which this asset resides. --- ##### `httpUrl`Required ```typescript public readonly httpUrl: string; ``` - *Type:* string Attribute which represents the S3 HTTP URL of this asset. For example, `https://s3.us-west-1.amazonaws.com/bucket/key` --- ##### `isFile`Required ```typescript public readonly isFile: boolean; ``` - *Type:* boolean Indicates if this asset is a single file. Allows constructs to ensure that the correct file type was used. --- ##### `isZipArchive`Required ```typescript public readonly isZipArchive: boolean; ``` - *Type:* boolean Indicates if this asset is a zip archive. Allows constructs to ensure that the correct file type was used. --- ##### `s3BucketName`Required ```typescript public readonly s3BucketName: string; ``` - *Type:* string Attribute that represents the name of the bucket this asset exists in. --- ##### `s3ObjectKey`Required ```typescript public readonly s3ObjectKey: string; ``` - *Type:* string Attribute which represents the S3 object key of this asset. --- ##### `s3ObjectUrl`Required ```typescript public readonly s3ObjectUrl: string; ``` - *Type:* string Attribute which represents the S3 URL of this asset. For example, `s3://bucket/key` --- ## Structs ### BuildOptions #### Initializer ```typescript import { BuildOptions } from '@mrgrain/cdk-esbuild' const buildOptions: BuildOptions = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | absPaths | string[] | Documentation: https://esbuild.github.io/api/#abs-paths. | | absWorkingDir | string | Documentation: https://esbuild.github.io/api/#working-directory. | | alias | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#alias. | | allowOverwrite | boolean | Documentation: https://esbuild.github.io/api/#allow-overwrite. | | assetNames | string | Documentation: https://esbuild.github.io/api/#asset-names. | | banner | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#banner. | | bundle | boolean | Documentation: https://esbuild.github.io/api/#bundle. | | charset | string | Documentation: https://esbuild.github.io/api/#charset. | | chunkNames | string | Documentation: https://esbuild.github.io/api/#chunk-names. | | color | boolean | Documentation: https://esbuild.github.io/api/#color. | | conditions | string[] | Documentation: https://esbuild.github.io/api/#conditions. | | define | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#define. | | drop | string[] | Documentation: https://esbuild.github.io/api/#drop. | | dropLabels | string[] | Documentation: https://esbuild.github.io/api/#drop-labels. | | entryNames | string | Documentation: https://esbuild.github.io/api/#entry-names. | | external | string[] | Documentation: https://esbuild.github.io/api/#external. | | footer | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#footer. | | format | string | Documentation: https://esbuild.github.io/api/#format. | | globalName | string | Documentation: https://esbuild.github.io/api/#global-name. | | ignoreAnnotations | boolean | Documentation: https://esbuild.github.io/api/#ignore-annotations. | | inject | string[] | Documentation: https://esbuild.github.io/api/#inject. | | jsx | string | Documentation: https://esbuild.github.io/api/#jsx. | | jsxDev | boolean | Documentation: https://esbuild.github.io/api/#jsx-development. | | jsxFactory | string | Documentation: https://esbuild.github.io/api/#jsx-factory. | | jsxFragment | string | Documentation: https://esbuild.github.io/api/#jsx-fragment. | | jsxImportSource | string | Documentation: https://esbuild.github.io/api/#jsx-import-source. | | jsxSideEffects | boolean | Documentation: https://esbuild.github.io/api/#jsx-side-effects. | | keepNames | boolean | Documentation: https://esbuild.github.io/api/#keep-names. | | legalComments | string | Documentation: https://esbuild.github.io/api/#legal-comments. | | lineLimit | number | Documentation: https://esbuild.github.io/api/#line-limit. | | loader | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#loader. | | logLevel | string | Documentation: https://esbuild.github.io/api/#log-level. | | logLimit | number | Documentation: https://esbuild.github.io/api/#log-limit. | | logOverride | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#log-override. | | mainFields | string[] | Documentation: https://esbuild.github.io/api/#main-fields. | | mangleCache | {[ key: string ]: string \| boolean} | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleQuoted | boolean | Documentation: https://esbuild.github.io/api/#mangle-props. | | metafile | boolean | Documentation: https://esbuild.github.io/api/#metafile. | | minify | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyIdentifiers | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifySyntax | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyWhitespace | boolean | Documentation: https://esbuild.github.io/api/#minify. | | nodePaths | string[] | Documentation: https://esbuild.github.io/api/#node-paths. | | outbase | string | Documentation: https://esbuild.github.io/api/#outbase. | | outdir | string | Documentation: https://esbuild.github.io/api/#outdir. | | outExtension | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#out-extension. | | outfile | string | Documentation: https://esbuild.github.io/api/#outfile. | | packages | string | Documentation: https://esbuild.github.io/api/#packages. | | platform | string | Documentation: https://esbuild.github.io/api/#platform. | | preserveSymlinks | boolean | Documentation: https://esbuild.github.io/api/#preserve-symlinks. | | publicPath | string | Documentation: https://esbuild.github.io/api/#public-path. | | pure | string[] | Documentation: https://esbuild.github.io/api/#pure. | | reserveProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | resolveExtensions | string[] | Documentation: https://esbuild.github.io/api/#resolve-extensions. | | sourcemap | boolean \| string | Documentation: https://esbuild.github.io/api/#sourcemap. | | sourceRoot | string | Documentation: https://esbuild.github.io/api/#source-root. | | sourcesContent | boolean | Documentation: https://esbuild.github.io/api/#sources-content. | | splitting | boolean | Documentation: https://esbuild.github.io/api/#splitting. | | supported | {[ key: string ]: boolean} | Documentation: https://esbuild.github.io/api/#supported. | | target | string \| string[] | Documentation: https://esbuild.github.io/api/#target. | | treeShaking | boolean | Documentation: https://esbuild.github.io/api/#tree-shaking. | | tsconfig | string | Documentation: https://esbuild.github.io/api/#tsconfig. | | tsconfigRaw | string \| TsconfigRaw | Documentation: https://esbuild.github.io/api/#tsconfig-raw. | | write | boolean | Documentation: https://esbuild.github.io/api/#write. | --- ##### `absPaths`Optional ```typescript public readonly absPaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#abs-paths. --- ##### `absWorkingDir`Optional ```typescript public readonly absWorkingDir: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#working-directory. --- ##### `alias`Optional ```typescript public readonly alias: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#alias. --- ##### `allowOverwrite`Optional ```typescript public readonly allowOverwrite: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#allow-overwrite. --- ##### `assetNames`Optional ```typescript public readonly assetNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#asset-names. --- ##### `banner`Optional ```typescript public readonly banner: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#banner. --- ##### `bundle`Optional ```typescript public readonly bundle: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#bundle. --- ##### `charset`Optional ```typescript public readonly charset: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#charset. --- ##### `chunkNames`Optional ```typescript public readonly chunkNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#chunk-names. --- ##### `color`Optional ```typescript public readonly color: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#color. --- ##### `conditions`Optional ```typescript public readonly conditions: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#conditions. --- ##### `define`Optional ```typescript public readonly define: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#define. --- ##### `drop`Optional ```typescript public readonly drop: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop. --- ##### `dropLabels`Optional ```typescript public readonly dropLabels: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop-labels. --- ##### `entryNames`Optional ```typescript public readonly entryNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#entry-names. --- ##### `external`Optional ```typescript public readonly external: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#external. --- ##### `footer`Optional ```typescript public readonly footer: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#footer. --- ##### `format`Optional ```typescript public readonly format: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#format. --- ##### `globalName`Optional ```typescript public readonly globalName: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#global-name. --- ##### `ignoreAnnotations`Optional ```typescript public readonly ignoreAnnotations: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#ignore-annotations. --- ##### `inject`Optional ```typescript public readonly inject: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#inject. --- ##### `jsx`Optional ```typescript public readonly jsx: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx. --- ##### `jsxDev`Optional ```typescript public readonly jsxDev: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-development. --- ##### `jsxFactory`Optional ```typescript public readonly jsxFactory: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-factory. --- ##### `jsxFragment`Optional ```typescript public readonly jsxFragment: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-fragment. --- ##### `jsxImportSource`Optional ```typescript public readonly jsxImportSource: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-import-source. --- ##### `jsxSideEffects`Optional ```typescript public readonly jsxSideEffects: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-side-effects. --- ##### `keepNames`Optional ```typescript public readonly keepNames: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#keep-names. --- ##### `legalComments`Optional ```typescript public readonly legalComments: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#legal-comments. --- ##### `lineLimit`Optional ```typescript public readonly lineLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#line-limit. --- ##### `loader`Optional ```typescript public readonly loader: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#loader. --- ##### `logLevel`Optional ```typescript public readonly logLevel: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#log-level. --- ##### `logLimit`Optional ```typescript public readonly logLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#log-limit. --- ##### `logOverride`Optional ```typescript public readonly logOverride: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#log-override. --- ##### `mainFields`Optional ```typescript public readonly mainFields: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#main-fields. --- ##### `mangleCache`Optional ```typescript public readonly mangleCache: {[ key: string ]: string | boolean}; ``` - *Type:* {[ key: string ]: string | boolean} Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleProps`Optional ```typescript public readonly mangleProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleQuoted`Optional ```typescript public readonly mangleQuoted: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `metafile`Optional ```typescript public readonly metafile: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#metafile. --- ##### `minify`Optional ```typescript public readonly minify: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyIdentifiers`Optional ```typescript public readonly minifyIdentifiers: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifySyntax`Optional ```typescript public readonly minifySyntax: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyWhitespace`Optional ```typescript public readonly minifyWhitespace: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `nodePaths`Optional ```typescript public readonly nodePaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#node-paths. --- ##### `outbase`Optional ```typescript public readonly outbase: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outbase. --- ##### `outdir`Optional ```typescript public readonly outdir: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outdir. --- ##### `outExtension`Optional ```typescript public readonly outExtension: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#out-extension. --- ##### `outfile`Optional ```typescript public readonly outfile: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outfile. --- ##### `packages`Optional ```typescript public readonly packages: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#packages. --- ##### `platform`Optional ```typescript public readonly platform: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#platform. --- ##### `preserveSymlinks`Optional ```typescript public readonly preserveSymlinks: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#preserve-symlinks. --- ##### `publicPath`Optional ```typescript public readonly publicPath: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#public-path. --- ##### `pure`Optional ```typescript public readonly pure: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#pure. --- ##### `reserveProps`Optional ```typescript public readonly reserveProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `resolveExtensions`Optional ```typescript public readonly resolveExtensions: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#resolve-extensions. --- ##### `sourcemap`Optional ```typescript public readonly sourcemap: boolean | string; ``` - *Type:* boolean | string Documentation: https://esbuild.github.io/api/#sourcemap. --- ##### `sourceRoot`Optional ```typescript public readonly sourceRoot: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#source-root. --- ##### `sourcesContent`Optional ```typescript public readonly sourcesContent: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#sources-content. --- ##### `splitting`Optional ```typescript public readonly splitting: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#splitting. --- ##### `supported`Optional ```typescript public readonly supported: {[ key: string ]: boolean}; ``` - *Type:* {[ key: string ]: boolean} Documentation: https://esbuild.github.io/api/#supported. --- ##### `target`Optional ```typescript public readonly target: string | string[]; ``` - *Type:* string | string[] Documentation: https://esbuild.github.io/api/#target. --- ##### `treeShaking`Optional ```typescript public readonly treeShaking: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#tree-shaking. --- ##### `tsconfig`Optional ```typescript public readonly tsconfig: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#tsconfig. --- ##### `tsconfigRaw`Optional ```typescript public readonly tsconfigRaw: string | TsconfigRaw; ``` - *Type:* string | TsconfigRaw Documentation: https://esbuild.github.io/api/#tsconfig-raw. --- ##### `write`Optional ```typescript public readonly write: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#write. --- ### BundlerProps #### Initializer ```typescript import { BundlerProps } from '@mrgrain/cdk-esbuild' const bundlerProps: BundlerProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | buildOptions | BuildOptions | Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. | | buildProvider | IBuildProvider | The esbuild Build API implementation to be used. | | copyDir | string \| string[] \| {[ key: string ]: string \| string[]} | Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. | --- ##### `buildOptions`Optional ```typescript public readonly buildOptions: BuildOptions; ``` - *Type:* BuildOptions Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. * `buildOptions.outdir: string` The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \ For example `{ outdir: 'js' }` will create an asset with a single directory called `js`, which contains all built files. This approach can be useful for static website deployments, where JavaScript code should be placed into a subdirectory. \ *Cannot be used together with `outfile`*. * `buildOptions.outfile: string` Relative path to a file inside the CDK asset output directory. For example `{ outfile: 'js/index.js' }` will create an asset with a single directory called `js`, which contains a single file `index.js`. This can be useful to rename the entry point. \ *Cannot be used with multiple entryPoints or together with `outdir`.* * `buildOptions.absWorkingDir: string` Absolute path to the [esbuild working directory](https://esbuild.github.io/api/#working-directory) and defaults to the [current working directory](https://en.wikipedia.org/wiki/Working_directory). \ If paths cannot be found, a good starting point is to look at the concatenation of `absWorkingDir + entryPoint`. It must always be a valid absolute path pointing to the entry point. When needed, the probably easiest way to set absWorkingDir is to use a combination of `resolve` and `__dirname` (see "Library authors" section in the documentation). > [https://esbuild.github.io/api/#build-api](https://esbuild.github.io/api/#build-api) --- ##### `buildProvider`Optional ```typescript public readonly buildProvider: IBuildProvider; ``` - *Type:* IBuildProvider - *Default:* new EsbuildProvider() The esbuild Build API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `IBuildProvider` as an escape hatch. --- ##### `copyDir`Optional ```typescript public readonly copyDir: string | string[] | {[ key: string ]: string | string[]}; ``` - *Type:* string | string[] | {[ key: string ]: string | string[]} Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. * When provided with a `string` or `array`, all files are copied to the root of asset staging directory. * When given a `map`, the key indicates the destination relative to the asset staging directory and the value is a list of all sources to be copied. Therefore the following values for `copyDir` are all equivalent: ``` { copyDir: "path/to/source" } { copyDir: ["path/to/source"] } { copyDir: { ".": "path/to/source" } } { copyDir: { ".": ["path/to/source"] } } ``` The destination cannot be outside of the asset staging directory. If you are receiving the error "Cannot copy files to outside of the asset staging directory." you are likely using `..` or an absolute path as key on the `copyDir` map. Instead use only relative paths and avoid `..`. --- ### CloudFrontFunctionCodeProps Properties for CloudFront Function TypeScript code. #### Initializer ```typescript import { CloudFrontFunctionCodeProps } from '@mrgrain/cdk-esbuild' const cloudFrontFunctionCodeProps: CloudFrontFunctionCodeProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | buildOptions | BuildOptions | Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. | | buildProvider | IBuildProvider | The esbuild Build API implementation to be used. | | runtime | CloudFrontFunctionRuntime | CloudFront Functions JavaScript runtime environment version to build for. | --- ##### `buildOptions`Optional ```typescript public readonly buildOptions: BuildOptions; ``` - *Type:* BuildOptions Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. * `buildOptions.outdir: string` The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \ For example `{ outdir: 'js' }` will create an asset with a single directory called `js`, which contains all built files. This approach can be useful for static website deployments, where JavaScript code should be placed into a subdirectory. \ *Cannot be used together with `outfile`*. * `buildOptions.outfile: string` Relative path to a file inside the CDK asset output directory. For example `{ outfile: 'js/index.js' }` will create an asset with a single directory called `js`, which contains a single file `index.js`. This can be useful to rename the entry point. \ *Cannot be used with multiple entryPoints or together with `outdir`.* * `buildOptions.absWorkingDir: string` Absolute path to the [esbuild working directory](https://esbuild.github.io/api/#working-directory) and defaults to the [current working directory](https://en.wikipedia.org/wiki/Working_directory). \ If paths cannot be found, a good starting point is to look at the concatenation of `absWorkingDir + entryPoint`. It must always be a valid absolute path pointing to the entry point. When needed, the probably easiest way to set absWorkingDir is to use a combination of `resolve` and `__dirname` (see "Library authors" section in the documentation). > [https://esbuild.github.io/api/#build-api](https://esbuild.github.io/api/#build-api) --- ##### `buildProvider`Optional ```typescript public readonly buildProvider: IBuildProvider; ``` - *Type:* IBuildProvider - *Default:* new EsbuildProvider() The esbuild Build API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `IBuildProvider` as an escape hatch. --- ##### `runtime`Optional ```typescript public readonly runtime: CloudFrontFunctionRuntime; ``` - *Type:* CloudFrontFunctionRuntime - *Default:* CloudFrontFunctionRuntime.JS_1_0 CloudFront Functions JavaScript runtime environment version to build for. --- ### CloudFrontFunctionInlineCodeProps Properties for CloudFront Function inline code. #### Initializer ```typescript import { CloudFrontFunctionInlineCodeProps } from '@mrgrain/cdk-esbuild' const cloudFrontFunctionInlineCodeProps: CloudFrontFunctionInlineCodeProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | transformOptions | TransformOptions | Transform options passed on to esbuild. | | transformProvider | ITransformProvider | The esbuild Transform API implementation to be used. | | runtime | CloudFrontFunctionRuntime | CloudFront Functions JavaScript runtime environment version to build for. | --- ##### `transformOptions`Optional ```typescript public readonly transformOptions: TransformOptions; ``` - *Type:* TransformOptions Transform options passed on to esbuild. Please refer to the esbuild Transform API docs for details. > [https://esbuild.github.io/api/#transform-api](https://esbuild.github.io/api/#transform-api) --- ##### `transformProvider`Optional ```typescript public readonly transformProvider: ITransformProvider; ``` - *Type:* ITransformProvider - *Default:* new DefaultEsbuildProvider() The esbuild Transform API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `ITransformProvider` as an escape hatch. --- ##### `runtime`Optional ```typescript public readonly runtime: CloudFrontFunctionRuntime; ``` - *Type:* CloudFrontFunctionRuntime - *Default:* CloudFrontFunctionRuntime.JS_1_0 CloudFront Functions JavaScript runtime environment version to build for. --- ### CodeConfig Result of binding `Code` into a `Function`. #### Initializer ```typescript import { CodeConfig } from '@mrgrain/cdk-esbuild' const codeConfig: CodeConfig = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | image | aws-cdk-lib.aws_lambda.CodeImageConfig | Docker image configuration (mutually exclusive with `s3Location` and `inlineCode`). | | inlineCode | string | Inline code (mutually exclusive with `s3Location` and `image`). | | s3Location | aws-cdk-lib.aws_s3.Location | The location of the code in S3 (mutually exclusive with `inlineCode` and `image`). | --- ##### `image`Optional ```typescript public readonly image: CodeImageConfig; ``` - *Type:* aws-cdk-lib.aws_lambda.CodeImageConfig - *Default:* code is not an ECR container image Docker image configuration (mutually exclusive with `s3Location` and `inlineCode`). --- ##### `inlineCode`Optional ```typescript public readonly inlineCode: string; ``` - *Type:* string - *Default:* code is not inline code Inline code (mutually exclusive with `s3Location` and `image`). --- ##### `s3Location`Optional ```typescript public readonly s3Location: Location; ``` - *Type:* aws-cdk-lib.aws_s3.Location - *Default:* code is not an s3 location The location of the code in S3 (mutually exclusive with `inlineCode` and `image`). --- ### CompilerOptions #### Initializer ```typescript import { CompilerOptions } from '@mrgrain/cdk-esbuild' const compilerOptions: CompilerOptions = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | alwaysStrict | boolean | *No description.* | | baseUrl | string | *No description.* | | experimentalDecorators | boolean | *No description.* | | importsNotUsedAsValues | string | *No description.* | | jsx | string | *No description.* | | jsxFactory | string | *No description.* | | jsxFragmentFactory | string | *No description.* | | jsxImportSource | string | *No description.* | | paths | {[ key: string ]: string[]} | *No description.* | | preserveValueImports | boolean | *No description.* | | strict | boolean | *No description.* | | target | string | *No description.* | | useDefineForClassFields | boolean | *No description.* | | verbatimModuleSyntax | boolean | *No description.* | --- ##### `alwaysStrict`Optional ```typescript public readonly alwaysStrict: boolean; ``` - *Type:* boolean --- ##### `baseUrl`Optional ```typescript public readonly baseUrl: string; ``` - *Type:* string --- ##### `experimentalDecorators`Optional ```typescript public readonly experimentalDecorators: boolean; ``` - *Type:* boolean --- ##### `importsNotUsedAsValues`Optional ```typescript public readonly importsNotUsedAsValues: string; ``` - *Type:* string --- ##### `jsx`Optional ```typescript public readonly jsx: string; ``` - *Type:* string --- ##### `jsxFactory`Optional ```typescript public readonly jsxFactory: string; ``` - *Type:* string --- ##### `jsxFragmentFactory`Optional ```typescript public readonly jsxFragmentFactory: string; ``` - *Type:* string --- ##### `jsxImportSource`Optional ```typescript public readonly jsxImportSource: string; ``` - *Type:* string --- ##### `paths`Optional ```typescript public readonly paths: {[ key: string ]: string[]}; ``` - *Type:* {[ key: string ]: string[]} --- ##### `preserveValueImports`Optional ```typescript public readonly preserveValueImports: boolean; ``` - *Type:* boolean --- ##### `strict`Optional ```typescript public readonly strict: boolean; ``` - *Type:* boolean --- ##### `target`Optional ```typescript public readonly target: string; ``` - *Type:* string --- ##### `useDefineForClassFields`Optional ```typescript public readonly useDefineForClassFields: boolean; ``` - *Type:* boolean --- ##### `verbatimModuleSyntax`Optional ```typescript public readonly verbatimModuleSyntax: boolean; ``` - *Type:* boolean --- ### EsbuildProviderProps Configure the default EsbuildProvider. #### Initializer ```typescript import { EsbuildProviderProps } from '@mrgrain/cdk-esbuild' const esbuildProviderProps: EsbuildProviderProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | esbuildBinaryPath | string | Path to the binary used by esbuild. | | esbuildModulePath | string | Absolute path to the esbuild module JS file. | --- ##### `esbuildBinaryPath`Optional ```typescript public readonly esbuildBinaryPath: string; ``` - *Type:* string Path to the binary used by esbuild. This is the same as setting the ESBUILD_BINARY_PATH environment variable. --- ##### `esbuildModulePath`Optional ```typescript public readonly esbuildModulePath: string; ``` - *Type:* string - *Default:* `CDK_ESBUILD_MODULE_PATH` or package resolution (see description) Absolute path to the esbuild module JS file. E.g. "/home/user/.npm/node_modules/esbuild/lib/main.js" If not set, the module path will be determined in the following order: - Use a path from the `CDK_ESBUILD_MODULE_PATH` environment variable - In TypeScript, fallback to the default Node.js package resolution mechanism - All other languages (Python, Go, .NET, Java) use an automatic "best effort" resolution mechanism. \ The exact algorithm of this mechanism is considered an implementation detail and should not be relied on. If `esbuild` cannot be found, it might be installed dynamically to a temporary location. To opt-out of this behavior, set either `esbuildModulePath` or `CDK_ESBUILD_MODULE_PATH` env variable. Use the static methods on `EsbuildSource` to customize the default behavior. --- ### ProviderBuildOptions #### Initializer ```typescript import { ProviderBuildOptions } from '@mrgrain/cdk-esbuild' const providerBuildOptions: ProviderBuildOptions = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | absPaths | string[] | Documentation: https://esbuild.github.io/api/#abs-paths. | | absWorkingDir | string | Documentation: https://esbuild.github.io/api/#working-directory. | | alias | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#alias. | | allowOverwrite | boolean | Documentation: https://esbuild.github.io/api/#allow-overwrite. | | assetNames | string | Documentation: https://esbuild.github.io/api/#asset-names. | | banner | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#banner. | | bundle | boolean | Documentation: https://esbuild.github.io/api/#bundle. | | charset | string | Documentation: https://esbuild.github.io/api/#charset. | | chunkNames | string | Documentation: https://esbuild.github.io/api/#chunk-names. | | color | boolean | Documentation: https://esbuild.github.io/api/#color. | | conditions | string[] | Documentation: https://esbuild.github.io/api/#conditions. | | define | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#define. | | drop | string[] | Documentation: https://esbuild.github.io/api/#drop. | | dropLabels | string[] | Documentation: https://esbuild.github.io/api/#drop-labels. | | entryNames | string | Documentation: https://esbuild.github.io/api/#entry-names. | | external | string[] | Documentation: https://esbuild.github.io/api/#external. | | footer | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#footer. | | format | string | Documentation: https://esbuild.github.io/api/#format. | | globalName | string | Documentation: https://esbuild.github.io/api/#global-name. | | ignoreAnnotations | boolean | Documentation: https://esbuild.github.io/api/#ignore-annotations. | | inject | string[] | Documentation: https://esbuild.github.io/api/#inject. | | jsx | string | Documentation: https://esbuild.github.io/api/#jsx. | | jsxDev | boolean | Documentation: https://esbuild.github.io/api/#jsx-development. | | jsxFactory | string | Documentation: https://esbuild.github.io/api/#jsx-factory. | | jsxFragment | string | Documentation: https://esbuild.github.io/api/#jsx-fragment. | | jsxImportSource | string | Documentation: https://esbuild.github.io/api/#jsx-import-source. | | jsxSideEffects | boolean | Documentation: https://esbuild.github.io/api/#jsx-side-effects. | | keepNames | boolean | Documentation: https://esbuild.github.io/api/#keep-names. | | legalComments | string | Documentation: https://esbuild.github.io/api/#legal-comments. | | lineLimit | number | Documentation: https://esbuild.github.io/api/#line-limit. | | loader | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#loader. | | logLevel | string | Documentation: https://esbuild.github.io/api/#log-level. | | logLimit | number | Documentation: https://esbuild.github.io/api/#log-limit. | | logOverride | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#log-override. | | mainFields | string[] | Documentation: https://esbuild.github.io/api/#main-fields. | | mangleCache | {[ key: string ]: string \| boolean} | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleQuoted | boolean | Documentation: https://esbuild.github.io/api/#mangle-props. | | metafile | boolean | Documentation: https://esbuild.github.io/api/#metafile. | | minify | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyIdentifiers | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifySyntax | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyWhitespace | boolean | Documentation: https://esbuild.github.io/api/#minify. | | nodePaths | string[] | Documentation: https://esbuild.github.io/api/#node-paths. | | outbase | string | Documentation: https://esbuild.github.io/api/#outbase. | | outdir | string | Documentation: https://esbuild.github.io/api/#outdir. | | outExtension | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#out-extension. | | outfile | string | Documentation: https://esbuild.github.io/api/#outfile. | | packages | string | Documentation: https://esbuild.github.io/api/#packages. | | platform | string | Documentation: https://esbuild.github.io/api/#platform. | | preserveSymlinks | boolean | Documentation: https://esbuild.github.io/api/#preserve-symlinks. | | publicPath | string | Documentation: https://esbuild.github.io/api/#public-path. | | pure | string[] | Documentation: https://esbuild.github.io/api/#pure. | | reserveProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | resolveExtensions | string[] | Documentation: https://esbuild.github.io/api/#resolve-extensions. | | sourcemap | boolean \| string | Documentation: https://esbuild.github.io/api/#sourcemap. | | sourceRoot | string | Documentation: https://esbuild.github.io/api/#source-root. | | sourcesContent | boolean | Documentation: https://esbuild.github.io/api/#sources-content. | | splitting | boolean | Documentation: https://esbuild.github.io/api/#splitting. | | supported | {[ key: string ]: boolean} | Documentation: https://esbuild.github.io/api/#supported. | | target | string \| string[] | Documentation: https://esbuild.github.io/api/#target. | | treeShaking | boolean | Documentation: https://esbuild.github.io/api/#tree-shaking. | | tsconfig | string | Documentation: https://esbuild.github.io/api/#tsconfig. | | tsconfigRaw | string \| TsconfigRaw | Documentation: https://esbuild.github.io/api/#tsconfig-raw. | | write | boolean | Documentation: https://esbuild.github.io/api/#write. | | entryPoints | string[] \| {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#entry-points. | --- ##### `absPaths`Optional ```typescript public readonly absPaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#abs-paths. --- ##### `absWorkingDir`Optional ```typescript public readonly absWorkingDir: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#working-directory. --- ##### `alias`Optional ```typescript public readonly alias: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#alias. --- ##### `allowOverwrite`Optional ```typescript public readonly allowOverwrite: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#allow-overwrite. --- ##### `assetNames`Optional ```typescript public readonly assetNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#asset-names. --- ##### `banner`Optional ```typescript public readonly banner: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#banner. --- ##### `bundle`Optional ```typescript public readonly bundle: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#bundle. --- ##### `charset`Optional ```typescript public readonly charset: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#charset. --- ##### `chunkNames`Optional ```typescript public readonly chunkNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#chunk-names. --- ##### `color`Optional ```typescript public readonly color: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#color. --- ##### `conditions`Optional ```typescript public readonly conditions: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#conditions. --- ##### `define`Optional ```typescript public readonly define: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#define. --- ##### `drop`Optional ```typescript public readonly drop: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop. --- ##### `dropLabels`Optional ```typescript public readonly dropLabels: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop-labels. --- ##### `entryNames`Optional ```typescript public readonly entryNames: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#entry-names. --- ##### `external`Optional ```typescript public readonly external: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#external. --- ##### `footer`Optional ```typescript public readonly footer: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#footer. --- ##### `format`Optional ```typescript public readonly format: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#format. --- ##### `globalName`Optional ```typescript public readonly globalName: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#global-name. --- ##### `ignoreAnnotations`Optional ```typescript public readonly ignoreAnnotations: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#ignore-annotations. --- ##### `inject`Optional ```typescript public readonly inject: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#inject. --- ##### `jsx`Optional ```typescript public readonly jsx: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx. --- ##### `jsxDev`Optional ```typescript public readonly jsxDev: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-development. --- ##### `jsxFactory`Optional ```typescript public readonly jsxFactory: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-factory. --- ##### `jsxFragment`Optional ```typescript public readonly jsxFragment: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-fragment. --- ##### `jsxImportSource`Optional ```typescript public readonly jsxImportSource: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-import-source. --- ##### `jsxSideEffects`Optional ```typescript public readonly jsxSideEffects: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-side-effects. --- ##### `keepNames`Optional ```typescript public readonly keepNames: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#keep-names. --- ##### `legalComments`Optional ```typescript public readonly legalComments: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#legal-comments. --- ##### `lineLimit`Optional ```typescript public readonly lineLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#line-limit. --- ##### `loader`Optional ```typescript public readonly loader: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#loader. --- ##### `logLevel`Optional ```typescript public readonly logLevel: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#log-level. --- ##### `logLimit`Optional ```typescript public readonly logLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#log-limit. --- ##### `logOverride`Optional ```typescript public readonly logOverride: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#log-override. --- ##### `mainFields`Optional ```typescript public readonly mainFields: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#main-fields. --- ##### `mangleCache`Optional ```typescript public readonly mangleCache: {[ key: string ]: string | boolean}; ``` - *Type:* {[ key: string ]: string | boolean} Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleProps`Optional ```typescript public readonly mangleProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleQuoted`Optional ```typescript public readonly mangleQuoted: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `metafile`Optional ```typescript public readonly metafile: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#metafile. --- ##### `minify`Optional ```typescript public readonly minify: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyIdentifiers`Optional ```typescript public readonly minifyIdentifiers: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifySyntax`Optional ```typescript public readonly minifySyntax: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyWhitespace`Optional ```typescript public readonly minifyWhitespace: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `nodePaths`Optional ```typescript public readonly nodePaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#node-paths. --- ##### `outbase`Optional ```typescript public readonly outbase: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outbase. --- ##### `outdir`Optional ```typescript public readonly outdir: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outdir. --- ##### `outExtension`Optional ```typescript public readonly outExtension: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#out-extension. --- ##### `outfile`Optional ```typescript public readonly outfile: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#outfile. --- ##### `packages`Optional ```typescript public readonly packages: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#packages. --- ##### `platform`Optional ```typescript public readonly platform: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#platform. --- ##### `preserveSymlinks`Optional ```typescript public readonly preserveSymlinks: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#preserve-symlinks. --- ##### `publicPath`Optional ```typescript public readonly publicPath: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#public-path. --- ##### `pure`Optional ```typescript public readonly pure: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#pure. --- ##### `reserveProps`Optional ```typescript public readonly reserveProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `resolveExtensions`Optional ```typescript public readonly resolveExtensions: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#resolve-extensions. --- ##### `sourcemap`Optional ```typescript public readonly sourcemap: boolean | string; ``` - *Type:* boolean | string Documentation: https://esbuild.github.io/api/#sourcemap. --- ##### `sourceRoot`Optional ```typescript public readonly sourceRoot: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#source-root. --- ##### `sourcesContent`Optional ```typescript public readonly sourcesContent: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#sources-content. --- ##### `splitting`Optional ```typescript public readonly splitting: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#splitting. --- ##### `supported`Optional ```typescript public readonly supported: {[ key: string ]: boolean}; ``` - *Type:* {[ key: string ]: boolean} Documentation: https://esbuild.github.io/api/#supported. --- ##### `target`Optional ```typescript public readonly target: string | string[]; ``` - *Type:* string | string[] Documentation: https://esbuild.github.io/api/#target. --- ##### `treeShaking`Optional ```typescript public readonly treeShaking: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#tree-shaking. --- ##### `tsconfig`Optional ```typescript public readonly tsconfig: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#tsconfig. --- ##### `tsconfigRaw`Optional ```typescript public readonly tsconfigRaw: string | TsconfigRaw; ``` - *Type:* string | TsconfigRaw Documentation: https://esbuild.github.io/api/#tsconfig-raw. --- ##### `write`Optional ```typescript public readonly write: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#write. --- ##### `entryPoints`Optional ```typescript public readonly entryPoints: string[] | {[ key: string ]: string}; ``` - *Type:* string[] | {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#entry-points. --- ### ProviderTransformOptions #### Initializer ```typescript import { ProviderTransformOptions } from '@mrgrain/cdk-esbuild' const providerTransformOptions: ProviderTransformOptions = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | absPaths | string[] | Documentation: https://esbuild.github.io/api/#abs-paths. | | banner | string | Documentation: https://esbuild.github.io/api/#banner. | | charset | string | Documentation: https://esbuild.github.io/api/#charset. | | color | boolean | Documentation: https://esbuild.github.io/api/#color. | | define | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#define. | | drop | string[] | Documentation: https://esbuild.github.io/api/#drop. | | dropLabels | string[] | Documentation: https://esbuild.github.io/api/#drop-labels. | | footer | string | Documentation: https://esbuild.github.io/api/#footer. | | format | string | Documentation: https://esbuild.github.io/api/#format. | | globalName | string | Documentation: https://esbuild.github.io/api/#global-name. | | ignoreAnnotations | boolean | Documentation: https://esbuild.github.io/api/#ignore-annotations. | | jsx | string | Documentation: https://esbuild.github.io/api/#jsx. | | jsxDev | boolean | Documentation: https://esbuild.github.io/api/#jsx-development. | | jsxFactory | string | Documentation: https://esbuild.github.io/api/#jsx-factory. | | jsxFragment | string | Documentation: https://esbuild.github.io/api/#jsx-fragment. | | jsxImportSource | string | Documentation: https://esbuild.github.io/api/#jsx-import-source. | | jsxSideEffects | boolean | Documentation: https://esbuild.github.io/api/#jsx-side-effects. | | keepNames | boolean | Documentation: https://esbuild.github.io/api/#keep-names. | | legalComments | string | Documentation: https://esbuild.github.io/api/#legal-comments. | | lineLimit | number | Documentation: https://esbuild.github.io/api/#line-limit. | | loader | string | Documentation: https://esbuild.github.io/api/#loader. | | logLevel | string | Documentation: https://esbuild.github.io/api/#log-level. | | logLimit | number | Documentation: https://esbuild.github.io/api/#log-limit. | | logOverride | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#log-override. | | mangleCache | {[ key: string ]: string \| boolean} | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleQuoted | boolean | Documentation: https://esbuild.github.io/api/#mangle-props. | | minify | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyIdentifiers | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifySyntax | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyWhitespace | boolean | Documentation: https://esbuild.github.io/api/#minify. | | platform | string | Documentation: https://esbuild.github.io/api/#platform. | | pure | string[] | Documentation: https://esbuild.github.io/api/#pure. | | reserveProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | sourcefile | string | Documentation: https://esbuild.github.io/api/#sourcefile. | | sourcemap | boolean \| string | Documentation: https://esbuild.github.io/api/#sourcemap. | | sourceRoot | string | Documentation: https://esbuild.github.io/api/#source-root. | | sourcesContent | boolean | Documentation: https://esbuild.github.io/api/#sources-content. | | supported | {[ key: string ]: boolean} | Documentation: https://esbuild.github.io/api/#supported. | | target | string \| string[] | Documentation: https://esbuild.github.io/api/#target. | | treeShaking | boolean | Documentation: https://esbuild.github.io/api/#tree-shaking. | | tsconfigRaw | string \| TsconfigRaw | Documentation: https://esbuild.github.io/api/#tsconfig-raw. | --- ##### `absPaths`Optional ```typescript public readonly absPaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#abs-paths. --- ##### `banner`Optional ```typescript public readonly banner: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#banner. --- ##### `charset`Optional ```typescript public readonly charset: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#charset. --- ##### `color`Optional ```typescript public readonly color: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#color. --- ##### `define`Optional ```typescript public readonly define: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#define. --- ##### `drop`Optional ```typescript public readonly drop: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop. --- ##### `dropLabels`Optional ```typescript public readonly dropLabels: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop-labels. --- ##### `footer`Optional ```typescript public readonly footer: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#footer. --- ##### `format`Optional ```typescript public readonly format: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#format. --- ##### `globalName`Optional ```typescript public readonly globalName: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#global-name. --- ##### `ignoreAnnotations`Optional ```typescript public readonly ignoreAnnotations: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#ignore-annotations. --- ##### `jsx`Optional ```typescript public readonly jsx: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx. --- ##### `jsxDev`Optional ```typescript public readonly jsxDev: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-development. --- ##### `jsxFactory`Optional ```typescript public readonly jsxFactory: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-factory. --- ##### `jsxFragment`Optional ```typescript public readonly jsxFragment: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-fragment. --- ##### `jsxImportSource`Optional ```typescript public readonly jsxImportSource: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-import-source. --- ##### `jsxSideEffects`Optional ```typescript public readonly jsxSideEffects: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-side-effects. --- ##### `keepNames`Optional ```typescript public readonly keepNames: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#keep-names. --- ##### `legalComments`Optional ```typescript public readonly legalComments: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#legal-comments. --- ##### `lineLimit`Optional ```typescript public readonly lineLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#line-limit. --- ##### `loader`Optional ```typescript public readonly loader: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#loader. --- ##### `logLevel`Optional ```typescript public readonly logLevel: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#log-level. --- ##### `logLimit`Optional ```typescript public readonly logLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#log-limit. --- ##### `logOverride`Optional ```typescript public readonly logOverride: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#log-override. --- ##### `mangleCache`Optional ```typescript public readonly mangleCache: {[ key: string ]: string | boolean}; ``` - *Type:* {[ key: string ]: string | boolean} Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleProps`Optional ```typescript public readonly mangleProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleQuoted`Optional ```typescript public readonly mangleQuoted: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `minify`Optional ```typescript public readonly minify: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyIdentifiers`Optional ```typescript public readonly minifyIdentifiers: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifySyntax`Optional ```typescript public readonly minifySyntax: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyWhitespace`Optional ```typescript public readonly minifyWhitespace: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `platform`Optional ```typescript public readonly platform: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#platform. --- ##### `pure`Optional ```typescript public readonly pure: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#pure. --- ##### `reserveProps`Optional ```typescript public readonly reserveProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `sourcefile`Optional ```typescript public readonly sourcefile: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#sourcefile. --- ##### `sourcemap`Optional ```typescript public readonly sourcemap: boolean | string; ``` - *Type:* boolean | string Documentation: https://esbuild.github.io/api/#sourcemap. --- ##### `sourceRoot`Optional ```typescript public readonly sourceRoot: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#source-root. --- ##### `sourcesContent`Optional ```typescript public readonly sourcesContent: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#sources-content. --- ##### `supported`Optional ```typescript public readonly supported: {[ key: string ]: boolean}; ``` - *Type:* {[ key: string ]: boolean} Documentation: https://esbuild.github.io/api/#supported. --- ##### `target`Optional ```typescript public readonly target: string | string[]; ``` - *Type:* string | string[] Documentation: https://esbuild.github.io/api/#target. --- ##### `treeShaking`Optional ```typescript public readonly treeShaking: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#tree-shaking. --- ##### `tsconfigRaw`Optional ```typescript public readonly tsconfigRaw: string | TsconfigRaw; ``` - *Type:* string | TsconfigRaw Documentation: https://esbuild.github.io/api/#tsconfig-raw. --- ### TransformerProps #### Initializer ```typescript import { TransformerProps } from '@mrgrain/cdk-esbuild' const transformerProps: TransformerProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | transformOptions | TransformOptions | Transform options passed on to esbuild. | | transformProvider | ITransformProvider | The esbuild Transform API implementation to be used. | --- ##### `transformOptions`Optional ```typescript public readonly transformOptions: TransformOptions; ``` - *Type:* TransformOptions Transform options passed on to esbuild. Please refer to the esbuild Transform API docs for details. > [https://esbuild.github.io/api/#transform-api](https://esbuild.github.io/api/#transform-api) --- ##### `transformProvider`Optional ```typescript public readonly transformProvider: ITransformProvider; ``` - *Type:* ITransformProvider - *Default:* new DefaultEsbuildProvider() The esbuild Transform API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `ITransformProvider` as an escape hatch. --- ### TransformOptions #### Initializer ```typescript import { TransformOptions } from '@mrgrain/cdk-esbuild' const transformOptions: TransformOptions = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | absPaths | string[] | Documentation: https://esbuild.github.io/api/#abs-paths. | | banner | string | Documentation: https://esbuild.github.io/api/#banner. | | charset | string | Documentation: https://esbuild.github.io/api/#charset. | | color | boolean | Documentation: https://esbuild.github.io/api/#color. | | define | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#define. | | drop | string[] | Documentation: https://esbuild.github.io/api/#drop. | | dropLabels | string[] | Documentation: https://esbuild.github.io/api/#drop-labels. | | footer | string | Documentation: https://esbuild.github.io/api/#footer. | | format | string | Documentation: https://esbuild.github.io/api/#format. | | globalName | string | Documentation: https://esbuild.github.io/api/#global-name. | | ignoreAnnotations | boolean | Documentation: https://esbuild.github.io/api/#ignore-annotations. | | jsx | string | Documentation: https://esbuild.github.io/api/#jsx. | | jsxDev | boolean | Documentation: https://esbuild.github.io/api/#jsx-development. | | jsxFactory | string | Documentation: https://esbuild.github.io/api/#jsx-factory. | | jsxFragment | string | Documentation: https://esbuild.github.io/api/#jsx-fragment. | | jsxImportSource | string | Documentation: https://esbuild.github.io/api/#jsx-import-source. | | jsxSideEffects | boolean | Documentation: https://esbuild.github.io/api/#jsx-side-effects. | | keepNames | boolean | Documentation: https://esbuild.github.io/api/#keep-names. | | legalComments | string | Documentation: https://esbuild.github.io/api/#legal-comments. | | lineLimit | number | Documentation: https://esbuild.github.io/api/#line-limit. | | loader | string | Documentation: https://esbuild.github.io/api/#loader. | | logLevel | string | Documentation: https://esbuild.github.io/api/#log-level. | | logLimit | number | Documentation: https://esbuild.github.io/api/#log-limit. | | logOverride | {[ key: string ]: string} | Documentation: https://esbuild.github.io/api/#log-override. | | mangleCache | {[ key: string ]: string \| boolean} | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | mangleQuoted | boolean | Documentation: https://esbuild.github.io/api/#mangle-props. | | minify | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyIdentifiers | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifySyntax | boolean | Documentation: https://esbuild.github.io/api/#minify. | | minifyWhitespace | boolean | Documentation: https://esbuild.github.io/api/#minify. | | platform | string | Documentation: https://esbuild.github.io/api/#platform. | | pure | string[] | Documentation: https://esbuild.github.io/api/#pure. | | reserveProps | any | Documentation: https://esbuild.github.io/api/#mangle-props. | | sourcefile | string | Documentation: https://esbuild.github.io/api/#sourcefile. | | sourcemap | boolean \| string | Documentation: https://esbuild.github.io/api/#sourcemap. | | sourceRoot | string | Documentation: https://esbuild.github.io/api/#source-root. | | sourcesContent | boolean | Documentation: https://esbuild.github.io/api/#sources-content. | | supported | {[ key: string ]: boolean} | Documentation: https://esbuild.github.io/api/#supported. | | target | string \| string[] | Documentation: https://esbuild.github.io/api/#target. | | treeShaking | boolean | Documentation: https://esbuild.github.io/api/#tree-shaking. | | tsconfigRaw | string \| TsconfigRaw | Documentation: https://esbuild.github.io/api/#tsconfig-raw. | --- ##### `absPaths`Optional ```typescript public readonly absPaths: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#abs-paths. --- ##### `banner`Optional ```typescript public readonly banner: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#banner. --- ##### `charset`Optional ```typescript public readonly charset: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#charset. --- ##### `color`Optional ```typescript public readonly color: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#color. --- ##### `define`Optional ```typescript public readonly define: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#define. --- ##### `drop`Optional ```typescript public readonly drop: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop. --- ##### `dropLabels`Optional ```typescript public readonly dropLabels: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#drop-labels. --- ##### `footer`Optional ```typescript public readonly footer: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#footer. --- ##### `format`Optional ```typescript public readonly format: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#format. --- ##### `globalName`Optional ```typescript public readonly globalName: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#global-name. --- ##### `ignoreAnnotations`Optional ```typescript public readonly ignoreAnnotations: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#ignore-annotations. --- ##### `jsx`Optional ```typescript public readonly jsx: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx. --- ##### `jsxDev`Optional ```typescript public readonly jsxDev: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-development. --- ##### `jsxFactory`Optional ```typescript public readonly jsxFactory: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-factory. --- ##### `jsxFragment`Optional ```typescript public readonly jsxFragment: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-fragment. --- ##### `jsxImportSource`Optional ```typescript public readonly jsxImportSource: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#jsx-import-source. --- ##### `jsxSideEffects`Optional ```typescript public readonly jsxSideEffects: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#jsx-side-effects. --- ##### `keepNames`Optional ```typescript public readonly keepNames: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#keep-names. --- ##### `legalComments`Optional ```typescript public readonly legalComments: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#legal-comments. --- ##### `lineLimit`Optional ```typescript public readonly lineLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#line-limit. --- ##### `loader`Optional ```typescript public readonly loader: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#loader. --- ##### `logLevel`Optional ```typescript public readonly logLevel: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#log-level. --- ##### `logLimit`Optional ```typescript public readonly logLimit: number; ``` - *Type:* number Documentation: https://esbuild.github.io/api/#log-limit. --- ##### `logOverride`Optional ```typescript public readonly logOverride: {[ key: string ]: string}; ``` - *Type:* {[ key: string ]: string} Documentation: https://esbuild.github.io/api/#log-override. --- ##### `mangleCache`Optional ```typescript public readonly mangleCache: {[ key: string ]: string | boolean}; ``` - *Type:* {[ key: string ]: string | boolean} Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleProps`Optional ```typescript public readonly mangleProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `mangleQuoted`Optional ```typescript public readonly mangleQuoted: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `minify`Optional ```typescript public readonly minify: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyIdentifiers`Optional ```typescript public readonly minifyIdentifiers: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifySyntax`Optional ```typescript public readonly minifySyntax: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `minifyWhitespace`Optional ```typescript public readonly minifyWhitespace: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#minify. --- ##### `platform`Optional ```typescript public readonly platform: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#platform. --- ##### `pure`Optional ```typescript public readonly pure: string[]; ``` - *Type:* string[] Documentation: https://esbuild.github.io/api/#pure. --- ##### `reserveProps`Optional ```typescript public readonly reserveProps: any; ``` - *Type:* any Documentation: https://esbuild.github.io/api/#mangle-props. --- ##### `sourcefile`Optional ```typescript public readonly sourcefile: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#sourcefile. --- ##### `sourcemap`Optional ```typescript public readonly sourcemap: boolean | string; ``` - *Type:* boolean | string Documentation: https://esbuild.github.io/api/#sourcemap. --- ##### `sourceRoot`Optional ```typescript public readonly sourceRoot: string; ``` - *Type:* string Documentation: https://esbuild.github.io/api/#source-root. --- ##### `sourcesContent`Optional ```typescript public readonly sourcesContent: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#sources-content. --- ##### `supported`Optional ```typescript public readonly supported: {[ key: string ]: boolean}; ``` - *Type:* {[ key: string ]: boolean} Documentation: https://esbuild.github.io/api/#supported. --- ##### `target`Optional ```typescript public readonly target: string | string[]; ``` - *Type:* string | string[] Documentation: https://esbuild.github.io/api/#target. --- ##### `treeShaking`Optional ```typescript public readonly treeShaking: boolean; ``` - *Type:* boolean Documentation: https://esbuild.github.io/api/#tree-shaking. --- ##### `tsconfigRaw`Optional ```typescript public readonly tsconfigRaw: string | TsconfigRaw; ``` - *Type:* string | TsconfigRaw Documentation: https://esbuild.github.io/api/#tsconfig-raw. --- ### TsconfigRaw #### Initializer ```typescript import { TsconfigRaw } from '@mrgrain/cdk-esbuild' const tsconfigRaw: TsconfigRaw = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | compilerOptions | CompilerOptions | *No description.* | --- ##### `compilerOptions`Optional ```typescript public readonly compilerOptions: CompilerOptions; ``` - *Type:* CompilerOptions --- ### TypeScriptAssetProps #### Initializer ```typescript import { TypeScriptAssetProps } from '@mrgrain/cdk-esbuild' const typeScriptAssetProps: TypeScriptAssetProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | buildOptions | BuildOptions | Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. | | buildProvider | IBuildProvider | The esbuild Build API implementation to be used. | | copyDir | string \| string[] \| {[ key: string ]: string \| string[]} | Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. | | assetHash | string | A hash of this asset, which is available at construction time. | | entryPoints | string \| string[] \| {[ key: string ]: string} | A path or list or map of paths to the entry points of your code. | --- ##### `buildOptions`Optional ```typescript public readonly buildOptions: BuildOptions; ``` - *Type:* BuildOptions Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. * `buildOptions.outdir: string` The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \ For example `{ outdir: 'js' }` will create an asset with a single directory called `js`, which contains all built files. This approach can be useful for static website deployments, where JavaScript code should be placed into a subdirectory. \ *Cannot be used together with `outfile`*. * `buildOptions.outfile: string` Relative path to a file inside the CDK asset output directory. For example `{ outfile: 'js/index.js' }` will create an asset with a single directory called `js`, which contains a single file `index.js`. This can be useful to rename the entry point. \ *Cannot be used with multiple entryPoints or together with `outdir`.* * `buildOptions.absWorkingDir: string` Absolute path to the [esbuild working directory](https://esbuild.github.io/api/#working-directory) and defaults to the [current working directory](https://en.wikipedia.org/wiki/Working_directory). \ If paths cannot be found, a good starting point is to look at the concatenation of `absWorkingDir + entryPoint`. It must always be a valid absolute path pointing to the entry point. When needed, the probably easiest way to set absWorkingDir is to use a combination of `resolve` and `__dirname` (see "Library authors" section in the documentation). > [https://esbuild.github.io/api/#build-api](https://esbuild.github.io/api/#build-api) --- ##### `buildProvider`Optional ```typescript public readonly buildProvider: IBuildProvider; ``` - *Type:* IBuildProvider - *Default:* new EsbuildProvider() The esbuild Build API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `IBuildProvider` as an escape hatch. --- ##### `copyDir`Optional ```typescript public readonly copyDir: string | string[] | {[ key: string ]: string | string[]}; ``` - *Type:* string | string[] | {[ key: string ]: string | string[]} Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. * When provided with a `string` or `array`, all files are copied to the root of asset staging directory. * When given a `map`, the key indicates the destination relative to the asset staging directory and the value is a list of all sources to be copied. Therefore the following values for `copyDir` are all equivalent: ``` { copyDir: "path/to/source" } { copyDir: ["path/to/source"] } { copyDir: { ".": "path/to/source" } } { copyDir: { ".": ["path/to/source"] } } ``` The destination cannot be outside of the asset staging directory. If you are receiving the error "Cannot copy files to outside of the asset staging directory." you are likely using `..` or an absolute path as key on the `copyDir` map. Instead use only relative paths and avoid `..`. --- ##### `assetHash`Optional ```typescript public readonly assetHash: string; ``` - *Type:* string A hash of this asset, which is available at construction time. As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed. Defaults to a hash of all files in the resulting bundle. --- ##### `entryPoints`Required ```typescript public readonly entryPoints: string | string[] | {[ key: string ]: string}; ``` - *Type:* string | string[] | {[ key: string ]: string} A path or list or map of paths to the entry points of your code. Relative paths are by default resolved from the current working directory. To change the working directory, see `buildOptions.absWorkingDir`. Absolute paths can be used if files are part of the working directory. Examples: - `'src/index.ts'` - `require.resolve('./lambda')` - `['src/index.ts', 'src/util.ts']` - `{one: 'src/two.ts', two: 'src/one.ts'}` --- ### TypeScriptCodeProps #### Initializer ```typescript import { TypeScriptCodeProps } from '@mrgrain/cdk-esbuild' const typeScriptCodeProps: TypeScriptCodeProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | buildOptions | BuildOptions | Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. | | buildProvider | IBuildProvider | The esbuild Build API implementation to be used. | | copyDir | string \| string[] \| {[ key: string ]: string \| string[]} | Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. | | assetHash | string | A hash of this asset, which is available at construction time. | --- ##### `buildOptions`Optional ```typescript public readonly buildOptions: BuildOptions; ``` - *Type:* BuildOptions Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. * `buildOptions.outdir: string` The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \ For example `{ outdir: 'js' }` will create an asset with a single directory called `js`, which contains all built files. This approach can be useful for static website deployments, where JavaScript code should be placed into a subdirectory. \ *Cannot be used together with `outfile`*. * `buildOptions.outfile: string` Relative path to a file inside the CDK asset output directory. For example `{ outfile: 'js/index.js' }` will create an asset with a single directory called `js`, which contains a single file `index.js`. This can be useful to rename the entry point. \ *Cannot be used with multiple entryPoints or together with `outdir`.* * `buildOptions.absWorkingDir: string` Absolute path to the [esbuild working directory](https://esbuild.github.io/api/#working-directory) and defaults to the [current working directory](https://en.wikipedia.org/wiki/Working_directory). \ If paths cannot be found, a good starting point is to look at the concatenation of `absWorkingDir + entryPoint`. It must always be a valid absolute path pointing to the entry point. When needed, the probably easiest way to set absWorkingDir is to use a combination of `resolve` and `__dirname` (see "Library authors" section in the documentation). > [https://esbuild.github.io/api/#build-api](https://esbuild.github.io/api/#build-api) --- ##### `buildProvider`Optional ```typescript public readonly buildProvider: IBuildProvider; ``` - *Type:* IBuildProvider - *Default:* new EsbuildProvider() The esbuild Build API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `IBuildProvider` as an escape hatch. --- ##### `copyDir`Optional ```typescript public readonly copyDir: string | string[] | {[ key: string ]: string | string[]}; ``` - *Type:* string | string[] | {[ key: string ]: string | string[]} Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. * When provided with a `string` or `array`, all files are copied to the root of asset staging directory. * When given a `map`, the key indicates the destination relative to the asset staging directory and the value is a list of all sources to be copied. Therefore the following values for `copyDir` are all equivalent: ``` { copyDir: "path/to/source" } { copyDir: ["path/to/source"] } { copyDir: { ".": "path/to/source" } } { copyDir: { ".": ["path/to/source"] } } ``` The destination cannot be outside of the asset staging directory. If you are receiving the error "Cannot copy files to outside of the asset staging directory." you are likely using `..` or an absolute path as key on the `copyDir` map. Instead use only relative paths and avoid `..`. --- ##### `assetHash`Optional ```typescript public readonly assetHash: string; ``` - *Type:* string A hash of this asset, which is available at construction time. As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed. Defaults to a hash of all files in the resulting bundle. --- ### TypeScriptSourceProps #### Initializer ```typescript import { TypeScriptSourceProps } from '@mrgrain/cdk-esbuild' const typeScriptSourceProps: TypeScriptSourceProps = { ... } ``` #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | buildOptions | BuildOptions | Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. | | buildProvider | IBuildProvider | The esbuild Build API implementation to be used. | | copyDir | string \| string[] \| {[ key: string ]: string \| string[]} | Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. | | assetHash | string | A hash of this asset, which is available at construction time. | --- ##### `buildOptions`Optional ```typescript public readonly buildOptions: BuildOptions; ``` - *Type:* BuildOptions Build options passed on to esbuild. Please refer to the esbuild Build API docs for details. * `buildOptions.outdir: string` The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \ For example `{ outdir: 'js' }` will create an asset with a single directory called `js`, which contains all built files. This approach can be useful for static website deployments, where JavaScript code should be placed into a subdirectory. \ *Cannot be used together with `outfile`*. * `buildOptions.outfile: string` Relative path to a file inside the CDK asset output directory. For example `{ outfile: 'js/index.js' }` will create an asset with a single directory called `js`, which contains a single file `index.js`. This can be useful to rename the entry point. \ *Cannot be used with multiple entryPoints or together with `outdir`.* * `buildOptions.absWorkingDir: string` Absolute path to the [esbuild working directory](https://esbuild.github.io/api/#working-directory) and defaults to the [current working directory](https://en.wikipedia.org/wiki/Working_directory). \ If paths cannot be found, a good starting point is to look at the concatenation of `absWorkingDir + entryPoint`. It must always be a valid absolute path pointing to the entry point. When needed, the probably easiest way to set absWorkingDir is to use a combination of `resolve` and `__dirname` (see "Library authors" section in the documentation). > [https://esbuild.github.io/api/#build-api](https://esbuild.github.io/api/#build-api) --- ##### `buildProvider`Optional ```typescript public readonly buildProvider: IBuildProvider; ``` - *Type:* IBuildProvider - *Default:* new EsbuildProvider() The esbuild Build API implementation to be used. Configure the default `EsbuildProvider` for more options or provide a custom `IBuildProvider` as an escape hatch. --- ##### `copyDir`Optional ```typescript public readonly copyDir: string | string[] | {[ key: string ]: string | string[]}; ``` - *Type:* string | string[] | {[ key: string ]: string | string[]} Copy additional files to the code [asset staging directory](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.AssetStaging.html#absolutestagedpath), before the build runs. Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs. * When provided with a `string` or `array`, all files are copied to the root of asset staging directory. * When given a `map`, the key indicates the destination relative to the asset staging directory and the value is a list of all sources to be copied. Therefore the following values for `copyDir` are all equivalent: ``` { copyDir: "path/to/source" } { copyDir: ["path/to/source"] } { copyDir: { ".": "path/to/source" } } { copyDir: { ".": ["path/to/source"] } } ``` The destination cannot be outside of the asset staging directory. If you are receiving the error "Cannot copy files to outside of the asset staging directory." you are likely using `..` or an absolute path as key on the `copyDir` map. Instead use only relative paths and avoid `..`. --- ##### `assetHash`Optional ```typescript public readonly assetHash: string; ``` - *Type:* string A hash of this asset, which is available at construction time. As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed. Defaults to a hash of all files in the resulting bundle. --- ## Classes ### CloudFrontFunctionRuntime CloudFront Functions JavaScript runtime environment version. #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | value | string | *No description.* | --- ##### `value`Required ```typescript public readonly value: string; ``` - *Type:* string --- #### Constants | **Name** | **Type** | **Description** | | --- | --- | --- | | JS_1_0 | CloudFrontFunctionRuntime | cloudfront-js-1.0 - limited ES6 support, no const/let, no async/await. | | JS_2_0 | CloudFrontFunctionRuntime | cloudfront-js-2.0 - enhanced ES6 support, const/let and async/await supported. | --- ##### `JS_1_0`Required ```typescript public readonly JS_1_0: CloudFrontFunctionRuntime; ``` - *Type:* CloudFrontFunctionRuntime cloudfront-js-1.0 - limited ES6 support, no const/let, no async/await. --- ##### `JS_2_0`Required ```typescript public readonly JS_2_0: CloudFrontFunctionRuntime; ``` - *Type:* CloudFrontFunctionRuntime cloudfront-js-2.0 - enhanced ES6 support, const/let and async/await supported. --- ### CloudFrontTypeScriptCode TypeScript code for CloudFront Functions. #### Initializers ```typescript import { CloudFrontTypeScriptCode } from '@mrgrain/cdk-esbuild' new CloudFrontTypeScriptCode() ``` | **Name** | **Type** | **Description** | | --- | --- | --- | --- #### Static Functions | **Name** | **Description** | | --- | --- | | fromFile | Create CloudFront Function code from a TypeScript file. | | fromInline | Create CloudFront Function code from inline TypeScript code. | --- ##### `fromFile` ```typescript import { CloudFrontTypeScriptCode } from '@mrgrain/cdk-esbuild' CloudFrontTypeScriptCode.fromFile(entryPoint: string, props?: CloudFrontFunctionCodeProps) ``` Create CloudFront Function code from a TypeScript file. ###### `entryPoint`Required - *Type:* string --- ###### `props`Optional - *Type:* CloudFrontFunctionCodeProps --- ##### `fromInline` ```typescript import { CloudFrontTypeScriptCode } from '@mrgrain/cdk-esbuild' CloudFrontTypeScriptCode.fromInline(code: string, props?: CloudFrontFunctionInlineCodeProps) ``` Create CloudFront Function code from inline TypeScript code. ###### `code`Required - *Type:* string --- ###### `props`Optional - *Type:* CloudFrontFunctionInlineCodeProps --- ### EsbuildBundler Low-level construct that can be used where `BundlingOptions` are required. This class directly interfaces with esbuild and provides almost no configuration safeguards. #### Initializers ```typescript import { EsbuildBundler } from '@mrgrain/cdk-esbuild' new EsbuildBundler(entryPoints: string | string[] | {[ key: string ]: string}, props: BundlerProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | entryPoints | string \| string[] \| {[ key: string ]: string} | A path or list or map of paths to the entry points of your code. | | props | BundlerProps | Props to change the behavior of the bundler. | --- ##### `entryPoints`Required - *Type:* string | string[] | {[ key: string ]: string} A path or list or map of paths to the entry points of your code. Relative paths are by default resolved from the current working directory. To change the working directory, see `buildOptions.absWorkingDir`. Absolute paths can be used if files are part of the working directory. Examples: - `'src/index.ts'` - `require.resolve('./lambda')` - `['src/index.ts', 'src/util.ts']` - `{one: 'src/two.ts', two: 'src/one.ts'}` --- ##### `props`Required - *Type:* BundlerProps Props to change the behavior of the bundler. --- #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | entryPoints | string \| string[] \| {[ key: string ]: string} | A path or list or map of paths to the entry points of your code. | | image | aws-cdk-lib.DockerImage | *No description.* | | local | aws-cdk-lib.ILocalBundling | Implementation of `ILocalBundling` interface, responsible for calling esbuild functions. | | props | BundlerProps | Props to change the behavior of the bundler. | --- ##### `entryPoints`Required ```typescript public readonly entryPoints: string | string[] | {[ key: string ]: string}; ``` - *Type:* string | string[] | {[ key: string ]: string} A path or list or map of paths to the entry points of your code. Relative paths are by default resolved from the current working directory. To change the working directory, see `buildOptions.absWorkingDir`. Absolute paths can be used if files are part of the working directory. Examples: - `'src/index.ts'` - `require.resolve('./lambda')` - `['src/index.ts', 'src/util.ts']` - `{one: 'src/two.ts', two: 'src/one.ts'}` --- ##### ~~`image`~~Required - *Deprecated:* This value is ignored since the bundler is always using a locally installed version of esbuild. However the property is required to comply with the `BundlingOptions` interface. ```typescript public readonly image: DockerImage; ``` - *Type:* aws-cdk-lib.DockerImage --- ##### `local`Required ```typescript public readonly local: ILocalBundling; ``` - *Type:* aws-cdk-lib.ILocalBundling Implementation of `ILocalBundling` interface, responsible for calling esbuild functions. --- ##### `props`Required ```typescript public readonly props: BundlerProps; ``` - *Type:* BundlerProps Props to change the behavior of the bundler. --- ### EsbuildProvider - *Implements:* IBuildProvider, ITransformProvider Default esbuild implementation calling esbuild's JavaScript API. #### Initializers ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' new EsbuildProvider(props?: EsbuildProviderProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | props | EsbuildProviderProps | *No description.* | --- ##### `props`Optional - *Type:* EsbuildProviderProps --- #### Methods | **Name** | **Description** | | --- | --- | | buildSync | A method implementing the code build. | | transformSync | A method implementing the inline code transformation. | --- ##### `buildSync` ```typescript public buildSync(options: ProviderBuildOptions): void ``` A method implementing the code build. During synth time, the method will receive all computed `BuildOptions` from the bundler. It MUST implement any output options to integrate correctly and MAY use any other options. On failure, it SHOULD print any warnings & errors to stderr and throw a `BuildFailure` to inform the bundler. ###### `options`Required - *Type:* ProviderBuildOptions --- ##### `transformSync` ```typescript public transformSync(input: string, options?: ProviderTransformOptions): string ``` A method implementing the inline code transformation. During synth time, the method will receive the inline code and all computed `TransformOptions` from the bundler. MUST return the transformed code as a string to integrate correctly. It MAY use these options to do so. On failure, it SHOULD print any warnings & errors to stderr and throw a `TransformFailure` to inform the bundler. ###### `input`Required - *Type:* string --- ###### `options`Optional - *Type:* ProviderTransformOptions --- #### Static Functions | **Name** | **Description** | | --- | --- | | defaultBuildProvider | Get the default implementation for the Build API. | | defaultTransformationProvider | Get the default implementation for the Transformation API. | | overrideDefaultBuildProvider | Set the default implementation for the Build API. | | overrideDefaultProvider | Set the default implementation for both Build and Transformation API. | | overrideDefaultTransformationProvider | Set the default implementation for the Transformation API. | --- ##### `defaultBuildProvider` ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' EsbuildProvider.defaultBuildProvider() ``` Get the default implementation for the Build API. ##### `defaultTransformationProvider` ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' EsbuildProvider.defaultTransformationProvider() ``` Get the default implementation for the Transformation API. ##### `overrideDefaultBuildProvider` ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' EsbuildProvider.overrideDefaultBuildProvider(provider: IBuildProvider) ``` Set the default implementation for the Build API. ###### `provider`Required - *Type:* IBuildProvider --- ##### `overrideDefaultProvider` ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' EsbuildProvider.overrideDefaultProvider(provider: IEsbuildProvider) ``` Set the default implementation for both Build and Transformation API. ###### `provider`Required - *Type:* IEsbuildProvider --- ##### `overrideDefaultTransformationProvider` ```typescript import { EsbuildProvider } from '@mrgrain/cdk-esbuild' EsbuildProvider.overrideDefaultTransformationProvider(provider: ITransformProvider) ``` Set the default implementation for the Transformation API. ###### `provider`Required - *Type:* ITransformProvider --- ### EsbuildSource #### Static Functions | **Name** | **Description** | | --- | --- | | anywhere | Try to find the module in most common paths. | | auto | First try to find to module, then install it to a temporary location. | | globalPaths | Try to find the module in common global installation paths. | | install | Install the module to a temporary location. | | nodeJs | Require module by name, do not attempt to find it anywhere else. | | platformDefault | `EsbuildSource.nodeJs()` for NodeJs, `EsbuildSource.auto()` for all other languages. | --- ##### `anywhere` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.anywhere() ``` Try to find the module in most common paths. ##### `auto` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.auto() ``` First try to find to module, then install it to a temporary location. ##### `globalPaths` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.globalPaths() ``` Try to find the module in common global installation paths. ##### `install` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.install() ``` Install the module to a temporary location. ##### `nodeJs` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.nodeJs() ``` Require module by name, do not attempt to find it anywhere else. ##### `platformDefault` ```typescript import { EsbuildSource } from '@mrgrain/cdk-esbuild' EsbuildSource.platformDefault() ``` `EsbuildSource.nodeJs()` for NodeJs, `EsbuildSource.auto()` for all other languages. ### InlineJavaScriptCode An implementation of `lambda.InlineCode` using the esbuild Transform API. Inline function code is limited to 4 KiB after transformation. #### Initializers ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' new InlineJavaScriptCode(code: string, props?: TransformerProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | code | string | The inline code to be transformed. | | props | TransformerProps | Props to change the behavior of the transformer. | --- ##### `code`Required - *Type:* string The inline code to be transformed. --- ##### `props`Optional - *Type:* TransformerProps Props to change the behavior of the transformer. Default values for `props.transformOptions`: - `loader='js'` - `platform=node` - `target=nodeX` with X being the major node version running locally > [https://esbuild.github.io/api/#transform-api](https://esbuild.github.io/api/#transform-api) --- #### Methods | **Name** | **Description** | | --- | --- | | bind | Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. | | bindToResource | Called after the CFN function resource has been created to allow the code class to bind to it. | --- ##### `bind` ```typescript public bind(scope: Construct): CodeConfig ``` Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. ###### `scope`Required - *Type:* constructs.Construct --- ##### `bindToResource` ```typescript public bindToResource(_resource: CfnResource, _options?: ResourceBindOptions): void ``` Called after the CFN function resource has been created to allow the code class to bind to it. Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins. ###### `_resource`Required - *Type:* aws-cdk-lib.CfnResource --- ###### `_options`Optional - *Type:* aws-cdk-lib.aws_lambda.ResourceBindOptions --- #### Static Functions | **Name** | **Description** | | --- | --- | | fromAsset | Loads the function code from a local disk path. | | fromAssetImage | Create an ECR image from the specified asset and bind it as the Lambda code. | | fromBucket | Lambda handler code as an S3 object. | | fromCfnParameters | Creates a new Lambda source defined using CloudFormation parameters. | | fromDockerBuild | Loads the function code from an asset created by a Docker build. | | fromEcrImage | Use an existing ECR image as the Lambda code. | | fromInline | Inline code for Lambda handler. | --- ##### `fromAsset` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromAsset(path: string, options?: AssetOptions) ``` Loads the function code from a local disk path. ###### `path`Required - *Type:* string Either a directory with the Lambda code bundle or a .zip file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_s3_assets.AssetOptions --- ##### `fromAssetImage` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromAssetImage(directory: string, props?: AssetImageCodeProps) ``` Create an ECR image from the specified asset and bind it as the Lambda code. ###### `directory`Required - *Type:* string the directory from which the asset must be created. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.AssetImageCodeProps properties to further configure the selected image. --- ##### `fromBucket` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromBucket(bucket: IBucket, key: string, objectVersion?: string) ``` Lambda handler code as an S3 object. ###### `bucket`Required - *Type:* aws-cdk-lib.aws_s3.IBucket The S3 bucket. --- ###### `key`Required - *Type:* string The object key. --- ###### `objectVersion`Optional - *Type:* string Optional S3 object version. --- ##### `fromCfnParameters` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromCfnParameters(props?: CfnParametersCodeProps) ``` Creates a new Lambda source defined using CloudFormation parameters. ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.CfnParametersCodeProps optional construction properties of {@link CfnParametersCode}. --- ##### `fromDockerBuild` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromDockerBuild(path: string, options?: DockerBuildAssetOptions) ``` Loads the function code from an asset created by a Docker build. By default, the asset is expected to be located at `/asset` in the image. ###### `path`Required - *Type:* string The path to the directory containing the Docker file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_lambda.DockerBuildAssetOptions Docker build options. --- ##### `fromEcrImage` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromEcrImage(repository: IRepository, props?: EcrImageCodeProps) ``` Use an existing ECR image as the Lambda code. ###### `repository`Required - *Type:* aws-cdk-lib.aws_ecr.IRepository the ECR repository that the image is in. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.EcrImageCodeProps properties to further configure the selected image. --- ##### `fromInline` ```typescript import { InlineJavaScriptCode } from '@mrgrain/cdk-esbuild' InlineJavaScriptCode.fromInline(code: string) ``` Inline code for Lambda handler. ###### `code`Required - *Type:* string The actual handler code (limited to 4KiB). --- #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | isInline | boolean | *No description.* | --- ##### `isInline`Required ```typescript public readonly isInline: boolean; ``` - *Type:* boolean --- ### InlineTypeScriptCode An implementation of `lambda.InlineCode` using the esbuild Transform API. Inline function code is limited to 4 KiB after transformation. #### Initializers ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' new InlineTypeScriptCode(code: string, props?: TransformerProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | code | string | The inline code to be transformed. | | props | TransformerProps | Props to change the behavior of the transformer. | --- ##### `code`Required - *Type:* string The inline code to be transformed. --- ##### `props`Optional - *Type:* TransformerProps Props to change the behavior of the transformer. Default values for `transformOptions`: - `loader='ts'` - `platform=node` - `target=nodeX` with X being the major node version running locally > [https://esbuild.github.io/api/#transform-api](https://esbuild.github.io/api/#transform-api) --- #### Methods | **Name** | **Description** | | --- | --- | | bind | Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. | | bindToResource | Called after the CFN function resource has been created to allow the code class to bind to it. | --- ##### `bind` ```typescript public bind(scope: Construct): CodeConfig ``` Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. ###### `scope`Required - *Type:* constructs.Construct --- ##### `bindToResource` ```typescript public bindToResource(_resource: CfnResource, _options?: ResourceBindOptions): void ``` Called after the CFN function resource has been created to allow the code class to bind to it. Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins. ###### `_resource`Required - *Type:* aws-cdk-lib.CfnResource --- ###### `_options`Optional - *Type:* aws-cdk-lib.aws_lambda.ResourceBindOptions --- #### Static Functions | **Name** | **Description** | | --- | --- | | fromAsset | Loads the function code from a local disk path. | | fromAssetImage | Create an ECR image from the specified asset and bind it as the Lambda code. | | fromBucket | Lambda handler code as an S3 object. | | fromCfnParameters | Creates a new Lambda source defined using CloudFormation parameters. | | fromDockerBuild | Loads the function code from an asset created by a Docker build. | | fromEcrImage | Use an existing ECR image as the Lambda code. | | fromInline | Inline code for Lambda handler. | --- ##### `fromAsset` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromAsset(path: string, options?: AssetOptions) ``` Loads the function code from a local disk path. ###### `path`Required - *Type:* string Either a directory with the Lambda code bundle or a .zip file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_s3_assets.AssetOptions --- ##### `fromAssetImage` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromAssetImage(directory: string, props?: AssetImageCodeProps) ``` Create an ECR image from the specified asset and bind it as the Lambda code. ###### `directory`Required - *Type:* string the directory from which the asset must be created. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.AssetImageCodeProps properties to further configure the selected image. --- ##### `fromBucket` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromBucket(bucket: IBucket, key: string, objectVersion?: string) ``` Lambda handler code as an S3 object. ###### `bucket`Required - *Type:* aws-cdk-lib.aws_s3.IBucket The S3 bucket. --- ###### `key`Required - *Type:* string The object key. --- ###### `objectVersion`Optional - *Type:* string Optional S3 object version. --- ##### `fromCfnParameters` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromCfnParameters(props?: CfnParametersCodeProps) ``` Creates a new Lambda source defined using CloudFormation parameters. ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.CfnParametersCodeProps optional construction properties of {@link CfnParametersCode}. --- ##### `fromDockerBuild` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromDockerBuild(path: string, options?: DockerBuildAssetOptions) ``` Loads the function code from an asset created by a Docker build. By default, the asset is expected to be located at `/asset` in the image. ###### `path`Required - *Type:* string The path to the directory containing the Docker file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_lambda.DockerBuildAssetOptions Docker build options. --- ##### `fromEcrImage` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromEcrImage(repository: IRepository, props?: EcrImageCodeProps) ``` Use an existing ECR image as the Lambda code. ###### `repository`Required - *Type:* aws-cdk-lib.aws_ecr.IRepository the ECR repository that the image is in. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.EcrImageCodeProps properties to further configure the selected image. --- ##### `fromInline` ```typescript import { InlineTypeScriptCode } from '@mrgrain/cdk-esbuild' InlineTypeScriptCode.fromInline(code: string) ``` Inline code for Lambda handler. ###### `code`Required - *Type:* string The actual handler code (limited to 4KiB). --- #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | isInline | boolean | *No description.* | --- ##### `isInline`Required ```typescript public readonly isInline: boolean; ``` - *Type:* boolean --- ### TypeScriptCode Represents the deployed TypeScript Code. #### Initializers ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' new TypeScriptCode(entryPoints: string | string[] | {[ key: string ]: string}, props?: TypeScriptCodeProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | entryPoints | string \| string[] \| {[ key: string ]: string} | A path or list or map of paths to the entry points of your code. | | props | TypeScriptCodeProps | Props to change the behavior of the bundler. | --- ##### `entryPoints`Required - *Type:* string | string[] | {[ key: string ]: string} A path or list or map of paths to the entry points of your code. Relative paths are by default resolved from the current working directory. To change the working directory, see `buildOptions.absWorkingDir`. Absolute paths can be used if files are part of the working directory. Examples: - `'src/index.ts'` - `require.resolve('./lambda')` - `['src/index.ts', 'src/util.ts']` - `{one: 'src/two.ts', two: 'src/one.ts'}` --- ##### `props`Optional - *Type:* TypeScriptCodeProps Props to change the behavior of the bundler. Default values for `props.buildOptions`: - `bundle=true` - `platform=node` - `target=nodeX` with X being the major node version running locally --- #### Methods | **Name** | **Description** | | --- | --- | | bind | Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. | | bindToResource | Called after the CFN function resource has been created to allow the code class to bind to it. | --- ##### `bind` ```typescript public bind(scope: Construct): CodeConfig ``` Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. ###### `scope`Required - *Type:* constructs.Construct --- ##### `bindToResource` ```typescript public bindToResource(resource: CfnResource, options?: ResourceBindOptions): void ``` Called after the CFN function resource has been created to allow the code class to bind to it. Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins. ###### `resource`Required - *Type:* aws-cdk-lib.CfnResource --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_lambda.ResourceBindOptions --- #### Static Functions | **Name** | **Description** | | --- | --- | | fromAsset | Loads the function code from a local disk path. | | fromAssetImage | Create an ECR image from the specified asset and bind it as the Lambda code. | | fromBucket | Lambda handler code as an S3 object. | | fromCfnParameters | Creates a new Lambda source defined using CloudFormation parameters. | | fromDockerBuild | Loads the function code from an asset created by a Docker build. | | fromEcrImage | Use an existing ECR image as the Lambda code. | | fromInline | Inline code for Lambda handler. | --- ##### `fromAsset` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromAsset(path: string, options?: AssetOptions) ``` Loads the function code from a local disk path. ###### `path`Required - *Type:* string Either a directory with the Lambda code bundle or a .zip file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_s3_assets.AssetOptions --- ##### `fromAssetImage` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromAssetImage(directory: string, props?: AssetImageCodeProps) ``` Create an ECR image from the specified asset and bind it as the Lambda code. ###### `directory`Required - *Type:* string the directory from which the asset must be created. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.AssetImageCodeProps properties to further configure the selected image. --- ##### `fromBucket` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromBucket(bucket: IBucket, key: string, objectVersion?: string) ``` Lambda handler code as an S3 object. ###### `bucket`Required - *Type:* aws-cdk-lib.aws_s3.IBucket The S3 bucket. --- ###### `key`Required - *Type:* string The object key. --- ###### `objectVersion`Optional - *Type:* string Optional S3 object version. --- ##### `fromCfnParameters` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromCfnParameters(props?: CfnParametersCodeProps) ``` Creates a new Lambda source defined using CloudFormation parameters. ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.CfnParametersCodeProps optional construction properties of {@link CfnParametersCode}. --- ##### `fromDockerBuild` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromDockerBuild(path: string, options?: DockerBuildAssetOptions) ``` Loads the function code from an asset created by a Docker build. By default, the asset is expected to be located at `/asset` in the image. ###### `path`Required - *Type:* string The path to the directory containing the Docker file. --- ###### `options`Optional - *Type:* aws-cdk-lib.aws_lambda.DockerBuildAssetOptions Docker build options. --- ##### `fromEcrImage` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromEcrImage(repository: IRepository, props?: EcrImageCodeProps) ``` Use an existing ECR image as the Lambda code. ###### `repository`Required - *Type:* aws-cdk-lib.aws_ecr.IRepository the ECR repository that the image is in. --- ###### `props`Optional - *Type:* aws-cdk-lib.aws_lambda.EcrImageCodeProps properties to further configure the selected image. --- ##### `fromInline` ```typescript import { TypeScriptCode } from '@mrgrain/cdk-esbuild' TypeScriptCode.fromInline(code: string) ``` Inline code for Lambda handler. ###### `code`Required - *Type:* string The actual handler code (limited to 4KiB). --- #### Properties | **Name** | **Type** | **Description** | | --- | --- | --- | | isInline | boolean | Determines whether this Code is inline code or not. | --- ##### ~~`isInline`~~Required - *Deprecated:* this value is ignored since inline is now determined based on the the inlineCode field of CodeConfig returned from bind(). ```typescript public readonly isInline: boolean; ``` - *Type:* boolean Determines whether this Code is inline code or not. --- ### TypeScriptSource - *Implements:* aws-cdk-lib.aws_s3_deployment.ISource #### Initializers ```typescript import { TypeScriptSource } from '@mrgrain/cdk-esbuild' new TypeScriptSource(entryPoints: string | string[] | {[ key: string ]: string}, props?: TypeScriptSourceProps) ``` | **Name** | **Type** | **Description** | | --- | --- | --- | | entryPoints | string \| string[] \| {[ key: string ]: string} | A path or list or map of paths to the entry points of your code. | | props | TypeScriptSourceProps | Props to change the behavior of the bundler. | --- ##### `entryPoints`Required - *Type:* string | string[] | {[ key: string ]: string} A path or list or map of paths to the entry points of your code. Relative paths are by default resolved from the current working directory. To change the working directory, see `buildOptions.absWorkingDir`. Absolute paths can be used if files are part of the working directory. Examples: - `'src/index.ts'` - `require.resolve('./lambda')` - `['src/index.ts', 'src/util.ts']` - `{one: 'src/two.ts', two: 'src/one.ts'}` --- ##### `props`Optional - *Type:* TypeScriptSourceProps Props to change the behavior of the bundler. Default values for `props.buildOptions`: - `bundle=true` - `platform=browser` --- #### Methods | **Name** | **Description** | | --- | --- | | bind | Binds the source to a bucket deployment. | --- ##### `bind` ```typescript public bind(scope: Construct, context?: DeploymentSourceContext): SourceConfig ``` Binds the source to a bucket deployment. ###### `scope`Required - *Type:* constructs.Construct --- ###### `context`Optional - *Type:* aws-cdk-lib.aws_s3_deployment.DeploymentSourceContext --- ## Protocols ### IBuildProvider - *Implemented By:* EsbuildProvider, IBuildProvider, IEsbuildProvider Provides an implementation of the esbuild Build API. #### Methods | **Name** | **Description** | | --- | --- | | buildSync | A method implementing the code build. | --- ##### `buildSync` ```typescript public buildSync(options: ProviderBuildOptions): void ``` A method implementing the code build. During synth time, the method will receive all computed `BuildOptions` from the bundler. It MUST implement any output options to integrate correctly and MAY use any other options. On failure, it SHOULD print any warnings & errors to stderr and throw a `BuildFailure` to inform the bundler. ###### `options`Required - *Type:* ProviderBuildOptions --- ### IEsbuildProvider - *Extends:* IBuildProvider, ITransformProvider - *Implemented By:* IEsbuildProvider Provides an implementation of the esbuild Build & Transform API. ### ITransformProvider - *Implemented By:* EsbuildProvider, IEsbuildProvider, ITransformProvider Provides an implementation of the esbuild Transform API. #### Methods | **Name** | **Description** | | --- | --- | | transformSync | A method implementing the inline code transformation. | --- ##### `transformSync` ```typescript public transformSync(input: string, options?: ProviderTransformOptions): string ``` A method implementing the inline code transformation. During synth time, the method will receive the inline code and all computed `TransformOptions` from the bundler. MUST return the transformed code as a string to integrate correctly. It MAY use these options to do so. On failure, it SHOULD print any warnings & errors to stderr and throw a `TransformFailure` to inform the bundler. ###### `input`Required - *Type:* string --- ###### `options`Optional - *Type:* ProviderTransformOptions ---