@mrgrain/cdk-esbuild 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +0 -1
- package/.jsii +54 -18
- package/.projenrc.ts +2 -6
- package/API.md +120 -42
- package/CHANGELOG.md +2 -2
- package/README.md +25 -23
- package/lib/asset.js +2 -2
- package/lib/bundler.d.ts +21 -5
- package/lib/bundler.js +44 -7
- package/lib/code.js +2 -2
- package/lib/esbuild-types.d.ts +9 -0
- package/lib/esbuild-types.js +1 -1
- package/lib/inline-code.js +4 -4
- package/lib/source.js +2 -2
- package/package.json +14 -14
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
package/.gitattributes
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/.github/pull_request_template.md linguist-generated
|
|
7
7
|
/.github/workflows/build.yml linguist-generated
|
|
8
8
|
/.github/workflows/pull-request-lint.yml linguist-generated
|
|
9
|
-
/.github/workflows/stale.yml linguist-generated
|
|
10
9
|
/.gitignore linguist-generated
|
|
11
10
|
/.mergify.yml linguist-generated
|
|
12
11
|
/.npmignore linguist-generated
|
package/.jsii
CHANGED
|
@@ -2777,7 +2777,7 @@
|
|
|
2777
2777
|
"stability": "stable"
|
|
2778
2778
|
},
|
|
2779
2779
|
"homepage": "https://github.com/mrgrain/cdk-esbuild",
|
|
2780
|
-
"jsiiVersion": "1.
|
|
2780
|
+
"jsiiVersion": "1.57.0 (build f614666)",
|
|
2781
2781
|
"keywords": [
|
|
2782
2782
|
"aws-cdk",
|
|
2783
2783
|
"bundler",
|
|
@@ -2800,7 +2800,7 @@
|
|
|
2800
2800
|
},
|
|
2801
2801
|
"name": "@mrgrain/cdk-esbuild",
|
|
2802
2802
|
"readme": {
|
|
2803
|
-
"markdown": "# cdk-esbuild\n\n_CDK constructs for [esbuild](https://github.com/evanw/esbuild), an extremely fast JavaScript bundler_\n\n> ⚠️ This version is compatible with AWS CDK v2. For the previous, AWS CDK v1 compatible release, see [cdk-esbuild@v2](https://github.com/mrgrain/cdk-esbuild/tree/v2)\n\n[Getting started](#getting-started) | [Migrating to v3](#migrating-to-v3) |\n[Documentation](#documentation) | [API Reference](#api-reference) | [Versioning](#versioning)\n\n## Why?\n\n_esbuild_ is an extremely fast bundler and minifier for Typescript and JavaScript.\nThis package makes _esbuild_ available to deploy lambda functions, static websites or to publish build artefacts (assets) for further use.\n\nAWS CDK [supports _esbuild_ with Lambda Functions](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html). However the implementation cannot be used with any other Constructs and doesn't expose all of _esbuild_'s build interface.\n\nThis package is running _esbuild_ directly in Node.js and bypasses Docker which the AWS CDK implementation uses. The approach is quicker and easier to use for Node.js users, but incompatible with other languages.\n\n**Production readiness**\n\nThis package is generally stable and ready to be used in production, as many do. However _esbuild_ not yet released a version 1.0.0 yet and its API is still in active development. Please check their guide on [production readiness](https://esbuild.github.io/faq/#production-readiness).\n\nNotably upgrades of the _esbuild_ minimum version requirement will be introduced in **minor versions** of this package and will inherit breaking changes from _esbuild_.\n\n## Getting started\n\nInstall `cdk-esbuild`:\n\n```\nnpm install @mrgrain/cdk-esbuild@3\n```\n\nIf _peer_ and _optional dependencies_ are not installed automatically (e.g. when using npm v4-6), please use this command to install all of them:\n\n```\nnpm install @mrgrain/cdk-esbuild@3 esbuild\n```\n\n### AWS Lambda: Serverless function\n\n> 💡 See [Lambda Function](examples/lambda) for a complete working example of a how to deploy a lambda function.\n\nUse `TypeScriptCode` as the `code` of a [lambda function](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#code):\n\n```ts\nimport * as lambda from \"aws-cdk-lib/aws-lambda\";\nimport { TypeScriptCode } from \"@mrgrain/cdk-esbuild\";\n\nconst bundledCode = new TypeScriptCode(\"src/index.ts\");\n\nconst fn = new lambda.Function(stack, \"MyFunction\", {\n runtime: lambda.Runtime.NODEJS_14_X,\n handler: \"index.handler\",\n code: bundledCode,\n});\n```\n\n### AWS S3: Static Website\n\n> 💡 See [Static Website with React](examples/website) for a complete working example of a how to deploy a React app to S3.\n\nUse `TypeScriptSource` as one of the `sources` of a [static website deployment](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-deployment-readme.html#roadmap):\n\n```ts\nimport * as s3 from \"aws-cdk-lib/aws-s3\";\nimport * as s3deploy from \"aws-cdk-lib/aws-s3-deployment\";\nimport { TypeScriptSource } from \"@mrgrain/cdk-esbuild\";\n\nconst websiteBundle = new TypeScriptSource(\"src/index.tsx\");\n\nconst websiteBucket = new s3.Bucket(stack, \"WebsiteBucket\", {\n autoDeleteObjects: true,\n publicReadAccess: true,\n removalPolicy: RemovalPolicy.DESTROY,\n websiteIndexDocument: \"index.html\",\n});\n\nnew s3deploy.BucketDeployment(stack, \"DeployWebsite\", {\n destinationBucket: websiteBucket,\n sources: [websiteBundle],\n});\n```\n\n### Amazon CloudWatch Synthetics: Canary monitoring\n\n> 💡 See [Monitored Website](examples/website) for a complete working example of a deployed and monitored website.\n\nSynthetics runs a canary to produce traffic to an application for monitoring purposes. Use `TypeScriptCode` as the `code` of a Canary test:\n\n> ℹ️ This feature depends on the `@aws-cdk/aws-synthetics-alpha` package which is a developer preview. You may need to update your source code when upgrading to a newer version of this package.\n>\n> ```\n> npm i @aws-cdk/aws-synthetics-alpha\n> ```\n\n```ts\nimport * as synthetics from \"@aws-cdk/aws-synthetics-alpha\";\nimport { TypeScriptCode } from \"@mrgrain/cdk-esbuild\";\n\nconst bundledCode = new TypeScriptCode(\"src/index.ts\", {\n buildOptions: {\n outdir: \"nodejs/node_modules\", // This is required by Synthetics\n },\n});\n\nconst canary = new synthetics.Canary(stack, \"MyCanary\", {\n runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2,\n test: synthetics.Test.custom({\n code: bundledCode,\n handler: \"index.handler\",\n });\n});\n```\n\n# Documentation\n\nThe package exports various different constructs for use with existing CDK features. A major guiding design principal for this package is to _extend, don't replace_. Expect constructs that you can provide as props, not complete replacements.\n\nFor use in **Lambda Functions** and **Synthetic Canaries**, the following classes implement `lambda.Code` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Code.html)) and `synthetics.Code` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-synthetics-alpha.Code.html)):\n\n- `TypeScriptCode` & `JavaScriptCode`\n\nInline code is only supported by **Lambda**:\n\n- `InlineTypeScriptCode` & `InlineJavaScriptCode`\n- `InlineTsxCode` & `InlineJsxCode`\n\nFor use with **S3 bucket deployments**, classes implementing `s3deploy.ISource` ([reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-deployment-readme.html)):\n\n- `TypeScriptSource` & `JavaScriptSource`\n\n> _Code and Source constructs seamlessly plugin to high-level CDK features. They share the same set of parameters, props and build options._\n\nUnderlying classes power the other features. You normally won't have to use them, but they are there if you need them:\n\n- `TypeScriptAsset` & `JavaScriptAsset` implements `s3.Asset` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)) \\\n creates an asset uploaded to S3 which can be referenced by other constructs\n\n- `EsbuildBundler` implements `core.BundlingOptions` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html)) \\\n provides an interface for a _esbuild_ bundler wherever needed\n\n## [API Reference](API.md)\n\nAuto-generated reference for classes and structs. This information is also available within the code completion of your IDE.\n\n## Escape hatches\n\nIt's possible that you want to use a implementation of esbuild that's different to the default one. Common reasons are:\n\n- The current version constraints for esbuild are not suitable\n- To use version of esbuild that is installed by any other means than `npm`, including Docker\n- Plugin support is needed for the building\n\nFor these situations, this package offers an escape hatch to bypass regular the implementation and provide a custom build and transform function.\n\n### Custom build function\n\n> 💡 See [Using esbuild with plugins](examples/esbuild-with-plugins) for a complete working example of a custom build function using this escape hatch.\n\nConstructs that result in starting a build, take a `buildFn` as optional prop. While the defined type for this function is `any`, it must implement the same signature as esbuild's `buildSync` function.\n\n```ts\nnew TypeScriptCode(\"fixtures/handlers/ts-handler.ts\", {\n buildFn: (options: BuildOptions): BuildResult => {\n try {\n // custom implementation returning BuildResult\n } catch (error) {\n // throw BuildFailure exception here\n }\n },\n});\n```\n\nInstead of esbuild, the provided function will be invoked with the calculated build options. The custom build function can amend, change or discard any of these. However integration with CDK relies heavily on the values `outdir`/`outfile` are set to and it's usually required to use them unchanged.\n\nFailures have to cause a `BuildFailure` exception in order to be fully handled.\n\n### Custom transform function\n\nConstructs that result in starting a transformation, take a `transformFn` as optional prop. While the defined type for this function is `any`, it must implement the same signature as esbuild's `transformSync` function.\n\n```ts\nnew InlineTypeScriptCode(\"let x: number = 1\", {\n transformFn: (options: TransformOptions): TransformResult => {\n try {\n // custom implementation returning TransformResult\n } catch (error) {\n // throw TransformFailure exception here\n }\n },,\n});\n```\n\nInstead of esbuild, the provided function will be invoked with the calculated transform options. The custom transform function can amend, change or discard any of these.\n\nFailures have to cause a `TransformFailure` exception in order to be fully handled.\n\n## Migrating to v3\n\nThe release of cdk-esbuild v3 brings compatibility with AWS CDK v2. Furthermore all deprecated properties and classes have been removed. In particular `InlineCode` classes now take `TransformerProps` as second parameter instead of transform options.\n\n### Upgrading\n\n- This version requires AWS CDK v2. Follow the [official migration guide](https://docs.aws.amazon.com/cdk/latest/guide/work-with-cdk-v2.html) to upgrade.\n- Update the package dependency to v3: `npm install --save @mrgrain/cdk-esbuild@^3.0.0`\n- `esbuild` is installed as an optional dependency. If your setup does not automatically install optional dependencies, make sure to add it as an explicit dependency.\n- Any use of `InlineCode` variations has to be updated. Previously the second parameter was either of type `TransformerProps` or `TransformOptions`. Now it must be `TransformerProps`.\\\n If the passed value is of type `TransformOptions`, turn it into the correct type like this:\n\n ```ts\n const oldOptions: TransformOptions = {...}\n\n new InlineTypeScriptCode('// inline code', {\n transformOptions: oldOptions\n });\n ```\n\n## Versioning\n\nThis package _mostly_ follows [Semantic Versioning](https://semver.org/), with the exception of upgrades to `esbuild`. These will be released as **minor versions** and often include breaking changes from `esbuild`.\n\n### Npm Tags\n\nSome users prefer to use tags over version ranges. The following stable tags are available for use:\n\n- `cdk-v1`, `cdk-v2` are provided for the latest release compatible with each version of the AWS CDK.\n\n- `latest` is the most recent stable release.\n\nThese tags also exist, but usage is strongly not recommended:\n\n- `unstable`, `next` are used for pre-release of the current and next major version respectively.\n\n- ~~`cdk-1.x.x`~~ tags have been deprecated in favour of `cdk-v1`. Use that one instead.\n\n## Future releases\n\n### Stable esbuild\n\nOnce `esbuild` has reached a stable version 1.0, a new major version will be released for _all_ breaking changes, including updates to minimum (peer) dependencies.\n\n## Library authors\n\nWhen developing a library consumed by other packages, you'll most likely have to set `buildOptions.absWorkingDir`. The easiest way to do this, is to resolve based on the directory name of the file, and traverse the tree upwards to the root of your library package (that's where `package.json` and `tsconfig.json` are):\n\n```ts\n// file: project/src/index.ts\nconst props = {\n buildOptions: {\n absWorkingDir: path.resolve(__dirname, \"..\"), // now: /user/project\n },\n};\n```\n\nThis will dynamically resolve to the correct path, wherever the package is installed.\n"
|
|
2803
|
+
"markdown": "# cdk-esbuild\n\n_CDK constructs for [esbuild](https://github.com/evanw/esbuild), an extremely fast JavaScript bundler_\n\n[Getting started](#getting-started) | [Migrating to v3](#migrating-to-v3) |\n[Documentation](#documentation) | [API Reference](#api-reference) | [Versioning](#versioning)\n\n> This version is compatible with AWS CDK v2. For the previous, AWS CDK v1 compatible release, see [cdk-esbuild@v2](https://github.com/mrgrain/cdk-esbuild/tree/v2).\n\n## Why?\n\n_esbuild_ is an extremely fast bundler and minifier for Typescript and JavaScript.\nThis package makes _esbuild_ available to deploy lambda functions, static websites or to publish build artefacts (assets) for further use.\n\nAWS CDK [supports _esbuild_ with Lambda Functions](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html). However the implementation cannot be used with any other Constructs and doesn't expose all of _esbuild_'s build interface.\n\nThis package is running _esbuild_ directly in Node.js and bypasses Docker which the AWS CDK implementation uses. The approach is quicker and easier to use for Node.js users, but incompatible with other languages.\n\n**Production readiness**\n\nThis package is stable and ready to be used in production, as many do. However _esbuild_ has not yet released a version 1.0.0 and its API is still in active development. Please read the guide on [esbuild's production readiness](https://esbuild.github.io/faq/#production-readiness).\n\nNotably upgrades of the _esbuild_ minimum version requirement will be introduced in **minor versions** of this package and will inherit breaking changes from _esbuild_.\n\n## Getting started\n\nInstall `cdk-esbuild`:\n\n```\nnpm install @mrgrain/cdk-esbuild@3\n```\n\nIf _peer_ or _optional dependencies_ are not installed automatically (e.g. when using npm v4-6), please use this command to install all of them:\n\n```\nnpm install @mrgrain/cdk-esbuild@3 esbuild\n```\n\n### AWS Lambda: Serverless function\n\n> 💡 See [Lambda Function](examples/lambda) for a complete working example of a how to deploy a lambda function.\n\nUse `TypeScriptCode` as the `code` of a [lambda function](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Function.html#code):\n\n```ts\nimport * as lambda from \"aws-cdk-lib/aws-lambda\";\nimport { TypeScriptCode } from \"@mrgrain/cdk-esbuild\";\n\nconst bundledCode = new TypeScriptCode(\"src/index.ts\");\n\nconst fn = new lambda.Function(stack, \"MyFunction\", {\n runtime: lambda.Runtime.NODEJS_16_X,\n handler: \"index.handler\",\n code: bundledCode,\n});\n```\n\n### AWS S3: Static Website\n\n> 💡 See [Static Website with React](examples/website) for a complete working example of a how to deploy a React app to S3.\n\nUse `TypeScriptSource` as one of the `sources` of a [static website deployment](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-deployment-readme.html#roadmap):\n\n```ts\nimport * as s3 from \"aws-cdk-lib/aws-s3\";\nimport * as s3deploy from \"aws-cdk-lib/aws-s3-deployment\";\nimport { TypeScriptSource } from \"@mrgrain/cdk-esbuild\";\n\nconst websiteBundle = new TypeScriptSource(\"src/index.tsx\");\n\nconst websiteBucket = new s3.Bucket(stack, \"WebsiteBucket\", {\n autoDeleteObjects: true,\n publicReadAccess: true,\n removalPolicy: RemovalPolicy.DESTROY,\n websiteIndexDocument: \"index.html\",\n});\n\nnew s3deploy.BucketDeployment(stack, \"DeployWebsite\", {\n destinationBucket: websiteBucket,\n sources: [websiteBundle],\n});\n```\n\n### Amazon CloudWatch Synthetics: Canary monitoring\n\n> 💡 See [Monitored Website](examples/website) for a complete working example of a deployed and monitored website.\n\nSynthetics runs a canary to produce traffic to an application for monitoring purposes. Use `TypeScriptCode` as the `code` of a Canary test:\n\n> ℹ️ This feature depends on the `@aws-cdk/aws-synthetics-alpha` package which is a developer preview. You may need to update your source code when upgrading to a newer version of this package.\n>\n> ```\n> npm i @aws-cdk/aws-synthetics-alpha\n> ```\n\n```ts\nimport * as synthetics from \"@aws-cdk/aws-synthetics-alpha\";\nimport { TypeScriptCode } from \"@mrgrain/cdk-esbuild\";\n\nconst bundledCode = new TypeScriptCode(\"src/index.ts\", {\n buildOptions: {\n outdir: \"nodejs/node_modules\", // This is required by Synthetics\n },\n});\n\nconst canary = new synthetics.Canary(stack, \"MyCanary\", {\n runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_2,\n test: synthetics.Test.custom({\n code: bundledCode,\n handler: \"index.handler\",\n });\n});\n```\n\n## Documentation\n\nThe package exports various different constructs for use with existing CDK features. A major guiding design principal for this package is to _extend, don't replace_. Expect constructs that you can provide as props, not complete replacements.\n\nFor use in **Lambda Functions** and **Synthetic Canaries**, the following classes implement `lambda.Code` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Code.html)) and `synthetics.Code` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-synthetics-alpha.Code.html)):\n\n- `TypeScriptCode` & `JavaScriptCode`\n\nInline code is only supported by **Lambda**:\n\n- `InlineTypeScriptCode` & `InlineJavaScriptCode`\n- `InlineTsxCode` & `InlineJsxCode`\n\nFor use with **S3 bucket deployments**, classes implementing `s3deploy.ISource` ([reference](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-s3-deployment-readme.html)):\n\n- `TypeScriptSource` & `JavaScriptSource`\n\n> _Code and Source constructs seamlessly plug-in to other high-level CDK constructs. They share the same set of parameters, props and build options._\n\nThe following classes power the other features. You normally won't have to use them, but they are there if you need them:\n\n- `TypeScriptAsset` & `JavaScriptAsset` implements `s3.Asset` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)) \\\n creates an asset uploaded to S3 which can be referenced by other constructs\n\n- `EsbuildBundler` implements `core.BundlingOptions` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html)) \\\n provides an interface for a _esbuild_ bundler wherever needed\n\n### [API Reference](API.md)\n\nAuto-generated reference for classes and structs. This information is also available as part of your IDE's code completion.\n\n### Escape hatches\n\nIt's possible that you want to use an implementation of esbuild that's different to the default one. Common reasons are:\n\n- The current version constraints for esbuild are not suitable\n- To use a version of esbuild that is installed by any other means than `npm`, including Docker\n- Plugin support is needed for building\n\nFor these situations, this package offers an escape hatch to bypass regular the implementation and provide a custom build and transform function.\n\n#### Custom build function\n\n> 💡 See [Using esbuild with plugins](examples/esbuild-with-plugins) for a complete working example of a custom build function using this escape hatch.\n\nConstructs that result in starting a build, take a `buildFn` as optional prop. While the defined type for this function is `any`, it must implement the same signature as esbuild's `buildSync` function.\n\n```ts\nnew TypeScriptCode(\"fixtures/handlers/ts-handler.ts\", {\n buildFn: (options: BuildOptions): BuildResult => {\n try {\n // custom implementation returning BuildResult\n } catch (error) {\n // throw BuildFailure exception here\n }\n },\n});\n```\n\nInstead of esbuild, the provided function will be invoked with the calculated build options. The custom build function can amend, change or discard any of these. However integration with CDK relies heavily on the values `outdir`/`outfile` are set to and it's usually required to use them unchanged.\n\nFailures have to cause a `BuildFailure` exception in order to be fully handled.\n\n#### Custom transform function\n\nConstructs that result in starting a transformation, take a `transformFn` as optional prop. While the defined type for this function is `any`, it must implement the same signature as esbuild's `transformSync` function.\n\n```ts\nnew InlineTypeScriptCode(\"let x: number = 1\", {\n transformFn: (options: TransformOptions): TransformResult => {\n try {\n // custom implementation returning TransformResult\n } catch (error) {\n // throw TransformFailure exception here\n }\n },,\n});\n```\n\nInstead of esbuild, the provided function will be invoked with the calculated transform options. The custom transform function can amend, change or discard any of these.\n\nFailures have to cause a `TransformFailure` exception in order to be fully handled.\n\n### Migrating to v3\n\nThe release of cdk-esbuild v3 brings compatibility with AWS CDK v2. Furthermore all deprecated properties and classes have been removed. In particular `InlineCode` classes now take `TransformerProps` as second parameter instead of transform options.\n\n#### Upgrading\n\n- This version requires AWS CDK v2. Follow the [official migration guide](https://docs.aws.amazon.com/cdk/latest/guide/work-with-cdk-v2.html) to upgrade.\n- Update the package dependency to v3: `npm install --save @mrgrain/cdk-esbuild@^3.0.0`\n- `esbuild` is installed as an optional dependency. If your setup does not automatically install optional dependencies, make sure to add it as an explicit dependency.\n- Any use of `InlineCode` variations has to be updated. Previously the second parameter was either of type `TransformerProps` or `TransformOptions`. Now it must be `TransformerProps`.\\\n If the passed value is of type `TransformOptions`, turn it into the correct type like this:\n\n ```ts\n const oldOptions: TransformOptions = {...}\n\n new InlineTypeScriptCode('// inline code', {\n transformOptions: oldOptions\n });\n ```\n\n## Versioning\n\nThis package follows [Semantic Versioning](https://semver.org/), with the exception of upgrades to `esbuild`. These will be released as **minor versions** and often include breaking changes from `esbuild`.\n\n### Npm Tags\n\nSome users prefer to use tags over version ranges. The following stable tags are available for use:\n\n- `cdk-v1`, `cdk-v2` are provided for the latest release compatible with each version of the AWS CDK.\n\n- `latest` is the most recent stable release.\n\nThese tags also exist, but usage is strongly not recommended:\n\n- `unstable`, `next` are used for pre-release of the current and next major version respectively.\n\n- ~~`cdk-1.x.x`~~ tags have been deprecated in favour of `cdk-v1`. Use that one instead.\n\n## Roadmap & Contributions\n\n[The project's roadmap is available on GitHub.](https://github.com/mrgrain/cdk-esbuild/projects/1) Please submit any feature requests as issues to the repository.\n\nAll contributions are welcome, no matter if they are for already planned or completely new features.\n\n## Library authors\n\nBuilding a library consumed by other packages that relies on `cdk-esbuild` might require you to set `buildOptions.absWorkingDir`. The easiest way to do this, is to resolve based on the directory name of the calling file, and traverse the tree upwards to the root of your library package (that's where `package.json` and `tsconfig.json` are):\n\n```ts\n// file: project/src/index.ts\nconst props = {\n buildOptions: {\n absWorkingDir: path.resolve(__dirname, \"..\"), // now: /user/project\n },\n};\n```\n\nThis will dynamically resolve to the correct path, wherever the package is installed.\n\nPlease open an issue if you encounter any difficulties.\n"
|
|
2804
2804
|
},
|
|
2805
2805
|
"repository": {
|
|
2806
2806
|
"type": "git",
|
|
@@ -3954,7 +3954,7 @@
|
|
|
3954
3954
|
"kind": "interface",
|
|
3955
3955
|
"locationInModule": {
|
|
3956
3956
|
"filename": "src/bundler.ts",
|
|
3957
|
-
"line":
|
|
3957
|
+
"line": 23
|
|
3958
3958
|
},
|
|
3959
3959
|
"name": "BundlerProps",
|
|
3960
3960
|
"properties": [
|
|
@@ -3974,7 +3974,7 @@
|
|
|
3974
3974
|
"immutable": true,
|
|
3975
3975
|
"locationInModule": {
|
|
3976
3976
|
"filename": "src/bundler.ts",
|
|
3977
|
-
"line":
|
|
3977
|
+
"line": 79
|
|
3978
3978
|
},
|
|
3979
3979
|
"name": "buildFn",
|
|
3980
3980
|
"optional": true,
|
|
@@ -3985,7 +3985,7 @@
|
|
|
3985
3985
|
{
|
|
3986
3986
|
"abstract": true,
|
|
3987
3987
|
"docs": {
|
|
3988
|
-
"remarks": "
|
|
3988
|
+
"remarks": "* `buildOptions.outdir: string`\nThe actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \\\nFor 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. \\\n*Cannot be used together with `outfile`*.\n* `buildOptions.outfile: string`\nRelative path to a file inside the CDK asset output directory.\nFor 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. \\\n*Cannot be used with multiple entryPoints or together with `outdir`.*\n* `buildOptions.absWorkingDir: string`\nAbsolute 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). \\\nIf 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).",
|
|
3989
3989
|
"see": "https://esbuild.github.io/api/#build-api",
|
|
3990
3990
|
"stability": "stable",
|
|
3991
3991
|
"summary": "Build options passed on to esbuild. Please refer to the esbuild Build API docs for details."
|
|
@@ -3993,7 +3993,7 @@
|
|
|
3993
3993
|
"immutable": true,
|
|
3994
3994
|
"locationInModule": {
|
|
3995
3995
|
"filename": "src/bundler.ts",
|
|
3996
|
-
"line":
|
|
3996
|
+
"line": 42
|
|
3997
3997
|
},
|
|
3998
3998
|
"name": "buildOptions",
|
|
3999
3999
|
"optional": true,
|
|
@@ -4004,19 +4004,55 @@
|
|
|
4004
4004
|
{
|
|
4005
4005
|
"abstract": true,
|
|
4006
4006
|
"docs": {
|
|
4007
|
-
"remarks": "
|
|
4007
|
+
"remarks": "* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.\n* 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.\n\nTherefore the following values for `copyDir` are all equivalent:\n```ts\n{ copyDir: \"path/to/source\" }\n{ copyDir: [\"path/to/source\"] }\n{ copyDir: { \".\": \"path/to/source\" } }\n{ copyDir: { \".\": [\"path/to/source\"] } }\n```\nThe destination cannot be outside of the asset staging directory.\nIf you are receiving the error \"Cannot copy files to outside of the asset staging directory.\"\nyou are likely using `..` or an absolute path as key on the `copyDir` map.\nInstead use only relative paths and avoid `..`.",
|
|
4008
4008
|
"stability": "stable",
|
|
4009
|
-
"summary": "Copy additional files to the
|
|
4009
|
+
"summary": "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."
|
|
4010
4010
|
},
|
|
4011
4011
|
"immutable": true,
|
|
4012
4012
|
"locationInModule": {
|
|
4013
4013
|
"filename": "src/bundler.ts",
|
|
4014
|
-
"line":
|
|
4014
|
+
"line": 65
|
|
4015
4015
|
},
|
|
4016
4016
|
"name": "copyDir",
|
|
4017
4017
|
"optional": true,
|
|
4018
4018
|
"type": {
|
|
4019
|
-
"
|
|
4019
|
+
"union": {
|
|
4020
|
+
"types": [
|
|
4021
|
+
{
|
|
4022
|
+
"primitive": "string"
|
|
4023
|
+
},
|
|
4024
|
+
{
|
|
4025
|
+
"collection": {
|
|
4026
|
+
"elementtype": {
|
|
4027
|
+
"primitive": "string"
|
|
4028
|
+
},
|
|
4029
|
+
"kind": "array"
|
|
4030
|
+
}
|
|
4031
|
+
},
|
|
4032
|
+
{
|
|
4033
|
+
"collection": {
|
|
4034
|
+
"elementtype": {
|
|
4035
|
+
"union": {
|
|
4036
|
+
"types": [
|
|
4037
|
+
{
|
|
4038
|
+
"primitive": "string"
|
|
4039
|
+
},
|
|
4040
|
+
{
|
|
4041
|
+
"collection": {
|
|
4042
|
+
"elementtype": {
|
|
4043
|
+
"primitive": "string"
|
|
4044
|
+
},
|
|
4045
|
+
"kind": "array"
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
]
|
|
4049
|
+
}
|
|
4050
|
+
},
|
|
4051
|
+
"kind": "map"
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
]
|
|
4055
|
+
}
|
|
4020
4056
|
}
|
|
4021
4057
|
}
|
|
4022
4058
|
],
|
|
@@ -4069,7 +4105,7 @@
|
|
|
4069
4105
|
},
|
|
4070
4106
|
"locationInModule": {
|
|
4071
4107
|
"filename": "src/bundler.ts",
|
|
4072
|
-
"line":
|
|
4108
|
+
"line": 106
|
|
4073
4109
|
},
|
|
4074
4110
|
"parameters": [
|
|
4075
4111
|
{
|
|
@@ -4120,7 +4156,7 @@
|
|
|
4120
4156
|
"kind": "class",
|
|
4121
4157
|
"locationInModule": {
|
|
4122
4158
|
"filename": "src/bundler.ts",
|
|
4123
|
-
"line":
|
|
4159
|
+
"line": 88
|
|
4124
4160
|
},
|
|
4125
4161
|
"name": "EsbuildBundler",
|
|
4126
4162
|
"properties": [
|
|
@@ -4133,7 +4169,7 @@
|
|
|
4133
4169
|
"immutable": true,
|
|
4134
4170
|
"locationInModule": {
|
|
4135
4171
|
"filename": "src/bundler.ts",
|
|
4136
|
-
"line":
|
|
4172
|
+
"line": 113
|
|
4137
4173
|
},
|
|
4138
4174
|
"name": "entryPoints",
|
|
4139
4175
|
"type": {
|
|
@@ -4170,7 +4206,7 @@
|
|
|
4170
4206
|
"immutable": true,
|
|
4171
4207
|
"locationInModule": {
|
|
4172
4208
|
"filename": "src/bundler.ts",
|
|
4173
|
-
"line":
|
|
4209
|
+
"line": 101
|
|
4174
4210
|
},
|
|
4175
4211
|
"name": "image",
|
|
4176
4212
|
"type": {
|
|
@@ -4185,7 +4221,7 @@
|
|
|
4185
4221
|
"immutable": true,
|
|
4186
4222
|
"locationInModule": {
|
|
4187
4223
|
"filename": "src/bundler.ts",
|
|
4188
|
-
"line":
|
|
4224
|
+
"line": 94
|
|
4189
4225
|
},
|
|
4190
4226
|
"name": "local",
|
|
4191
4227
|
"type": {
|
|
@@ -4200,7 +4236,7 @@
|
|
|
4200
4236
|
"immutable": true,
|
|
4201
4237
|
"locationInModule": {
|
|
4202
4238
|
"filename": "src/bundler.ts",
|
|
4203
|
-
"line":
|
|
4239
|
+
"line": 120
|
|
4204
4240
|
},
|
|
4205
4241
|
"name": "props",
|
|
4206
4242
|
"type": {
|
|
@@ -6056,6 +6092,6 @@
|
|
|
6056
6092
|
"symbolId": "src/source:TypeScriptSourceProps"
|
|
6057
6093
|
}
|
|
6058
6094
|
},
|
|
6059
|
-
"version": "3.
|
|
6060
|
-
"fingerprint": "
|
|
6095
|
+
"version": "3.4.0",
|
|
6096
|
+
"fingerprint": "KLIX/Vq9D/NBEka2gtCgAIO/3cBKSHQNOCxdNGupRg4="
|
|
6061
6097
|
}
|
package/.projenrc.ts
CHANGED
|
@@ -85,14 +85,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
|
|
|
85
85
|
|
|
86
86
|
// Dependencies
|
|
87
87
|
cdkVersion: '2.0.0',
|
|
88
|
-
peerDeps: [
|
|
89
|
-
'aws-cdk-lib@^2.0.0',
|
|
90
|
-
],
|
|
91
88
|
devDeps: [
|
|
92
|
-
'@aws-cdk/aws-synthetics-alpha',
|
|
89
|
+
'@aws-cdk/aws-synthetics-alpha@2.0.0-alpha.11',
|
|
93
90
|
'@types/eslint',
|
|
94
|
-
'aws-cdk-lib@2.0.0',
|
|
95
|
-
'constructs@10.0.5',
|
|
96
91
|
'esbuild@^0.14.0',
|
|
97
92
|
'jest-mock',
|
|
98
93
|
'ts-morph',
|
|
@@ -191,6 +186,7 @@ new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
|
|
|
191
186
|
esbuildTypes.getInterface('CommonOptions')?.getProperty('mangleProps')?.setType('any');
|
|
192
187
|
esbuildTypes.getInterface('CommonOptions')?.getProperty('reserveProps')?.setType('any');
|
|
193
188
|
esbuildTypes.getInterface('TransformOptions')?.getProperty('tsconfigRaw')?.setType('string');
|
|
189
|
+
esbuildTypes.getInterface('InitializeOptions')?.getProperty('wasmModule')?.setType('any');
|
|
194
190
|
},
|
|
195
191
|
});
|
|
196
192
|
|
package/API.md
CHANGED
|
@@ -39,15 +39,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
39
39
|
|
|
40
40
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
41
41
|
|
|
42
|
-
`buildOptions.outdir: string`
|
|
42
|
+
* `buildOptions.outdir: string`
|
|
43
43
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
44
44
|
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. \
|
|
45
45
|
*Cannot be used together with `outfile`*.
|
|
46
|
-
|
|
46
|
+
* `buildOptions.outfile: string`
|
|
47
47
|
Relative path to a file inside the CDK asset output directory.
|
|
48
48
|
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. \
|
|
49
49
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
50
|
-
|
|
50
|
+
* `buildOptions.absWorkingDir: string`
|
|
51
51
|
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). \
|
|
52
52
|
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).
|
|
53
53
|
|
|
@@ -58,14 +58,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
58
58
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.AssetProps.property.copyDir"></a>
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
|
-
public readonly copyDir: string;
|
|
61
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
- *Type:* `string`
|
|
64
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
65
|
+
|
|
66
|
+
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.
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
69
|
+
* 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.
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
72
|
+
```ts
|
|
73
|
+
{ copyDir: "path/to/source" }
|
|
74
|
+
{ copyDir: ["path/to/source"] }
|
|
75
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
76
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
77
|
+
```
|
|
78
|
+
The destination cannot be outside of the asset staging directory.
|
|
79
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
80
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
81
|
+
Instead use only relative paths and avoid `..`.
|
|
69
82
|
|
|
70
83
|
---
|
|
71
84
|
|
|
@@ -805,15 +818,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
805
818
|
|
|
806
819
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
807
820
|
|
|
808
|
-
`buildOptions.outdir: string`
|
|
821
|
+
* `buildOptions.outdir: string`
|
|
809
822
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
810
823
|
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. \
|
|
811
824
|
*Cannot be used together with `outfile`*.
|
|
812
|
-
|
|
825
|
+
* `buildOptions.outfile: string`
|
|
813
826
|
Relative path to a file inside the CDK asset output directory.
|
|
814
827
|
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. \
|
|
815
828
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
816
|
-
|
|
829
|
+
* `buildOptions.absWorkingDir: string`
|
|
817
830
|
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). \
|
|
818
831
|
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).
|
|
819
832
|
|
|
@@ -824,14 +837,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
824
837
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BundlerProps.property.copyDir"></a>
|
|
825
838
|
|
|
826
839
|
```typescript
|
|
827
|
-
public readonly copyDir: string;
|
|
840
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
828
841
|
```
|
|
829
842
|
|
|
830
|
-
- *Type:* `string`
|
|
843
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
831
844
|
|
|
832
|
-
Copy additional files to the
|
|
845
|
+
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.
|
|
833
846
|
|
|
834
|
-
|
|
847
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
848
|
+
* 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.
|
|
849
|
+
|
|
850
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
851
|
+
```ts
|
|
852
|
+
{ copyDir: "path/to/source" }
|
|
853
|
+
{ copyDir: ["path/to/source"] }
|
|
854
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
855
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
856
|
+
```
|
|
857
|
+
The destination cannot be outside of the asset staging directory.
|
|
858
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
859
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
860
|
+
Instead use only relative paths and avoid `..`.
|
|
835
861
|
|
|
836
862
|
---
|
|
837
863
|
|
|
@@ -893,15 +919,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
893
919
|
|
|
894
920
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
895
921
|
|
|
896
|
-
`buildOptions.outdir: string`
|
|
922
|
+
* `buildOptions.outdir: string`
|
|
897
923
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
898
924
|
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. \
|
|
899
925
|
*Cannot be used together with `outfile`*.
|
|
900
|
-
|
|
926
|
+
* `buildOptions.outfile: string`
|
|
901
927
|
Relative path to a file inside the CDK asset output directory.
|
|
902
928
|
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. \
|
|
903
929
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
904
|
-
|
|
930
|
+
* `buildOptions.absWorkingDir: string`
|
|
905
931
|
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). \
|
|
906
932
|
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).
|
|
907
933
|
|
|
@@ -912,14 +938,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
912
938
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptCodeProps.property.copyDir"></a>
|
|
913
939
|
|
|
914
940
|
```typescript
|
|
915
|
-
public readonly copyDir: string;
|
|
941
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
916
942
|
```
|
|
917
943
|
|
|
918
|
-
- *Type:* `string`
|
|
944
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
919
945
|
|
|
920
|
-
Copy additional files to the
|
|
946
|
+
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.
|
|
921
947
|
|
|
922
|
-
|
|
948
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
949
|
+
* 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.
|
|
950
|
+
|
|
951
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
952
|
+
```ts
|
|
953
|
+
{ copyDir: "path/to/source" }
|
|
954
|
+
{ copyDir: ["path/to/source"] }
|
|
955
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
956
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
957
|
+
```
|
|
958
|
+
The destination cannot be outside of the asset staging directory.
|
|
959
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
960
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
961
|
+
Instead use only relative paths and avoid `..`.
|
|
923
962
|
|
|
924
963
|
---
|
|
925
964
|
|
|
@@ -975,15 +1014,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
975
1014
|
|
|
976
1015
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
977
1016
|
|
|
978
|
-
`buildOptions.outdir: string`
|
|
1017
|
+
* `buildOptions.outdir: string`
|
|
979
1018
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
980
1019
|
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. \
|
|
981
1020
|
*Cannot be used together with `outfile`*.
|
|
982
|
-
|
|
1021
|
+
* `buildOptions.outfile: string`
|
|
983
1022
|
Relative path to a file inside the CDK asset output directory.
|
|
984
1023
|
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. \
|
|
985
1024
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
986
|
-
|
|
1025
|
+
* `buildOptions.absWorkingDir: string`
|
|
987
1026
|
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). \
|
|
988
1027
|
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).
|
|
989
1028
|
|
|
@@ -994,14 +1033,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
994
1033
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptSourceProps.property.copyDir"></a>
|
|
995
1034
|
|
|
996
1035
|
```typescript
|
|
997
|
-
public readonly copyDir: string;
|
|
1036
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
998
1037
|
```
|
|
999
1038
|
|
|
1000
|
-
- *Type:* `string`
|
|
1039
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
1040
|
+
|
|
1041
|
+
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.
|
|
1001
1042
|
|
|
1002
|
-
|
|
1043
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
1044
|
+
* 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.
|
|
1003
1045
|
|
|
1004
|
-
|
|
1046
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
1047
|
+
```ts
|
|
1048
|
+
{ copyDir: "path/to/source" }
|
|
1049
|
+
{ copyDir: ["path/to/source"] }
|
|
1050
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
1051
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
1052
|
+
```
|
|
1053
|
+
The destination cannot be outside of the asset staging directory.
|
|
1054
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
1055
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
1056
|
+
Instead use only relative paths and avoid `..`.
|
|
1005
1057
|
|
|
1006
1058
|
---
|
|
1007
1059
|
|
|
@@ -1495,15 +1547,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
1495
1547
|
|
|
1496
1548
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
1497
1549
|
|
|
1498
|
-
`buildOptions.outdir: string`
|
|
1550
|
+
* `buildOptions.outdir: string`
|
|
1499
1551
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
1500
1552
|
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. \
|
|
1501
1553
|
*Cannot be used together with `outfile`*.
|
|
1502
|
-
|
|
1554
|
+
* `buildOptions.outfile: string`
|
|
1503
1555
|
Relative path to a file inside the CDK asset output directory.
|
|
1504
1556
|
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. \
|
|
1505
1557
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
1506
|
-
|
|
1558
|
+
* `buildOptions.absWorkingDir: string`
|
|
1507
1559
|
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). \
|
|
1508
1560
|
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).
|
|
1509
1561
|
|
|
@@ -1514,14 +1566,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
1514
1566
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptCodeProps.property.copyDir"></a>
|
|
1515
1567
|
|
|
1516
1568
|
```typescript
|
|
1517
|
-
public readonly copyDir: string;
|
|
1569
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
1518
1570
|
```
|
|
1519
1571
|
|
|
1520
|
-
- *Type:* `string`
|
|
1572
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
1521
1573
|
|
|
1522
|
-
Copy additional files to the
|
|
1574
|
+
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.
|
|
1523
1575
|
|
|
1524
|
-
|
|
1576
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
1577
|
+
* 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.
|
|
1578
|
+
|
|
1579
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
1580
|
+
```ts
|
|
1581
|
+
{ copyDir: "path/to/source" }
|
|
1582
|
+
{ copyDir: ["path/to/source"] }
|
|
1583
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
1584
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
1585
|
+
```
|
|
1586
|
+
The destination cannot be outside of the asset staging directory.
|
|
1587
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
1588
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
1589
|
+
Instead use only relative paths and avoid `..`.
|
|
1525
1590
|
|
|
1526
1591
|
---
|
|
1527
1592
|
|
|
@@ -1577,15 +1642,15 @@ public readonly buildOptions: BuildOptions;
|
|
|
1577
1642
|
|
|
1578
1643
|
Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
1579
1644
|
|
|
1580
|
-
`buildOptions.outdir: string`
|
|
1645
|
+
* `buildOptions.outdir: string`
|
|
1581
1646
|
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
1582
1647
|
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. \
|
|
1583
1648
|
*Cannot be used together with `outfile`*.
|
|
1584
|
-
|
|
1649
|
+
* `buildOptions.outfile: string`
|
|
1585
1650
|
Relative path to a file inside the CDK asset output directory.
|
|
1586
1651
|
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. \
|
|
1587
1652
|
*Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
1588
|
-
|
|
1653
|
+
* `buildOptions.absWorkingDir: string`
|
|
1589
1654
|
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). \
|
|
1590
1655
|
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).
|
|
1591
1656
|
|
|
@@ -1596,14 +1661,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
|
|
|
1596
1661
|
##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptSourceProps.property.copyDir"></a>
|
|
1597
1662
|
|
|
1598
1663
|
```typescript
|
|
1599
|
-
public readonly copyDir: string;
|
|
1664
|
+
public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
|
|
1600
1665
|
```
|
|
1601
1666
|
|
|
1602
|
-
- *Type:* `string`
|
|
1667
|
+
- *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
|
|
1603
1668
|
|
|
1604
|
-
Copy additional files to the
|
|
1669
|
+
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.
|
|
1605
1670
|
|
|
1606
|
-
|
|
1671
|
+
* When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
|
|
1672
|
+
* 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.
|
|
1673
|
+
|
|
1674
|
+
Therefore the following values for `copyDir` are all equivalent:
|
|
1675
|
+
```ts
|
|
1676
|
+
{ copyDir: "path/to/source" }
|
|
1677
|
+
{ copyDir: ["path/to/source"] }
|
|
1678
|
+
{ copyDir: { ".": "path/to/source" } }
|
|
1679
|
+
{ copyDir: { ".": ["path/to/source"] } }
|
|
1680
|
+
```
|
|
1681
|
+
The destination cannot be outside of the asset staging directory.
|
|
1682
|
+
If you are receiving the error "Cannot copy files to outside of the asset staging directory."
|
|
1683
|
+
you are likely using `..` or an absolute path as key on the `copyDir` map.
|
|
1684
|
+
Instead use only relative paths and avoid `..`.
|
|
1607
1685
|
|
|
1608
1686
|
---
|
|
1609
1687
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
## [3.
|
|
2
|
+
## [3.4.0](https://github.com/mrgrain/cdk-esbuild/compare/v3.3.0...v3.4.0) (2022-05-26)
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
### Features
|
|
6
6
|
|
|
7
|
-
*
|
|
7
|
+
* copyDir supports more complex scenarios ([08c59fb](https://github.com/mrgrain/cdk-esbuild/commit/08c59fba7bf1ee68ca103520b3e0b7ea5359a925))
|