@mrgrain/cdk-esbuild 2.0.0-alpha.0 → 2.0.0-alpha.5
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 +1 -1
- package/.jsii +560 -504
- package/{.projenrc.mjs → .projenrc.ts} +38 -31
- package/API.md +432 -698
- package/CHANGELOG.md +261 -0
- package/README.md +51 -172
- package/SECURITY.md +5 -5
- package/lib/asset.d.ts +29 -28
- package/lib/asset.js +23 -13
- package/lib/bundler.d.ts +92 -0
- package/lib/bundler.js +85 -0
- package/lib/code.d.ts +75 -28
- package/lib/code.js +61 -7
- package/lib/esbuild-types.js +2 -1
- package/lib/index.d.ts +5 -6
- package/lib/index.js +3 -5
- package/lib/inline-code.d.ts +88 -4
- package/lib/inline-code.js +93 -9
- package/lib/source.d.ts +18 -9
- package/lib/source.js +5 -3
- package/package.json +4 -1
- package/projenrc/TypeScriptSourceFile.ts +50 -0
- package/esbuild/Dockerfile +0 -13
- package/esbuild/esbuild-js +0 -22
- package/lib/bundlers.d.ts +0 -42
- package/lib/bundlers.js +0 -62
- package/lib/bundling.d.ts +0 -20
- package/lib/bundling.js +0 -30
- package/lib/esbuild-types-raw.d.ts +0 -304
- package/lib/esbuild-types-raw.js +0 -4
package/lib/asset.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import { Asset as S3Asset } from '@aws-cdk/aws-s3-assets';
|
|
2
2
|
import { Construct } from '@aws-cdk/core';
|
|
3
|
-
import {
|
|
3
|
+
import { BundlerProps, EntryPoints } from './bundler';
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
/**
|
|
9
|
-
* Relative path to a directory copied to the output BEFORE esbuild is run (i.e esbuild will overwrite existing files).
|
|
10
|
-
*
|
|
11
|
-
* @stability stable
|
|
12
|
-
*/
|
|
13
|
-
readonly copyDir?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Options passed on to esbuild.
|
|
16
|
-
*
|
|
17
|
-
* @stability stable
|
|
18
|
-
*/
|
|
19
|
-
readonly buildOptions?: BuildOptions;
|
|
7
|
+
export interface AssetBaseProps extends BundlerProps {
|
|
20
8
|
/**
|
|
21
9
|
* A hash of this asset, which is available at construction time.
|
|
22
10
|
*
|
|
23
|
-
* As this is a plain string, it
|
|
24
|
-
*
|
|
25
|
-
* hash
|
|
11
|
+
* 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.
|
|
12
|
+
*
|
|
13
|
+
* Defaults to a hash of all files in the resulting bundle.
|
|
26
14
|
*
|
|
27
15
|
* @stability stable
|
|
28
16
|
*/
|
|
@@ -31,29 +19,42 @@ export interface EsbuildProps {
|
|
|
31
19
|
/**
|
|
32
20
|
* @stability stable
|
|
33
21
|
*/
|
|
34
|
-
export interface
|
|
22
|
+
export interface AssetProps extends AssetBaseProps {
|
|
35
23
|
/**
|
|
36
|
-
*
|
|
24
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
25
|
+
*
|
|
26
|
+
* E.g. `src/index.ts`.
|
|
37
27
|
*
|
|
38
28
|
* @stability stable
|
|
39
29
|
*/
|
|
40
|
-
readonly entryPoints:
|
|
30
|
+
readonly entryPoints: EntryPoints;
|
|
41
31
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
declare type JavaScriptAssetProps = AssetProps;
|
|
33
|
+
declare type TypeScriptAssetProps = AssetProps;
|
|
34
|
+
/**
|
|
35
|
+
* @stability stable
|
|
36
|
+
*/
|
|
37
|
+
declare abstract class Asset<Props extends AssetProps> extends S3Asset {
|
|
45
38
|
/**
|
|
46
|
-
* @
|
|
39
|
+
* @stability stable
|
|
47
40
|
*/
|
|
48
|
-
constructor(scope: Construct, id: string,
|
|
41
|
+
constructor(scope: Construct, id: string, props: Props);
|
|
49
42
|
}
|
|
50
43
|
/**
|
|
51
|
-
*
|
|
44
|
+
* Bundles the entry points and creates a CDK asset which is uploaded to the bootstrapped CDK S3 bucket during deployment.
|
|
45
|
+
*
|
|
46
|
+
* The asset can be used by other constructs.
|
|
47
|
+
*
|
|
48
|
+
* @stability stable
|
|
52
49
|
*/
|
|
53
50
|
export declare class JavaScriptAsset extends Asset<JavaScriptAssetProps> {
|
|
54
51
|
}
|
|
55
52
|
/**
|
|
56
|
-
*
|
|
53
|
+
* Bundles the entry points and creates a CDK asset which is uploaded to the bootstrapped CDK S3 bucket during deployment.
|
|
54
|
+
*
|
|
55
|
+
* The asset can be used by other constructs.
|
|
56
|
+
*
|
|
57
|
+
* @stability stable
|
|
57
58
|
*/
|
|
58
59
|
export declare class TypeScriptAsset extends Asset<TypeScriptAssetProps> {
|
|
59
60
|
}
|
package/lib/asset.js
CHANGED
|
@@ -6,14 +6,18 @@ const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const aws_s3_assets_1 = require("@aws-cdk/aws-s3-assets");
|
|
8
8
|
const core_1 = require("@aws-cdk/core");
|
|
9
|
-
const
|
|
9
|
+
const bundler_1 = require("./bundler");
|
|
10
|
+
/**
|
|
11
|
+
* @stability stable
|
|
12
|
+
*/
|
|
10
13
|
class Asset extends aws_s3_assets_1.Asset {
|
|
11
14
|
/**
|
|
12
|
-
* @
|
|
15
|
+
* @stability stable
|
|
13
16
|
*/
|
|
14
|
-
constructor(scope, id,
|
|
17
|
+
constructor(scope, id, props) {
|
|
15
18
|
var _c;
|
|
16
|
-
const
|
|
19
|
+
const { assetHash, copyDir, buildOptions: options = {}, } = props;
|
|
20
|
+
const entryPoints = typeof props.entryPoints === 'string' ? [props.entryPoints] : props.entryPoints;
|
|
17
21
|
const name = scope.node.path + core_1.ConstructNode.PATH_SEP + id;
|
|
18
22
|
Object.values(entryPoints).forEach((entryPoint) => {
|
|
19
23
|
if (path_1.isAbsolute(entryPoint)) {
|
|
@@ -30,29 +34,35 @@ class Asset extends aws_s3_assets_1.Asset {
|
|
|
30
34
|
path: absWorkingDir,
|
|
31
35
|
assetHash,
|
|
32
36
|
assetHashType: assetHash ? core_1.AssetHashType.CUSTOM : core_1.AssetHashType.OUTPUT,
|
|
33
|
-
bundling: new
|
|
34
|
-
|
|
35
|
-
entryPoints,
|
|
36
|
-
}, {
|
|
37
|
+
bundling: new bundler_1.EsbuildBundler(entryPoints, {
|
|
38
|
+
buildOptions,
|
|
37
39
|
copyDir,
|
|
38
40
|
}),
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
|
-
*
|
|
45
|
+
* Bundles the entry points and creates a CDK asset which is uploaded to the bootstrapped CDK S3 bucket during deployment.
|
|
46
|
+
*
|
|
47
|
+
* The asset can be used by other constructs.
|
|
48
|
+
*
|
|
49
|
+
* @stability stable
|
|
44
50
|
*/
|
|
45
51
|
class JavaScriptAsset extends Asset {
|
|
46
52
|
}
|
|
47
53
|
exports.JavaScriptAsset = JavaScriptAsset;
|
|
48
54
|
_a = JSII_RTTI_SYMBOL_1;
|
|
49
|
-
JavaScriptAsset[_a] = { fqn: "@mrgrain/cdk-esbuild.JavaScriptAsset", version: "2.0.0-alpha.
|
|
55
|
+
JavaScriptAsset[_a] = { fqn: "@mrgrain/cdk-esbuild.JavaScriptAsset", version: "2.0.0-alpha.5" };
|
|
50
56
|
/**
|
|
51
|
-
*
|
|
57
|
+
* Bundles the entry points and creates a CDK asset which is uploaded to the bootstrapped CDK S3 bucket during deployment.
|
|
58
|
+
*
|
|
59
|
+
* The asset can be used by other constructs.
|
|
60
|
+
*
|
|
61
|
+
* @stability stable
|
|
52
62
|
*/
|
|
53
63
|
class TypeScriptAsset extends Asset {
|
|
54
64
|
}
|
|
55
65
|
exports.TypeScriptAsset = TypeScriptAsset;
|
|
56
66
|
_b = JSII_RTTI_SYMBOL_1;
|
|
57
|
-
TypeScriptAsset[_b] = { fqn: "@mrgrain/cdk-esbuild.TypeScriptAsset", version: "2.0.0-alpha.
|
|
58
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
67
|
+
TypeScriptAsset[_b] = { fqn: "@mrgrain/cdk-esbuild.TypeScriptAsset", version: "2.0.0-alpha.5" };
|
|
68
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvYXNzZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSwrQkFBa0M7QUFDbEMsMERBQTBEO0FBQzFELHdDQUF3RTtBQUN4RSx1Q0FBc0U7QUFrQnRFOztHQUVHO0FBQ0gsTUFBZSxLQUFnQyxTQUFRLHFCQUFPOzs7O0lBRTVELFlBQ0UsS0FBZ0IsRUFDaEIsRUFBVSxFQUNWLEtBQVk7O1FBRVosTUFBTSxFQUNKLFNBQVMsRUFDVCxPQUFPLEVBQ1AsWUFBWSxFQUFFLE9BQU8sR0FBRyxFQUFFLEdBQzNCLEdBQUcsS0FBSyxDQUFDO1FBQ1YsTUFBTSxXQUFXLEdBQ2YsT0FBTyxLQUFLLENBQUMsV0FBVyxLQUFLLFFBQVEsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUM7UUFFbEYsTUFBTSxJQUFJLEdBQUcsS0FBSyxDQUFDLElBQUksQ0FBQyxJQUFJLEdBQUcsb0JBQWEsQ0FBQyxRQUFRLEdBQUcsRUFBRSxDQUFDO1FBRTNELE1BQU0sQ0FBQyxNQUFNLENBQUMsV0FBVyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsVUFBa0IsRUFBRSxFQUFFO1lBQ3hELElBQUksaUJBQVUsQ0FBQyxVQUFVLENBQUMsRUFBRTtnQkFDMUIsTUFBTSxJQUFJLEtBQUssQ0FDYixHQUFH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vaW50cyB9IGZyb20gJy4vYnVuZGxlcic7XG5cbi8qKlxuICogQGludGVybmFsXG4gKi9cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXRCYXNlUHJvcHMgZXh0ZW5kcyBCdW5kbGVyUHJvcHMge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICByZWFkb25seSBhc3NldEhhc2g/OiBzdHJpbmc7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXRQcm9wcyBleHRlbmRzIEFzc2V0QmFzZVByb3BzIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICByZWFkb25seSBlbnRyeVBvaW50czogRW50cnlQb2ludHM7XG59XG5cbnR5cGUgSmF2YVNjcmlwdEFzc2V0UHJvcHMgPSBBc3NldFByb3BzO1xudHlwZSBUeXBlU2NyaXB0QXNzZXRQcm9wcyA9IEFzc2V0UHJvcHM7XG5cbi8qKlxuICogQHN0YWJpbGl0eSBzdGFibGVcbiAqL1xuYWJzdHJhY3QgY2xhc3MgQXNzZXQ8UHJvcHMgZXh0ZW5kcyBBc3NldFByb3BzPiBleHRlbm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jd2QoKTtcblxuICAgIGNvbnN0IGJ1aWxkT3B0aW9ucyA9IHtcbiAgICAgIGJ1bmRsZTogdHJ1ZSxcbiAgICAgIC4uLm9wdGlvbnMsXG4gICAgICBhYnNXb3JraW5nRGlyLFxuICAgIH07XG5cbiAgICBzdXBlcihzY29wZSwgaWQsIHtcbiAgICAgIHBhdGg6IGFic1dvcmtpbmdEaXIsXG4gICAgICBhc3NldEhhc2gsXG4gICAgICBhc3NldEhhc2hUeXBlOiBhc3NldEhhc2ggPyBBc3NldEhhc2hUeXBlLkNVU1RPTSA6IEFzc2V0SGFzaFR5cGUuT1VUUFVULFxuICAgICAgYnVuZGxpbmc6IG5ldyBFc2J1aWxkQnVuZGxlcihcbiAgICAgICAgZW50cnlQb2ludHMsXG4gICAgICAgIHtcbiAgICAgICAgICBidWlsZE9wdGlvbnMsXG4gICAgICAgICAgY29weURpcixcbiAgICAgICAgfSxcbiAgICAgICksXG4gICAgfSk7XG4gIH1cbn1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbmV4cG9ydCBjbGFzcyBKYXZhU2NyaXB0QXNzZXQgZXh0ZW5kcyBBc3NldDxKYXZhU2NyaXB0QXNzZXRQcm9wcz4ge31cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbmV4cG9ydCBjbGFzcyBUeXBlU2NyaXB0QXNzZXQgZXh0ZW5kcyBBc3NldDxUeXBlU2NyaXB0QXNzZXRQcm9wcz4ge31cbiJdfQ==
|
package/lib/bundler.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { DockerImage, ILocalBundling } from '@aws-cdk/core';
|
|
2
|
+
import { BuildOptions } from './esbuild-types';
|
|
3
|
+
/**
|
|
4
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project. E.g. `src/index.ts`.
|
|
5
|
+
*
|
|
6
|
+
* @stability stable
|
|
7
|
+
*/
|
|
8
|
+
export declare type EntryPoints = string | string[] | Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* @stability stable
|
|
11
|
+
*/
|
|
12
|
+
export interface BundlerProps {
|
|
13
|
+
/**
|
|
14
|
+
* Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
|
|
15
|
+
*
|
|
16
|
+
* - `buildOptions.outdir: string` \
|
|
17
|
+
* The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
18
|
+
* 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. \
|
|
19
|
+
* *Cannot be used together with `outfile`*.
|
|
20
|
+
* - `buildOptions.outfile: string` \
|
|
21
|
+
* Relative path to a file inside the CDK asset output directory. \
|
|
22
|
+
* 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. \
|
|
23
|
+
* *Cannot be used with multiple entryPoints or together with `outdir`.*
|
|
24
|
+
* - `buildOptions.absWorkingDir: string` \
|
|
25
|
+
* 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). \
|
|
26
|
+
* 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).
|
|
27
|
+
*
|
|
28
|
+
* @see https://esbuild.github.io/api/#build-api
|
|
29
|
+
* @stability stable
|
|
30
|
+
*/
|
|
31
|
+
readonly buildOptions?: BuildOptions;
|
|
32
|
+
/**
|
|
33
|
+
* Copy additional files to the output directory, before the build runs.
|
|
34
|
+
*
|
|
35
|
+
* Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
|
|
36
|
+
*
|
|
37
|
+
* @stability stable
|
|
38
|
+
*/
|
|
39
|
+
readonly copyDir?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* (experimental) Low-level construct that can be used where `BundlingOptions` are required.
|
|
43
|
+
*
|
|
44
|
+
* This class directly interfaces with esbuild and provides almost no configuration safeguards.
|
|
45
|
+
*
|
|
46
|
+
* @experimental
|
|
47
|
+
*/
|
|
48
|
+
export declare class EsbuildBundler {
|
|
49
|
+
/**
|
|
50
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
51
|
+
* E.g. `src/index.ts`.
|
|
52
|
+
*
|
|
53
|
+
* @stability experimental
|
|
54
|
+
*/
|
|
55
|
+
readonly entryPoints: EntryPoints;
|
|
56
|
+
/**
|
|
57
|
+
* Props to change the behaviour of the bundler.
|
|
58
|
+
*
|
|
59
|
+
* @stability experimental
|
|
60
|
+
*/
|
|
61
|
+
readonly props: BundlerProps;
|
|
62
|
+
/**
|
|
63
|
+
* (experimental) Implementation of `ILocalBundling` interface, responsible for calling esbuild functions.
|
|
64
|
+
*
|
|
65
|
+
* @experimental
|
|
66
|
+
*/
|
|
67
|
+
readonly local: ILocalBundling;
|
|
68
|
+
/**
|
|
69
|
+
* @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.
|
|
70
|
+
*/
|
|
71
|
+
readonly image: DockerImage;
|
|
72
|
+
/**
|
|
73
|
+
* @param entryPoints A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
74
|
+
* @param props Props to change the behaviour of the bundler.
|
|
75
|
+
* @experimental
|
|
76
|
+
*/
|
|
77
|
+
constructor(
|
|
78
|
+
/**
|
|
79
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
80
|
+
* E.g. `src/index.ts`.
|
|
81
|
+
*
|
|
82
|
+
* @stability experimental
|
|
83
|
+
*/
|
|
84
|
+
entryPoints: EntryPoints,
|
|
85
|
+
/**
|
|
86
|
+
* Props to change the behaviour of the bundler.
|
|
87
|
+
*
|
|
88
|
+
* @stability experimental
|
|
89
|
+
*/
|
|
90
|
+
props: BundlerProps);
|
|
91
|
+
private getOutputOptions;
|
|
92
|
+
}
|
package/lib/bundler.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.EsbuildBundler = void 0;
|
|
5
|
+
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const core_1 = require("@aws-cdk/core");
|
|
8
|
+
const esbuild_wrapper_1 = require("./esbuild-wrapper");
|
|
9
|
+
const formatMessages_1 = require("./formatMessages");
|
|
10
|
+
/**
|
|
11
|
+
* (experimental) Low-level construct that can be used where `BundlingOptions` are required.
|
|
12
|
+
*
|
|
13
|
+
* This class directly interfaces with esbuild and provides almost no configuration safeguards.
|
|
14
|
+
*
|
|
15
|
+
* @experimental
|
|
16
|
+
*/
|
|
17
|
+
class EsbuildBundler {
|
|
18
|
+
/**
|
|
19
|
+
* @param entryPoints A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
20
|
+
* @param props Props to change the behaviour of the bundler.
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
23
|
+
constructor(
|
|
24
|
+
/**
|
|
25
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
26
|
+
* E.g. `src/index.ts`.
|
|
27
|
+
*
|
|
28
|
+
* @stability experimental
|
|
29
|
+
*/
|
|
30
|
+
entryPoints,
|
|
31
|
+
/**
|
|
32
|
+
* Props to change the behaviour of the bundler.
|
|
33
|
+
*
|
|
34
|
+
* @stability experimental
|
|
35
|
+
*/
|
|
36
|
+
props) {
|
|
37
|
+
var _b, _c;
|
|
38
|
+
this.entryPoints = entryPoints;
|
|
39
|
+
this.props = props;
|
|
40
|
+
/**
|
|
41
|
+
* @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.
|
|
42
|
+
*/
|
|
43
|
+
this.image = core_1.DockerImage.fromRegistry('scratch');
|
|
44
|
+
if (((_b = props === null || props === void 0 ? void 0 : props.buildOptions) === null || _b === void 0 ? void 0 : _b.outfile) && ((_c = props === null || props === void 0 ? void 0 : props.buildOptions) === null || _c === void 0 ? void 0 : _c.outdir)) {
|
|
45
|
+
throw new Error('Cannot use both "outfile" and "outdir"');
|
|
46
|
+
}
|
|
47
|
+
this.local = {
|
|
48
|
+
tryBundle: (outputDir, _options) => {
|
|
49
|
+
var _b, _c, _d, _e;
|
|
50
|
+
try {
|
|
51
|
+
if (this.props.copyDir) {
|
|
52
|
+
core_1.FileSystem.copyDirectory(path_1.resolve((_d = (_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.buildOptions) === null || _c === void 0 ? void 0 : _c.absWorkingDir) !== null && _d !== void 0 ? _d : process.cwd(), this.props.copyDir), outputDir);
|
|
53
|
+
}
|
|
54
|
+
const buildResult = esbuild_wrapper_1.buildSync({
|
|
55
|
+
entryPoints,
|
|
56
|
+
...(((_e = this.props) === null || _e === void 0 ? void 0 : _e.buildOptions) || {}),
|
|
57
|
+
...this.getOutputOptions(outputDir, { normalize: path_1.normalize, join: path_1.join }),
|
|
58
|
+
});
|
|
59
|
+
formatMessages_1.printBuildMessages(buildResult, { prefix: 'Build ' });
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
formatMessages_1.printBuildMessages(error, { prefix: 'Build ' });
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
getOutputOptions(cdkOutputDir, path = path_1.posix) {
|
|
69
|
+
var _b, _c, _d, _e, _f, _g;
|
|
70
|
+
if ((_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.buildOptions) === null || _c === void 0 ? void 0 : _c.outfile) {
|
|
71
|
+
return {
|
|
72
|
+
outdir: undefined,
|
|
73
|
+
outfile: path.normalize(path.join(...[cdkOutputDir, (_e = (_d = this.props) === null || _d === void 0 ? void 0 : _d.buildOptions) === null || _e === void 0 ? void 0 : _e.outfile].filter(Boolean))),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
outdir: path.normalize(path.join(...[cdkOutputDir, (_g = (_f = this.props) === null || _f === void 0 ? void 0 : _f.buildOptions) === null || _g === void 0 ? void 0 : _g.outdir].filter(Boolean))),
|
|
78
|
+
outfile: undefined,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.EsbuildBundler = EsbuildBundler;
|
|
83
|
+
_a = JSII_RTTI_SYMBOL_1;
|
|
84
|
+
EsbuildBundler[_a] = { fqn: "@mrgrain/cdk-esbuild.EsbuildBundler", version: "2.0.0-alpha.5" };
|
|
85
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9idW5kbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsK0JBQXFFO0FBQ3JFLHdDQUt1QjtBQUV2Qix1REFBOEM7QUFDOUMscURBQXNEOzs7Ozs7OztBQW1CdEQsTUFBYSxjQUFjOzs7Ozs7SUFRekI7SUFDRTs7Ozs7T0FLRztJQ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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gIHJlYWRvbmx5IGJ1aWxkT3B0aW9ucz86IEJ1aWxkT3B0aW9ucztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgcmVhZG9ubHkgY29weURpcj86IHN0cmluZztcbn1cblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuZXhwb3J0IGNsYXNzIEVzYnVpbGRCdW5kbGVyIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgcHVibGljIHJlYWRvbmx5IGxvY2FsOiBJTG9jYWxCdW5kbGluZztcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gIHB1YmxpYyByZWFkb25seSBpbWFnZSA9IERvY2tlckltYWdlLmZyb21SZWdpc3RyeSgnc2NyYXRjaCcpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gIHB1YmxpYyBjb25zdHJ1Y3RvcihcbiAgICAvKipcbiAgICAgKiBBIHJlbGF0aXZlIHBhdGggb3IgbGlzdCBvciBtYXAgb2YgcmVsYXRpdmUgcGF0aHMgdG8gdGhlIGVudHJ5IHBvaW50cyBvZiB5b3VyIGNvZGUgZnJvbSB0aGUgcm9vdCBvZiB0aGUgcHJvamVjdC5cbiAgICAgKiBFLmcuIGBzcmMvaW5kZXgudHNgLlxuICAgICAqXG4gICAgICogQHN0YWJpbGl0eSBleHBlcmltZW50YWxcbiAgICAgKi9cbiAgICBwdWJsaWMgcmVhZG9ubHkgZW50cnlQb2ludHM6IEVudHJ5UG9pbnRzLFxuXG4gICAgLyoqXG4gICAgICogUHJvcHMgdG8gY2hhbmdlIHRoZSBiZWhhdmlvdXIgb2YgdGhlIGJ1bmRsZXIuXG4gICAgICpcbiAgICAgKiBAc3RhYmlsaXR5IGV4cGVyaW1lbnRhbFxuICAgICAqL1xuICAgIHB1YmxpYyByZWFkb25seSBwcm9wczogQnVuZGxlclByb3BzLFxuICApIHtcbiAgICBpZiAocHJvcHM/LmJ1aWxkT3B0aW9ucz8ub3V0ZmlsZSAmJiBwcm9wcz8uYnVpbGRPcHRpb25zPy5vdXRkaXIpIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcignQ2Fubm90IHVzZSBib3RoIFwib3V0ZmlsZVwiIGFuZCBcIm91dGRpclwiJyk7XG4gICAgfVxuXG4gICAgdGhpcy5sb2NhbCA9IHtcbiAgICAgIHRyeUJ1bmRsZTogKG91dHB1dERpcjogc3RyaW5nLCBfb3B0aW9uczogQnVuZGxpbmdPcHRpb25zKTogYm9vbGVhbiA9PiB7XG4gICAgICAgIHRyeSB7XG4gICAgICAgICAgaWYgKHRoaXMucHJvcHMuY29weURpcikge1xuICAgICAgICAgICAgRmlsZVN5c3RlbS5jb3B5RGlyZWN0b3J5KFxuICAgICAgICAgICAgICByZXNvbHZlKFxuICAgICAgICAgICAgICAgIHRoaXMucHJvcHM/LmJ1aWxkT3B0aW9ucz8uYWJzV29ya2luZ0RpciA/PyBwcm9jZXNzLmN3ZCgpLFxuICAgICAgICAgICAgICAgIHRoaXMucHJvcHMuY29weURpcixcbiAgICAgICAgICAgICAgKSxcbiAgICAgICAgICAgICAgb3V0cHV0RGlyLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBjb25zdCBidWlsZFJlc3VsdDogQnVpbGRSZXN1bHQgPSBidWlsZFN5bmMoe1xuICAgICAgICAgICAgZW50cnlQb2ludHMsXG4gICAgICAgICAgICAuLi4odGhpcy5wcm9wcz8uYnVpbGRPcHRpb25zIHx8IHt9KSxcbiAgICAgICAgICAgIC4uLnRoaXMuZ2V0T3V0cHV0T3B0aW9ucyhvdXRwdXREaXIsIHsgbm9ybWFsaXplLCBqb2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uZmlsdGVyKFxuICAgICAgICAgICAgQm9vbGVhbixcbiAgICAgICAgICApIGFzIHN0cmluZ1tdKSxcbiAgICAgICAgKSxcbiAgICAgICksXG4gICAgICBvdXRmaWxlOiB1bmRlZmluZWQsXG4gICAgfTtcbiAgfVxufVxuIl19
|
package/lib/code.d.ts
CHANGED
|
@@ -1,87 +1,134 @@
|
|
|
1
1
|
import { ResourceBindOptions } from '@aws-cdk/aws-lambda';
|
|
2
|
+
import { Location } from '@aws-cdk/aws-s3';
|
|
2
3
|
import { CfnResource, Construct } from '@aws-cdk/core';
|
|
3
|
-
import {
|
|
4
|
+
import { AssetBaseProps, AssetProps, JavaScriptAsset as JSAsset, TypeScriptAsset as TSAsset } from './asset';
|
|
5
|
+
import { EntryPoints } from './bundler';
|
|
4
6
|
/**
|
|
5
7
|
* @stability stable
|
|
6
8
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
/**
|
|
9
|
-
* @stability stable
|
|
10
|
-
*/
|
|
11
|
-
readonly bucketName: string;
|
|
9
|
+
export interface CodeConfig {
|
|
12
10
|
/**
|
|
11
|
+
* The location of the code in S3.
|
|
12
|
+
*
|
|
13
13
|
* @stability stable
|
|
14
14
|
*/
|
|
15
|
-
readonly
|
|
15
|
+
readonly s3Location: Location;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* @stability stable
|
|
19
19
|
*/
|
|
20
|
-
export interface
|
|
21
|
-
/**
|
|
22
|
-
* @stability stable
|
|
23
|
-
*/
|
|
24
|
-
readonly s3Location?: Location;
|
|
25
|
-
/**
|
|
26
|
-
* @stability stable
|
|
27
|
-
*/
|
|
28
|
-
readonly inlineCode?: string;
|
|
20
|
+
export interface JavaScriptCodeProps extends AssetBaseProps {
|
|
29
21
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @stability stable
|
|
24
|
+
*/
|
|
25
|
+
export interface TypeScriptCodeProps extends AssetBaseProps {
|
|
26
|
+
}
|
|
27
|
+
declare abstract class Code<Props extends JavaScriptCodeProps | TypeScriptCodeProps, Asset extends JSAsset | TSAsset> {
|
|
28
|
+
readonly entryPoints: EntryPoints;
|
|
29
|
+
protected abstract readonly assetClass: new (scope: Construct, id: string, props: AssetProps) => Asset;
|
|
34
30
|
/**
|
|
35
31
|
* @stability stable
|
|
36
32
|
*/
|
|
37
|
-
protected props:
|
|
33
|
+
protected props: AssetProps;
|
|
38
34
|
/**
|
|
39
35
|
* @stability stable
|
|
40
36
|
*/
|
|
41
37
|
protected asset: Asset;
|
|
42
38
|
/**
|
|
43
|
-
*
|
|
39
|
+
* (deprecated) Determines whether this Code is inline code or not.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated this value is ignored since inline is now determined based on the the inlineCode field of CodeConfig returned from bind().
|
|
44
42
|
*/
|
|
45
|
-
isInline:
|
|
43
|
+
isInline: boolean;
|
|
46
44
|
/**
|
|
47
45
|
*
|
|
48
46
|
* @param entryPoints - Relative path to the asset code. Use `props.buildOptions.absWorkingDir` if an absolute path is required.
|
|
49
47
|
* @param props - Asset properties.
|
|
50
48
|
*/
|
|
51
|
-
constructor(entryPoints:
|
|
49
|
+
constructor(entryPoints: EntryPoints, props: Props);
|
|
52
50
|
/**
|
|
53
51
|
* @stability stable
|
|
54
52
|
*/
|
|
55
53
|
bind(scope: Construct): CodeConfig;
|
|
56
54
|
/**
|
|
55
|
+
* Called after the CFN function resource has been created to allow the code class to bind to it.
|
|
56
|
+
*
|
|
57
|
+
* Specifically it's required to allow assets to add
|
|
58
|
+
* metadata for tooling like SAM CLI to be able to find their origins.
|
|
59
|
+
*
|
|
57
60
|
* @stability stable
|
|
58
61
|
*/
|
|
59
62
|
bindToResource(resource: CfnResource, options?: ResourceBindOptions): void;
|
|
60
63
|
}
|
|
61
64
|
/**
|
|
65
|
+
* Represents the deployed JavaScript Code.
|
|
66
|
+
*
|
|
62
67
|
* @stability stable
|
|
63
68
|
*/
|
|
64
69
|
export declare class JavaScriptCode extends Code<JavaScriptCodeProps, JSAsset> {
|
|
65
70
|
/**
|
|
66
71
|
* @stability stable
|
|
67
72
|
*/
|
|
68
|
-
assetClass: typeof JSAsset;
|
|
73
|
+
protected readonly assetClass: typeof JSAsset;
|
|
74
|
+
/**
|
|
75
|
+
* @param entryPoints A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
76
|
+
* @param props Props to change the behavior of the bundler.
|
|
77
|
+
* @stability stable
|
|
78
|
+
*/
|
|
79
|
+
constructor(
|
|
80
|
+
/**
|
|
81
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
82
|
+
* E.g. `src/index.ts`.
|
|
83
|
+
*
|
|
84
|
+
* @stability stable
|
|
85
|
+
*/
|
|
86
|
+
entryPoints: EntryPoints,
|
|
69
87
|
/**
|
|
88
|
+
* Props to change the behavior of the bundler.
|
|
89
|
+
*
|
|
90
|
+
* Default values for `props.buildOptions`:
|
|
91
|
+
* - `bundle=true`
|
|
92
|
+
* - `platform=node`
|
|
93
|
+
* - `target=nodeX` with X being the major node version running locally
|
|
94
|
+
*
|
|
70
95
|
* @stability stable
|
|
71
96
|
*/
|
|
72
|
-
|
|
97
|
+
props?: JavaScriptCodeProps);
|
|
73
98
|
}
|
|
74
99
|
/**
|
|
100
|
+
* Represents the deployed TypeScript Code.
|
|
101
|
+
*
|
|
75
102
|
* @stability stable
|
|
76
103
|
*/
|
|
77
104
|
export declare class TypeScriptCode extends Code<TypeScriptCodeProps, TSAsset> {
|
|
78
105
|
/**
|
|
79
106
|
* @stability stable
|
|
80
107
|
*/
|
|
81
|
-
assetClass: typeof TSAsset;
|
|
108
|
+
protected readonly assetClass: typeof TSAsset;
|
|
82
109
|
/**
|
|
110
|
+
* @param entryPoints A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
111
|
+
* @param props Props to change the behavior of the bundler.
|
|
112
|
+
* @stability stable
|
|
113
|
+
*/
|
|
114
|
+
constructor(
|
|
115
|
+
/**
|
|
116
|
+
* A relative path or list or map of relative paths to the entry points of your code from the root of the project.
|
|
117
|
+
* E.g. `src/index.ts`.
|
|
118
|
+
*
|
|
119
|
+
* @stability stable
|
|
120
|
+
*/
|
|
121
|
+
entryPoints: EntryPoints,
|
|
122
|
+
/**
|
|
123
|
+
* Props to change the behavior of the bundler.
|
|
124
|
+
*
|
|
125
|
+
* Default values for `props.buildOptions`:
|
|
126
|
+
* - `bundle=true`
|
|
127
|
+
* - `platform=node`
|
|
128
|
+
* - `target=nodeX` with X being the major node version running locally
|
|
129
|
+
*
|
|
83
130
|
* @stability stable
|
|
84
131
|
*/
|
|
85
|
-
|
|
132
|
+
props?: TypeScriptCodeProps);
|
|
86
133
|
}
|
|
87
134
|
export {};
|