@mrgrain/cdk-esbuild 1.127.0 → 2.0.0-alpha.2
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 +23 -0
- package/.jsii +3670 -0
- package/.projenrc.mjs +175 -0
- package/API.md +1685 -0
- package/CHANGELOG.md +2 -2
- package/LICENSE +1 -3
- package/README.md +25 -165
- package/SECURITY.md +18 -0
- package/lib/asset.d.ts +29 -20
- package/lib/asset.js +20 -14
- package/lib/bundler.d.ts +51 -0
- package/lib/bundler.js +71 -0
- package/lib/code.d.ts +68 -17
- package/lib/code.js +49 -12
- package/lib/esbuild-types-raw.d.ts +304 -0
- package/lib/esbuild-types-raw.js +4 -0
- package/lib/esbuild-types.d.ts +464 -0
- package/lib/esbuild-types.js +4 -0
- package/lib/esbuild-wrapper.d.ts +3 -0
- package/lib/esbuild-wrapper.js +12 -0
- package/lib/formatMessages.d.ts +2 -2
- package/lib/formatMessages.js +10 -10
- package/lib/index.d.ts +6 -5
- package/lib/index.js +4 -6
- package/lib/inline-code.d.ts +14 -2
- package/lib/inline-code.js +32 -10
- package/lib/source.d.ts +51 -14
- package/lib/source.js +37 -6
- package/package.json +137 -38
- package/esbuild/Dockerfile +0 -13
- package/esbuild/esbuild-js +0 -22
- package/lib/bundlers.d.ts +0 -53
- package/lib/bundlers.js +0 -93
- package/lib/bundling.d.ts +0 -12
- package/lib/bundling.js +0 -44
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
## [1.128.0](https://github.com/mrgrain/cdk-esbuild/compare/v1.127.0...v1.128.0) (2021-10-16)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
- works with cdk-1.128.0
|
|
4
4
|
|
|
5
5
|
## [1.127.0](https://github.com/mrgrain/cdk-esbuild/compare/v1.126.0...v1.127.0) (2021-10-09)
|
|
6
6
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
_CDK constructs for [esbuild](https://github.com/evanw/esbuild), an extremely fast JavaScript bundler_
|
|
4
4
|
|
|
5
|
-
[Getting started](#getting-started) | [
|
|
5
|
+
[Getting started](#getting-started) | [Upgrading from 1.x](#upgrading-from-1x) |
|
|
6
|
+
[Documentation](#documentation) | [API Reference](#api-reference) | [Versioning](#versioning)
|
|
6
7
|
|
|
7
8
|
## Why?
|
|
8
9
|
|
|
@@ -13,6 +14,12 @@ AWS CDK [supports _esbuild_ with Lambda Functions](https://docs.aws.amazon.com/c
|
|
|
13
14
|
|
|
14
15
|
This 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.
|
|
15
16
|
|
|
17
|
+
**⚠️ Regarding stability**
|
|
18
|
+
|
|
19
|
+
This package is generally stable. However _esbuild_ is still on major version zero, which you should consider. Please check their guide on [production readiness](https://esbuild.github.io/faq/#production-readiness).
|
|
20
|
+
|
|
21
|
+
Notably upgrades of the _esbuild_ version requirement will be introduced in **minor versions** of this package and will inherit breaking changes from _esbuild_.
|
|
22
|
+
|
|
16
23
|
## Getting started
|
|
17
24
|
|
|
18
25
|
Install `cdk-esbuild`:
|
|
@@ -21,10 +28,10 @@ Install `cdk-esbuild`:
|
|
|
21
28
|
npm install @mrgrain/cdk-esbuild
|
|
22
29
|
```
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
If _peer_ and _optional dependencies_ are not installed automatically (e.g. when using npm v4-6), please use this command to install all of them:
|
|
25
32
|
|
|
26
33
|
```
|
|
27
|
-
npm install @mrgrain/cdk-esbuild @aws-cdk/core @aws-cdk/aws-lambda @aws-cdk/aws-s3-assets @aws-cdk/aws-s3-deployment @aws-cdk/aws-synthetics
|
|
34
|
+
npm install @mrgrain/cdk-esbuild esbuild @aws-cdk/core @aws-cdk/aws-lambda @aws-cdk/aws-s3-assets @aws-cdk/aws-s3-deployment @aws-cdk/aws-synthetics
|
|
28
35
|
```
|
|
29
36
|
|
|
30
37
|
### AWS Lambda: Serverless function
|
|
@@ -74,9 +81,6 @@ new s3deploy.BucketDeployment(stack, "DeployWebsite", {
|
|
|
74
81
|
|
|
75
82
|
### Amazon CloudWatch Synthetics: Canary monitoring
|
|
76
83
|
|
|
77
|
-
> ⚠️ **Status: Experimental** \
|
|
78
|
-
> Expect the interface to change. Please report any issues!
|
|
79
|
-
|
|
80
84
|
> 💡 See [Monitored Website](examples/website) for a complete working example of a deployed and monitored website.
|
|
81
85
|
|
|
82
86
|
Synthetics runs a canary to produce traffic to an application for monitoring purposes. Use `TypeScriptCode` as the `code` of a Canary test:
|
|
@@ -117,180 +121,36 @@ For use with **S3 bucket deployments**, classes implementing `s3deploy.ISource`
|
|
|
117
121
|
|
|
118
122
|
- 🧺 `TypeScriptSource` & `JavaScriptSource`
|
|
119
123
|
|
|
120
|
-
> _Code and Source constructs seamlessly plugin to high-level CDK features. They share the same set of parameters, props and build options
|
|
124
|
+
> _Code and Source constructs seamlessly plugin to high-level CDK features. They share the same set of parameters, props and build options._
|
|
121
125
|
|
|
122
|
-
Underlying classes
|
|
126
|
+
Underlying classes power the other features. You normally won't have to use them, but they are there if you need them:
|
|
123
127
|
|
|
124
128
|
- `TypeScriptAsset` & `JavaScriptAsset` implements `s3.Asset` ([reference](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-s3-assets.Asset.html)) \
|
|
125
129
|
creates an asset uploaded to S3 which can be referenced by other constructs
|
|
126
130
|
|
|
127
|
-
- `
|
|
128
|
-
provides a _esbuild_
|
|
129
|
-
|
|
130
|
-
## `TypeScriptCode`, `JavaScriptCode`
|
|
131
|
-
|
|
132
|
-
> ℹ️ _Although these classes are currently identical, please use the appropriate class as functionality might diverge in future releases._
|
|
133
|
-
|
|
134
|
-
**Default build options:**
|
|
135
|
-
|
|
136
|
-
- `bundle=true`
|
|
137
|
-
- `platform=node`
|
|
138
|
-
- `target=nodeX` with `X` being the major node version running the code
|
|
139
|
-
|
|
140
|
-
### Parameters
|
|
141
|
-
|
|
142
|
-
- `entryPoints: string | string[] | Record<string, string>` \
|
|
143
|
-
A single or list of relative paths to the entry points of your code from the root of the project.
|
|
144
|
-
|
|
145
|
-
### Props
|
|
146
|
-
|
|
147
|
-
- `props.buildOptions?` as per esbuild [(reference)](https://esbuild.github.io/getting-started/#build-scripts) \
|
|
148
|
-
**All build options are optional.** \
|
|
149
|
-
Same defaults and functionalities apply, with a few changes as noted below. Generally speaking usage of entry and output options are different, as these are inferred by CDK.
|
|
150
|
-
|
|
151
|
-
- ❌ `buildOptions.entryPoints` \
|
|
152
|
-
_Not available. Option is exposed as parameter._
|
|
153
|
-
|
|
154
|
-
- `buildOptions.outdir: string` \
|
|
155
|
-
The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
|
|
156
|
-
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. \
|
|
157
|
-
_Cannot be used together with `outfile`._
|
|
158
|
-
|
|
159
|
-
- `buildOptions.outfile: string` \
|
|
160
|
-
Relative path to a file inside the CDK asset output directory. \
|
|
161
|
-
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.\
|
|
162
|
-
_Cannot be used with multiple `entryPoints` or together with `outdir`._
|
|
163
|
-
|
|
164
|
-
- `buildOptions.absWorkingDir: string` \
|
|
165
|
-
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).\
|
|
166
|
-
Docker-based builds also use this path to mount local files into the container. A large `absWorkingDir` can slow down the Docker build. \
|
|
167
|
-
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 "A note for library authors" below).
|
|
168
|
-
|
|
169
|
-
> **⚠️ A note for library authors**
|
|
170
|
-
>
|
|
171
|
-
> When developing a library consumed by other packages, you'll most likely have to set `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):
|
|
172
|
-
>
|
|
173
|
-
> ```ts
|
|
174
|
-
> // file: project/src/index.ts
|
|
175
|
-
> const props = {
|
|
176
|
-
> buildOptions: {
|
|
177
|
-
> absWorkingDir: path.resolve(__dirname, ".."), // now: /user/project
|
|
178
|
-
> },
|
|
179
|
-
> };
|
|
180
|
-
> ```
|
|
181
|
-
>
|
|
182
|
-
> This will dynamically resolve to the correct path, wherever the package is installed.
|
|
183
|
-
|
|
184
|
-
- `props.copyDir?: string` \
|
|
185
|
-
**⚠️ Experimental** - _Likely to change once esbuild supports this natively_ \
|
|
186
|
-
Relative path to a directory copied to the output before the build is run (i.e esbuild will overwrite existing files).
|
|
187
|
-
|
|
188
|
-
- `props.bundlerPriority?: BundlerPriority (BundlerPriority.AttemptLocal)` \
|
|
189
|
-
Set the priority order of available bundlers. It can be useful to limit use to one of the bundlers. For Docker, the `absWorkingDir` path (or current working directory) will be mounted into the container as context. By default bundling with a locally installed binary is attempted first and Docker will only be used if the local bundling fails.
|
|
190
|
-
|
|
191
|
-
## `TypeScriptSource`, `JavaScriptSource`
|
|
192
|
-
|
|
193
|
-
> ℹ️ _Although these classes are currently identical, please use the appropriate class as functionality might diverge in future releases._
|
|
194
|
-
|
|
195
|
-
**Default build options:**
|
|
196
|
-
|
|
197
|
-
- `bundle=true`
|
|
198
|
-
- `platform=browser`
|
|
199
|
-
|
|
200
|
-
> 💡 See [Static Website with React](examples/website) for a complete working example of a how to deploy a React app to S3.
|
|
201
|
-
|
|
202
|
-
### Parameters & Props
|
|
203
|
-
|
|
204
|
-
➡️ _Code and Source constructs share the same set of parameters, props and build options. Please see above for details._
|
|
131
|
+
- `EsbuildBundler` implements `core.BundlingOptions` ([reference](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.BundlingOptions.html)) \
|
|
132
|
+
provides an interface for a _esbuild_ bundler wherever needed
|
|
205
133
|
|
|
206
|
-
##
|
|
134
|
+
## [API Reference](API.md)
|
|
207
135
|
|
|
208
|
-
|
|
136
|
+
Auto-generated reference for classes and structs. This information is also available within the code completion of your IDE.
|
|
209
137
|
|
|
210
|
-
|
|
211
|
-
Inline function code is limited to 4 KiB _after_ transformation.
|
|
138
|
+
## Upgrading from 1.x
|
|
212
139
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
- `code: string` \
|
|
216
|
-
The inline code to be transformed.
|
|
217
|
-
|
|
218
|
-
- `transformOptions: TransformOptions` \
|
|
219
|
-
Options from the [esbuild Transform API](https://esbuild.github.io/api/#transform-api).
|
|
220
|
-
|
|
221
|
-
**Default transform options:** \
|
|
222
|
-
• `loader=ts|js|tsx|jsx` (one of `ts,js,tsx,jsx` depending on the used class)
|
|
223
|
-
|
|
224
|
-
## `TypeScriptAsset`, `JavaScriptAsset`
|
|
225
|
-
|
|
226
|
-
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.
|
|
227
|
-
|
|
228
|
-
> ℹ️ _The high-level constructs for `TypeScriptSource` and `TypeScriptCode` (and respective JavaScript classes) actually just use this asset._
|
|
229
|
-
|
|
230
|
-
**Default build options:**
|
|
231
|
-
|
|
232
|
-
- `bundle=true`
|
|
233
|
-
|
|
234
|
-
### Parameters
|
|
235
|
-
|
|
236
|
-
- `scope: cdk.Construct`
|
|
237
|
-
- `id: string`
|
|
238
|
-
- `props: TypeScriptAssetProps|JavaScriptAssetProps`
|
|
239
|
-
|
|
240
|
-
### Props
|
|
241
|
-
|
|
242
|
-
- `props.entryPoints: string | string[] | Record<string, string>` \
|
|
243
|
-
A single or list of relative paths to the entry points of your code from the root of the project.
|
|
244
|
-
|
|
245
|
-
- `props.copyDir?: string` \
|
|
246
|
-
**⚠️ Experimental** - _Likely to change once esbuild supports this natively_ \
|
|
247
|
-
Relative path to a directory copied to the output before the build is run (i.e esbuild will overwrite existing files).
|
|
248
|
-
|
|
249
|
-
- `props.bundlerPriority?: BundlerPriority (BundlerPriority.AttemptLocal)` \
|
|
250
|
-
Set the priority order of available bundlers. It can be useful to limit use to one of the bundlers. For Docker, the `absWorkingDir` path (or current working directory) will be mounted into the container as context. By default bundling with a locally installed binary is attempted first and Docker will only be used if the local bundling fails.
|
|
251
|
-
|
|
252
|
-
- `props.buildOptions?` as per esbuild [(reference)](https://esbuild.github.io/getting-started/#build-scripts) \
|
|
253
|
-
**All build options are optional.** \
|
|
254
|
-
➡️ See `TypeScriptCode` for detailed explanation on options.
|
|
255
|
-
|
|
256
|
-
## `EsbuildBundling`
|
|
257
|
-
|
|
258
|
-
**⚠️ Status: Unstable**
|
|
259
|
-
|
|
260
|
-
Low-level class that can be used where a `BundlingOptions` are required. This class provides the local und Docker-based bundling but doesn't come with any kind of safeguards.
|
|
261
|
-
|
|
262
|
-
### Parameters
|
|
263
|
-
|
|
264
|
-
- `buildOptions?` \
|
|
265
|
-
All esbuild options are available, with adapted functionality as described above.
|
|
266
|
-
|
|
267
|
-
- `props.priority?: BundlerPriority (BundlerPriority.AttemptLocal)` \
|
|
268
|
-
Priority order of available bundlers. Default `BundlerPriority.AttemptLocal` is to attempt using a locally installed binary first, retrying with Docker in case of failure. Can be set to only use either the local or Docker bundler.
|
|
269
|
-
|
|
270
|
-
- `props.copyDir?: string` \
|
|
271
|
-
Copy additional files to the output directory, before the build runs.
|
|
272
|
-
|
|
273
|
-
- `props.esbuildVersion?: string` \
|
|
274
|
-
_Docker build only._ A npm compatible version constraint. If not provided will attempt to read from a `package-lock.json` or `package.json` in the `absWorkingDir`. Otherwise uses the constraint provided by this package (usually `^0.x.0`).
|
|
140
|
+
tbd
|
|
275
141
|
|
|
276
142
|
## Versioning
|
|
277
143
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
_Because esbuild is still in major version zero, this package must be considered unstable. Notably updates to the minimal version requirement of esbuild will be introduced in minor versions of this package and thus will contain any breaking changes esbuild introduces._
|
|
281
|
-
|
|
282
|
-
The package tracks the **minor** version number of CDK releases. It might work with newer versions of CDK, but has not been tested. Features changes, including breaking changes, will only be introduced alongside minor releases.
|
|
283
|
-
|
|
284
|
-
**Patches releases** will contain fixes to this library only and do not necessarily reflect CDK patches.
|
|
144
|
+
This 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`.
|
|
285
145
|
|
|
286
|
-
|
|
146
|
+
Although great care is taken to avoid this, all features marked as `@unstable` may change with minor versions. Please note that the unstable flag is applied to all new or experimental features and internal classes.
|
|
287
147
|
|
|
288
|
-
|
|
148
|
+
## Future releases
|
|
289
149
|
|
|
290
|
-
|
|
150
|
+
### AWS CDK v2
|
|
291
151
|
|
|
292
|
-
The
|
|
152
|
+
The monolithic version 2 of CDK (aka Mono-CDK) is on the horizon. A new major release of this package will be marked alongside CDK. Support for AWS CDK v1.x.x will be continued, however no new features will be added.
|
|
293
153
|
|
|
294
|
-
|
|
154
|
+
### Stable esbuild
|
|
295
155
|
|
|
296
|
-
|
|
156
|
+
Once `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.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Use this section to tell people about which versions of your project are
|
|
6
|
+
currently being supported with security updates.
|
|
7
|
+
|
|
8
|
+
| Plugin Version | CDK Version | Supported |
|
|
9
|
+
| -------------- | ----------- | ------------------------------------------------ |
|
|
10
|
+
| 1.x.x | 1.x.x | :white_check_mark: only the latest minor version |
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
Please raise an [issue](https://github.com/mrgrain/cdk-esbuild/issues) and add the `security` label.
|
|
15
|
+
|
|
16
|
+
I strive to respond to security issues within 48h. However this is an open source project with a single maintainer and life can get in the way.
|
|
17
|
+
|
|
18
|
+
Contributions of secrurity fixes are most welcome!
|
package/lib/asset.d.ts
CHANGED
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
import { Asset as S3Asset } from
|
|
2
|
-
import { Construct
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
entryPoints: string | string[] | Record<string, string>;
|
|
1
|
+
import { Asset as S3Asset } from '@aws-cdk/aws-s3-assets';
|
|
2
|
+
import { Construct } from '@aws-cdk/core';
|
|
3
|
+
import { BundlerProps, EntryPoints } from './bundler';
|
|
4
|
+
/**
|
|
5
|
+
* @stability stable
|
|
6
|
+
*/
|
|
7
|
+
export interface AssetBaseProps extends BundlerProps {
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* A hash of this asset, which is available at construction time.
|
|
10
|
+
*
|
|
11
|
+
* As this is a plain string, it
|
|
12
|
+
* can be used in construct IDs in order to enforce creation of a new resource when the content
|
|
13
|
+
* hash has changed.
|
|
14
|
+
*
|
|
15
|
+
* @stability stable
|
|
11
16
|
*/
|
|
12
|
-
|
|
17
|
+
readonly assetHash?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @stability stable
|
|
21
|
+
*/
|
|
22
|
+
export interface AssetProps extends AssetBaseProps {
|
|
13
23
|
/**
|
|
14
|
-
*
|
|
24
|
+
* Relative paths to the entrypoints of your code, e.g. `src/index.ts`.
|
|
15
25
|
*
|
|
16
|
-
* @
|
|
26
|
+
* @stability stable
|
|
17
27
|
*/
|
|
18
|
-
|
|
28
|
+
readonly entryPoints: EntryPoints;
|
|
29
|
+
}
|
|
30
|
+
declare type JavaScriptAssetProps = AssetProps;
|
|
31
|
+
declare type TypeScriptAssetProps = AssetProps;
|
|
32
|
+
declare abstract class Asset<Props extends AssetProps> extends S3Asset {
|
|
19
33
|
/**
|
|
20
|
-
*
|
|
34
|
+
* @experimental
|
|
21
35
|
*/
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
export declare type JavaScriptAssetProps = EsbuildAssetProps;
|
|
25
|
-
export declare type TypeScriptAssetProps = EsbuildAssetProps;
|
|
26
|
-
declare abstract class Asset<Props extends EsbuildAssetProps> extends S3Asset {
|
|
27
|
-
constructor(scope: Construct, id: string, { entryPoints: propEntryPoints, assetHash, bundlerPriority, copyDir, buildOptions: options, }: Props);
|
|
36
|
+
constructor(scope: Construct, id: string, props: Props);
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* @experimental
|
package/lib/asset.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.TypeScriptAsset = exports.JavaScriptAsset = void 0;
|
|
5
|
+
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
|
6
|
+
const path_1 = require("path");
|
|
4
7
|
const aws_s3_assets_1 = require("@aws-cdk/aws-s3-assets");
|
|
5
8
|
const core_1 = require("@aws-cdk/core");
|
|
6
|
-
const
|
|
7
|
-
const bundlers_1 = require("./bundlers");
|
|
8
|
-
const bundling_1 = require("./bundling");
|
|
9
|
+
const bundler_1 = require("./bundler");
|
|
9
10
|
class Asset extends aws_s3_assets_1.Asset {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
constructor(scope, id, props) {
|
|
15
|
+
var _c;
|
|
16
|
+
const { assetHash, copyDir, buildOptions: options = {}, } = props;
|
|
17
|
+
const entryPoints = typeof props.entryPoints === 'string' ? [props.entryPoints] : props.entryPoints;
|
|
13
18
|
const name = scope.node.path + core_1.ConstructNode.PATH_SEP + id;
|
|
14
19
|
Object.values(entryPoints).forEach((entryPoint) => {
|
|
15
|
-
if (
|
|
20
|
+
if (path_1.isAbsolute(entryPoint)) {
|
|
16
21
|
throw new Error(`${name}: Entry points must be a relative path. If you need to define an absolute path, please use \`buildOptions.absWorkingDir\` accordingly.`);
|
|
17
22
|
}
|
|
18
23
|
});
|
|
19
|
-
const absWorkingDir = (
|
|
24
|
+
const absWorkingDir = (_c = options.absWorkingDir) !== null && _c !== void 0 ? _c : process.cwd();
|
|
20
25
|
const buildOptions = {
|
|
21
26
|
bundle: true,
|
|
22
27
|
...options,
|
|
@@ -26,11 +31,8 @@ class Asset extends aws_s3_assets_1.Asset {
|
|
|
26
31
|
path: absWorkingDir,
|
|
27
32
|
assetHash,
|
|
28
33
|
assetHashType: assetHash ? core_1.AssetHashType.CUSTOM : core_1.AssetHashType.OUTPUT,
|
|
29
|
-
bundling: new
|
|
30
|
-
|
|
31
|
-
entryPoints,
|
|
32
|
-
}, {
|
|
33
|
-
priority: bundlerPriority,
|
|
34
|
+
bundling: new bundler_1.EsbuildBundler(entryPoints, {
|
|
35
|
+
buildOptions,
|
|
34
36
|
copyDir,
|
|
35
37
|
}),
|
|
36
38
|
});
|
|
@@ -42,10 +44,14 @@ class Asset extends aws_s3_assets_1.Asset {
|
|
|
42
44
|
class JavaScriptAsset extends Asset {
|
|
43
45
|
}
|
|
44
46
|
exports.JavaScriptAsset = JavaScriptAsset;
|
|
47
|
+
_a = JSII_RTTI_SYMBOL_1;
|
|
48
|
+
JavaScriptAsset[_a] = { fqn: "@mrgrain/cdk-esbuild.JavaScriptAsset", version: "2.0.0-alpha.2" };
|
|
45
49
|
/**
|
|
46
50
|
* @experimental
|
|
47
51
|
*/
|
|
48
52
|
class TypeScriptAsset extends Asset {
|
|
49
53
|
}
|
|
50
54
|
exports.TypeScriptAsset = TypeScriptAsset;
|
|
51
|
-
|
|
55
|
+
_b = JSII_RTTI_SYMBOL_1;
|
|
56
|
+
TypeScriptAsset[_b] = { fqn: "@mrgrain/cdk-esbuild.TypeScriptAsset", version: "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gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICByZWFkb25seSBhc3NldEhhc2g/OiBzdHJpbmc7XG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgQXNzZXRQcm9wcyBleHRlbmRzIEFzc2V0QmFzZVByb3BzIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFxuICByZWFkb25seSBlbnRyeVBvaW50czogRW50cnlQb2ludHM7XG59XG5cbnR5cGUgSmF2YVNjcmlwdEFzc2V0UHJvcHMgPSBBc3NldFByb3BzO1xudHlwZSBUeXBlU2NyaXB0QXNzZXRQcm9wcyA9IEFzc2V0UHJvcHM7XG5cbmFic3RyYWN0IGNsYXNzIEFzc2V0PFByb3BzIGV4dGVuZHMgQXNzZXRQcm9wcz4gZXh0ZW5kcyBTM0Fzc2V0IHtcbiAgcHVibGljIGNvbnN0cnVjdG9yKFxuICAgIHNjb3BlOiBDb25zdHJ1Y3QsXG4gICAgaWQ6IHN0cmluZyxcbiAgICBwcm9wczogUHJvcHMsXG4gICkge1xuICAgIGNvbnN0IHtcbiAgICAgIGFzc2V0SGFzaCxcbiAgICAgIGNvcHlEaXIsXG4gICAgICBidWlsZE9wdGlvbnM6IG9wdGlvbnMgPSB7fSxcbiAgICB9ID0gcHJvcHM7XG4gICAgY29uc3QgZW50cnlQb2ludHM6IHN0cmluZ1tdIHwgUmVjb3JkPHN0cmluZywgc3RyaW5nPiA9XG4gICAgICB0eXBlb2YgcHJvcHMuZW50cnlQb2ludHMgPT09ICdzdHJpbmcnID8gW3Byb3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pbGRPcHRpb25zLFxuICAgICAgICAgIGNvcHlEaXIsXG4gICAgICAgIH0sXG4gICAgICApLFxuICAgIH0pO1xuICB9XG59XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIFxuZXhwb3J0IGNsYXNzIEphdmFTY3JpcHRBc3NldCBleHRlbmRzIEFzc2V0PEphdmFTY3JpcHRBc3NldFByb3BzPiB7fVxuXG4gICAgICAgICAgICAgICAgICAgICAgICBcbmV4cG9ydCBjbGFzcyBUeXBlU2NyaXB0QXNzZXQgZXh0ZW5kcyBBc3NldDxUeXBlU2NyaXB0QXNzZXRQcm9wcz4ge31cbiJdfQ==
|
package/lib/bundler.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DockerImage, ILocalBundling } from '@aws-cdk/core';
|
|
2
|
+
import { BuildOptions } from './esbuild-types';
|
|
3
|
+
/**
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
6
|
+
export declare type EntryPoints = string | string[] | Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export interface BundlerProps {
|
|
11
|
+
/**
|
|
12
|
+
* (experimental) Options passed on to esbuild.
|
|
13
|
+
*
|
|
14
|
+
* @experimental
|
|
15
|
+
*/
|
|
16
|
+
readonly buildOptions?: BuildOptions;
|
|
17
|
+
/**
|
|
18
|
+
* (experimental) Relative path to a directory copied to the output BEFORE esbuild is run (i.e esbuild will overwrite existing files).
|
|
19
|
+
*
|
|
20
|
+
* @experimental
|
|
21
|
+
*/
|
|
22
|
+
readonly copyDir?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @experimental
|
|
26
|
+
*/
|
|
27
|
+
export declare class EsbuildBundler {
|
|
28
|
+
/**
|
|
29
|
+
* Relative paths to the entrypoints of your code, e.g. `src/index.ts`
|
|
30
|
+
*/
|
|
31
|
+
readonly entryPoints: EntryPoints;
|
|
32
|
+
readonly props: BundlerProps;
|
|
33
|
+
/**
|
|
34
|
+
* @experimental
|
|
35
|
+
*/
|
|
36
|
+
readonly local: ILocalBundling;
|
|
37
|
+
/**
|
|
38
|
+
* @experimental
|
|
39
|
+
*/
|
|
40
|
+
readonly image: DockerImage;
|
|
41
|
+
/**
|
|
42
|
+
* @param entryPoints Relative paths to the entrypoints of your code, e.g. `src/index.ts`.
|
|
43
|
+
* @experimental
|
|
44
|
+
*/
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Relative paths to the entrypoints of your code, e.g. `src/index.ts`
|
|
48
|
+
*/
|
|
49
|
+
entryPoints: EntryPoints, props: BundlerProps);
|
|
50
|
+
private getOutputOptions;
|
|
51
|
+
}
|
package/lib/bundler.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
|
12
|
+
*/
|
|
13
|
+
class EsbuildBundler {
|
|
14
|
+
/**
|
|
15
|
+
* @param entryPoints Relative paths to the entrypoints of your code, e.g. `src/index.ts`.
|
|
16
|
+
* @experimental
|
|
17
|
+
*/
|
|
18
|
+
constructor(
|
|
19
|
+
/**
|
|
20
|
+
* Relative paths to the entrypoints of your code, e.g. `src/index.ts`
|
|
21
|
+
*/
|
|
22
|
+
entryPoints, props) {
|
|
23
|
+
var _b, _c;
|
|
24
|
+
this.entryPoints = entryPoints;
|
|
25
|
+
this.props = props;
|
|
26
|
+
/**
|
|
27
|
+
* @experimental
|
|
28
|
+
*/
|
|
29
|
+
this.image = core_1.DockerImage.fromRegistry('scratch');
|
|
30
|
+
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)) {
|
|
31
|
+
throw new Error('Cannot use both "outfile" and "outdir"');
|
|
32
|
+
}
|
|
33
|
+
this.local = {
|
|
34
|
+
tryBundle: (outputDir, _options) => {
|
|
35
|
+
var _b, _c, _d, _e;
|
|
36
|
+
try {
|
|
37
|
+
if (this.props.copyDir) {
|
|
38
|
+
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);
|
|
39
|
+
}
|
|
40
|
+
const buildResult = esbuild_wrapper_1.buildSync({
|
|
41
|
+
entryPoints,
|
|
42
|
+
...(((_e = this.props) === null || _e === void 0 ? void 0 : _e.buildOptions) || {}),
|
|
43
|
+
...this.getOutputOptions(outputDir, { normalize: path_1.normalize, join: path_1.join }),
|
|
44
|
+
});
|
|
45
|
+
formatMessages_1.printBuildMessages(buildResult, { prefix: 'Build ' });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
formatMessages_1.printBuildMessages(error, { prefix: 'Build ' });
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
getOutputOptions(cdkOutputDir, path = path_1.posix) {
|
|
55
|
+
var _b, _c, _d, _e, _f, _g;
|
|
56
|
+
if ((_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.buildOptions) === null || _c === void 0 ? void 0 : _c.outfile) {
|
|
57
|
+
return {
|
|
58
|
+
outdir: undefined,
|
|
59
|
+
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))),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
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))),
|
|
64
|
+
outfile: undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.EsbuildBundler = EsbuildBundler;
|
|
69
|
+
_a = JSII_RTTI_SYMBOL_1;
|
|
70
|
+
EsbuildBundler[_a] = { fqn: "@mrgrain/cdk-esbuild.EsbuildBundler", version: "2.0.0-alpha.2" };
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9idW5kbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsK0JBQXFFO0FBQ3JFLHdDQUt1QjtBQUV2Qix1REFBOEM7QUFDOUMscURBQXNEOzs7O0FBaUJ0RCxNQUFhLGNBQWM7Ozs7O0lBS3pCO0lBQ0U7O09BRUc7SUFDYSxXQUF3QixFQUN4QixLQUFtQjs7UUFEbkIsZ0JBQVcsR0FBWCxXQUFXLENBQWE7UUFDeEIsVUFBSyxHQUFMLEtBQUssQ0FBYzs7OztRQVByQixVQUFLLEdBQUcsa0JBQVcsQ0FBQyxZQUFZLENBQUMsU0FBUyxDQUFDLENBQUM7UUFTMUQsSUFBSSxPQUFBLEtBQUssYUFBTCxLQUFLLHVCQUFMLEtBQUssQ0FBRSxZQUFZLDBDQUFFLE9BQU8sWUFBSSxLQUFLLGFBQUwsS0FBSyx1QkFBTCxLQUFLLENBQUUsWUFBWSwwQ0FBRSxNQUFNLENBQUEsRUFBRTtZQUMvRCxNQUF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SBmcm9tICcuL2VzYnVpbGQtd3JhcHBlcic7XG5pbXBvcnQgeyBwcmludEJ1aWxkTWVzc2FnZXMgfSBmcm9tICcuL2Zvcm1hdE1lc3NhZ2VzJztcblxuLyoqXG4gKiBAZXhwZXJpbWVudGFsXG4gKi9cbmV4cG9ydCB0eXBlIEVudHJ5UG9pbnRzID0gc3RyaW5nIHwgc3RyaW5nW10gfCBSZWNvcmQ8c3RyaW5nLCBzdHJpbmc+O1xuXG4gICAgICAgICAgICAgICAgICAgICAgICBcbmV4cG9ydCBpbnRlcmZhY2UgQnVuZGxlclByb3BzIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcbiAgcmVhZG9ubHkgYnVpbGRPcHRpb25zPzogQnVpbGRPcHRpb25zO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXG4gIHJlYWRvbmx5IGNvcHlEaXI/OiBzdHJpbmc7XG59XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIFxuZXhwb3J0IGNsYXNzIEVzYnVpbGRCdW5kbGVyIHtcbiAgcHVibGljIHJlYWRvbmx5IGxvY2FsOiBJTG9jYWxCdW5kbGluZztcblxuICBwdWJsaWMgcmVhZG9ubHkgaW1hZ2UgPSBEb2NrZXJJbWFnZS5mcm9tUmVnaXN0cnkoJ3NjcmF0Y2gnKTtcblxuICBwdWJsaWMgY29uc3RydWN0b3IoXG4gICAgLyoqXG4gICAgICogUmVsYXRpdmUgcGF0aHMgdG8gdGhlIGVudHJ5cG9pbnRzIG9mIHlvdXIgY29kZSwgZS5nLiBgc3JjL2luZGV4LnRzYFxuICAgICAqL1xuICAgIHB1YmxpYyByZWFkb25seSBlbnRyeVBvaW50czogRW50cnlQb2ludHMsXG4gICAgcHVibGljIHJlYWRvbmx5IHByb3BzOiBCdW5kbGVyUHJvcHMsXG4gICkge1xuICAgIGlmIChwcm9wcz8uYnVpbGRPcHRpb25zPy5vdXRmaWxlICYmIHByb3BzPy5idWlsZE9wdGlvbnM/Lm91dGRpcikge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKCdDYW5ub3QgdXNlIGJvdGggXCJvdXRmaWxlXCIgYW5kIFwib3V0ZGlyXCInKTtcbiAgICB9XG5cbiAgICB0aGlzLmxvY2FsID0ge1xuICAgICAgdHJ5QnVuZGxlOiAob3V0cHV0RGlyOiBzdHJpbmcsIF9vcHRpb25zOiBCdW5kbGluZ09wdGlvbnMpOiBib29sZWFuID0+IHtcbiAgICAgICAgdHJ5IHtcbiAgICAgICAgICBpZiAodGhpcy5wcm9wcy5jb3B5RGlyKSB7XG4gICAgICAgICAgICBGaWxlU3lzdGVtLmNvcHlEaXJlY3RvcnkoXG4gICAgICAgICAgICAgIHJlc29sdmUoXG4gICAgICAgICAgICAgICAgdGhpcy5wcm9wcz8uYnVpbGRPcHRpb25zPy5hYnNXb3JraW5nRGlyID8/IHByb2Nlc3MuY3dkKCksXG4gICAgICAgICAgICAgICAgdGhpcy5wcm9wcy5jb3B5RGlyLFxuICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgICBvdXRwdXREaXIsXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGNvbnN0IGJ1aWxkUmVzdWx0OiBCdWlsZFJlc3VsdCA9IGJ1aWxkU3luYyh7XG4gICAgICAgICAgICBlbnRyeVBvaW50cyxcbiAgICAgICAgICAgIC4uLih0aGlzLnByb3BzPy5idWlsZE9wdGlvbnMgfHwge30pLFxuICAgICAgICAgICAgLi4udGhpcy5nZXRPdXRwdXRPcHRpb25zKG91dHB1dERpciwgeyBub3JtYWxpemUsIGpvaW4gfSksXG4gICAgICAgICAgfSk7XG5cbiAgICAgICAgICBwcmludEJ1aWxkTWVzc2FnZXMoYnVpbGRSZXN1bHQsIHs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