@mrgrain/cdk-esbuild 3.2.0 → 3.5.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/.projenrc.ts CHANGED
@@ -58,14 +58,6 @@ const project = new awscdk.AwsCdkConstructLibrary({
58
58
  eslintOptions: {
59
59
  lintProjenRc: false,
60
60
  dirs: ['src', 'projenrc', '.projenrc.ts'],
61
- ignorePatterns: [
62
- '*.js',
63
- '*.d.ts',
64
- 'node_modules/',
65
- '*.generated.ts',
66
- 'coverage',
67
- 'examples/',
68
- ],
69
61
  },
70
62
 
71
63
  // Release
@@ -85,14 +77,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
85
77
 
86
78
  // Dependencies
87
79
  cdkVersion: '2.0.0',
88
- peerDeps: [
89
- 'aws-cdk-lib@^2.0.0',
90
- ],
91
80
  devDeps: [
92
- '@aws-cdk/aws-synthetics-alpha',
81
+ '@aws-cdk/aws-synthetics-alpha@2.0.0-alpha.11',
93
82
  '@types/eslint',
94
- 'aws-cdk-lib@2.0.0',
95
- 'constructs@10.0.5',
96
83
  'esbuild@^0.14.0',
97
84
  'jest-mock',
98
85
  'ts-morph',
@@ -166,10 +153,22 @@ new vscode.VsCode(project).launchConfiguration.addConfiguration({
166
153
  project.tryFindObjectFile('package.json')?.addOverride('optionalDependencies', {
167
154
  esbuild: '^0.14.0',
168
155
  });
156
+ project.tryFindObjectFile('package.json')?.addOverride('overrides', {
157
+ '@types/prettier': '2.6.0',
158
+ });
169
159
 
170
160
  project.eslint?.addRules({
171
161
  '@typescript-eslint/member-ordering': 'off',
172
162
  });
163
+ project.eslint?.addOverride({
164
+ files: ['projenrc/*.ts'],
165
+ rules: {
166
+ '@typescript-eslint/no-require-imports': 'off',
167
+ 'import/no-extraneous-dependencies': 'off',
168
+ },
169
+ });
170
+ project.eslint?.addIgnorePattern('examples/');
171
+ project.eslint?.addIgnorePattern('!projenrc/*.ts');
173
172
 
174
173
  new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
175
174
  source: 'node_modules/esbuild/lib/main.d.ts',
@@ -191,6 +190,7 @@ new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
191
190
  esbuildTypes.getInterface('CommonOptions')?.getProperty('mangleProps')?.setType('any');
192
191
  esbuildTypes.getInterface('CommonOptions')?.getProperty('reserveProps')?.setType('any');
193
192
  esbuildTypes.getInterface('TransformOptions')?.getProperty('tsconfigRaw')?.setType('string');
193
+ esbuildTypes.getInterface('InitializeOptions')?.getProperty('wasmModule')?.setType('any');
194
194
  },
195
195
  });
196
196
 
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
- - `buildOptions.outfile: string`
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
- - `buildOptions.absWorkingDir: string`
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
- Copy additional files to the output directory, before the build runs.
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
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
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
 
@@ -433,6 +446,18 @@ Documentation: https://esbuild.github.io/api/#log-limit.
433
446
 
434
447
  ---
435
448
 
449
+ ##### `logOverride`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BuildOptions.property.logOverride"></a>
450
+
451
+ ```typescript
452
+ public readonly logOverride: {[ key: string ]: string};
453
+ ```
454
+
455
+ - *Type:* {[ key: string ]: `string`}
456
+
457
+ Documentation: https://esbuild.github.io/api/#log-override.
458
+
459
+ ---
460
+
436
461
  ##### `mainFields`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BuildOptions.property.mainFields"></a>
437
462
 
438
463
  ```typescript
@@ -469,6 +494,18 @@ Documentation: https://esbuild.github.io/api/#mangle-props.
469
494
 
470
495
  ---
471
496
 
497
+ ##### `mangleQuoted`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BuildOptions.property.mangleQuoted"></a>
498
+
499
+ ```typescript
500
+ public readonly mangleQuoted: boolean;
501
+ ```
502
+
503
+ - *Type:* `boolean`
504
+
505
+ Documentation: https://esbuild.github.io/api/#mangle-props.
506
+
507
+ ---
508
+
472
509
  ##### `metafile`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BuildOptions.property.metafile"></a>
473
510
 
474
511
  ```typescript
@@ -793,15 +830,15 @@ public readonly buildOptions: BuildOptions;
793
830
 
794
831
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
795
832
 
796
- `buildOptions.outdir: string`
833
+ * `buildOptions.outdir: string`
797
834
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
798
835
  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. \
799
836
  *Cannot be used together with `outfile`*.
800
- - `buildOptions.outfile: string`
837
+ * `buildOptions.outfile: string`
801
838
  Relative path to a file inside the CDK asset output directory.
802
839
  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. \
803
840
  *Cannot be used with multiple entryPoints or together with `outdir`.*
804
- - `buildOptions.absWorkingDir: string`
841
+ * `buildOptions.absWorkingDir: string`
805
842
  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). \
806
843
  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).
807
844
 
@@ -812,14 +849,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
812
849
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BundlerProps.property.copyDir"></a>
813
850
 
814
851
  ```typescript
815
- public readonly copyDir: string;
852
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
816
853
  ```
817
854
 
818
- - *Type:* `string`
855
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
819
856
 
820
- Copy additional files to the output directory, before the build runs.
857
+ 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.
821
858
 
822
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
859
+ * When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
860
+ * 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.
861
+
862
+ Therefore the following values for `copyDir` are all equivalent:
863
+ ```ts
864
+ { copyDir: "path/to/source" }
865
+ { copyDir: ["path/to/source"] }
866
+ { copyDir: { ".": "path/to/source" } }
867
+ { copyDir: { ".": ["path/to/source"] } }
868
+ ```
869
+ The destination cannot be outside of the asset staging directory.
870
+ If you are receiving the error "Cannot copy files to outside of the asset staging directory."
871
+ you are likely using `..` or an absolute path as key on the `copyDir` map.
872
+ Instead use only relative paths and avoid `..`.
823
873
 
824
874
  ---
825
875
 
@@ -881,15 +931,15 @@ public readonly buildOptions: BuildOptions;
881
931
 
882
932
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
883
933
 
884
- `buildOptions.outdir: string`
934
+ * `buildOptions.outdir: string`
885
935
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
886
936
  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. \
887
937
  *Cannot be used together with `outfile`*.
888
- - `buildOptions.outfile: string`
938
+ * `buildOptions.outfile: string`
889
939
  Relative path to a file inside the CDK asset output directory.
890
940
  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. \
891
941
  *Cannot be used with multiple entryPoints or together with `outdir`.*
892
- - `buildOptions.absWorkingDir: string`
942
+ * `buildOptions.absWorkingDir: string`
893
943
  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). \
894
944
  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).
895
945
 
@@ -900,14 +950,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
900
950
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptCodeProps.property.copyDir"></a>
901
951
 
902
952
  ```typescript
903
- public readonly copyDir: string;
953
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
904
954
  ```
905
955
 
906
- - *Type:* `string`
956
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
957
+
958
+ 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.
907
959
 
908
- Copy additional files to the output directory, before the build runs.
960
+ * When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
961
+ * 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.
909
962
 
910
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
963
+ Therefore the following values for `copyDir` are all equivalent:
964
+ ```ts
965
+ { copyDir: "path/to/source" }
966
+ { copyDir: ["path/to/source"] }
967
+ { copyDir: { ".": "path/to/source" } }
968
+ { copyDir: { ".": ["path/to/source"] } }
969
+ ```
970
+ The destination cannot be outside of the asset staging directory.
971
+ If you are receiving the error "Cannot copy files to outside of the asset staging directory."
972
+ you are likely using `..` or an absolute path as key on the `copyDir` map.
973
+ Instead use only relative paths and avoid `..`.
911
974
 
912
975
  ---
913
976
 
@@ -963,15 +1026,15 @@ public readonly buildOptions: BuildOptions;
963
1026
 
964
1027
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
965
1028
 
966
- `buildOptions.outdir: string`
1029
+ * `buildOptions.outdir: string`
967
1030
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
968
1031
  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. \
969
1032
  *Cannot be used together with `outfile`*.
970
- - `buildOptions.outfile: string`
1033
+ * `buildOptions.outfile: string`
971
1034
  Relative path to a file inside the CDK asset output directory.
972
1035
  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. \
973
1036
  *Cannot be used with multiple entryPoints or together with `outdir`.*
974
- - `buildOptions.absWorkingDir: string`
1037
+ * `buildOptions.absWorkingDir: string`
975
1038
  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). \
976
1039
  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).
977
1040
 
@@ -982,14 +1045,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
982
1045
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptSourceProps.property.copyDir"></a>
983
1046
 
984
1047
  ```typescript
985
- public readonly copyDir: string;
1048
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
986
1049
  ```
987
1050
 
988
- - *Type:* `string`
1051
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
1052
+
1053
+ 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.
989
1054
 
990
- Copy additional files to the output directory, before the build runs.
1055
+ * When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
1056
+ * 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.
991
1057
 
992
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
1058
+ Therefore the following values for `copyDir` are all equivalent:
1059
+ ```ts
1060
+ { copyDir: "path/to/source" }
1061
+ { copyDir: ["path/to/source"] }
1062
+ { copyDir: { ".": "path/to/source" } }
1063
+ { copyDir: { ".": ["path/to/source"] } }
1064
+ ```
1065
+ The destination cannot be outside of the asset staging directory.
1066
+ If you are receiving the error "Cannot copy files to outside of the asset staging directory."
1067
+ you are likely using `..` or an absolute path as key on the `copyDir` map.
1068
+ Instead use only relative paths and avoid `..`.
993
1069
 
994
1070
  ---
995
1071
 
@@ -1259,6 +1335,18 @@ Documentation: https://esbuild.github.io/api/#log-limit.
1259
1335
 
1260
1336
  ---
1261
1337
 
1338
+ ##### `logOverride`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TransformOptions.property.logOverride"></a>
1339
+
1340
+ ```typescript
1341
+ public readonly logOverride: {[ key: string ]: string};
1342
+ ```
1343
+
1344
+ - *Type:* {[ key: string ]: `string`}
1345
+
1346
+ Documentation: https://esbuild.github.io/api/#log-override.
1347
+
1348
+ ---
1349
+
1262
1350
  ##### `mangleCache`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TransformOptions.property.mangleCache"></a>
1263
1351
 
1264
1352
  ```typescript
@@ -1283,6 +1371,18 @@ Documentation: https://esbuild.github.io/api/#mangle-props.
1283
1371
 
1284
1372
  ---
1285
1373
 
1374
+ ##### `mangleQuoted`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TransformOptions.property.mangleQuoted"></a>
1375
+
1376
+ ```typescript
1377
+ public readonly mangleQuoted: boolean;
1378
+ ```
1379
+
1380
+ - *Type:* `boolean`
1381
+
1382
+ Documentation: https://esbuild.github.io/api/#mangle-props.
1383
+
1384
+ ---
1385
+
1286
1386
  ##### `minify`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TransformOptions.property.minify"></a>
1287
1387
 
1288
1388
  ```typescript
@@ -1471,15 +1571,15 @@ public readonly buildOptions: BuildOptions;
1471
1571
 
1472
1572
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
1473
1573
 
1474
- `buildOptions.outdir: string`
1574
+ * `buildOptions.outdir: string`
1475
1575
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
1476
1576
  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. \
1477
1577
  *Cannot be used together with `outfile`*.
1478
- - `buildOptions.outfile: string`
1578
+ * `buildOptions.outfile: string`
1479
1579
  Relative path to a file inside the CDK asset output directory.
1480
1580
  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. \
1481
1581
  *Cannot be used with multiple entryPoints or together with `outdir`.*
1482
- - `buildOptions.absWorkingDir: string`
1582
+ * `buildOptions.absWorkingDir: string`
1483
1583
  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). \
1484
1584
  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).
1485
1585
 
@@ -1490,14 +1590,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
1490
1590
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptCodeProps.property.copyDir"></a>
1491
1591
 
1492
1592
  ```typescript
1493
- public readonly copyDir: string;
1593
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
1494
1594
  ```
1495
1595
 
1496
- - *Type:* `string`
1596
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
1497
1597
 
1498
- Copy additional files to the output directory, before the build runs.
1598
+ 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.
1499
1599
 
1500
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
1600
+ * When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
1601
+ * 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.
1602
+
1603
+ Therefore the following values for `copyDir` are all equivalent:
1604
+ ```ts
1605
+ { copyDir: "path/to/source" }
1606
+ { copyDir: ["path/to/source"] }
1607
+ { copyDir: { ".": "path/to/source" } }
1608
+ { copyDir: { ".": ["path/to/source"] } }
1609
+ ```
1610
+ The destination cannot be outside of the asset staging directory.
1611
+ If you are receiving the error "Cannot copy files to outside of the asset staging directory."
1612
+ you are likely using `..` or an absolute path as key on the `copyDir` map.
1613
+ Instead use only relative paths and avoid `..`.
1501
1614
 
1502
1615
  ---
1503
1616
 
@@ -1553,15 +1666,15 @@ public readonly buildOptions: BuildOptions;
1553
1666
 
1554
1667
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
1555
1668
 
1556
- `buildOptions.outdir: string`
1669
+ * `buildOptions.outdir: string`
1557
1670
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
1558
1671
  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. \
1559
1672
  *Cannot be used together with `outfile`*.
1560
- - `buildOptions.outfile: string`
1673
+ * `buildOptions.outfile: string`
1561
1674
  Relative path to a file inside the CDK asset output directory.
1562
1675
  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. \
1563
1676
  *Cannot be used with multiple entryPoints or together with `outdir`.*
1564
- - `buildOptions.absWorkingDir: string`
1677
+ * `buildOptions.absWorkingDir: string`
1565
1678
  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). \
1566
1679
  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).
1567
1680
 
@@ -1572,14 +1685,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
1572
1685
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptSourceProps.property.copyDir"></a>
1573
1686
 
1574
1687
  ```typescript
1575
- public readonly copyDir: string;
1688
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
1576
1689
  ```
1577
1690
 
1578
- - *Type:* `string`
1691
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
1692
+
1693
+ 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.
1579
1694
 
1580
- Copy additional files to the output directory, before the build runs.
1695
+ * When provided with a `string` or `array`, all files are copied to the root of asset staging directory.
1696
+ * 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.
1581
1697
 
1582
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
1698
+ Therefore the following values for `copyDir` are all equivalent:
1699
+ ```ts
1700
+ { copyDir: "path/to/source" }
1701
+ { copyDir: ["path/to/source"] }
1702
+ { copyDir: { ".": "path/to/source" } }
1703
+ { copyDir: { ".": ["path/to/source"] } }
1704
+ ```
1705
+ The destination cannot be outside of the asset staging directory.
1706
+ If you are receiving the error "Cannot copy files to outside of the asset staging directory."
1707
+ you are likely using `..` or an absolute path as key on the `copyDir` map.
1708
+ Instead use only relative paths and avoid `..`.
1583
1709
 
1584
1710
  ---
1585
1711
 
package/CHANGELOG.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
- ## [3.2.0](https://github.com/mrgrain/cdk-esbuild/compare/v3.1.0...v3.2.0) (2022-02-04)
2
+ ## [3.5.0](https://github.com/mrgrain/cdk-esbuild/compare/v3.4.0...v3.5.0) (2022-06-02)
3
3
 
4
4
 
5
5
  ### Features
6
6
 
7
- * support esbuild mangle-props ([a2566d1](https://github.com/mrgrain/cdk-esbuild/commit/a2566d1ebdb3ed8fabecdda31de413d64075f441))
7
+ * support logOverride buildOption ([d1cad61](https://github.com/mrgrain/cdk-esbuild/commit/d1cad614a28f0e07b9646ff62dd47393f5616b99))
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  _CDK constructs for [esbuild](https://github.com/evanw/esbuild), an extremely fast JavaScript bundler_
4
4
 
5
- > ⚠️ 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)
6
-
7
5
  [Getting started](#getting-started) | [Migrating to v3](#migrating-to-v3) |
8
6
  [Documentation](#documentation) | [API Reference](#api-reference) | [Versioning](#versioning)
9
7
 
8
+ > 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).
9
+
10
10
  ## Why?
11
11
 
12
12
  _esbuild_ is an extremely fast bundler and minifier for Typescript and JavaScript.
@@ -18,7 +18,7 @@ This package is running _esbuild_ directly in Node.js and bypasses Docker which
18
18
 
19
19
  **Production readiness**
20
20
 
21
- This 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).
21
+ This 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).
22
22
 
23
23
  Notably upgrades of the _esbuild_ minimum version requirement will be introduced in **minor versions** of this package and will inherit breaking changes from _esbuild_.
24
24
 
@@ -30,7 +30,7 @@ Install `cdk-esbuild`:
30
30
  npm install @mrgrain/cdk-esbuild@3
31
31
  ```
32
32
 
33
- 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:
33
+ If _peer_ or _optional dependencies_ are not installed automatically (e.g. when using npm v4-6), please use this command to install all of them:
34
34
 
35
35
  ```
36
36
  npm install @mrgrain/cdk-esbuild@3 esbuild
@@ -49,7 +49,7 @@ import { TypeScriptCode } from "@mrgrain/cdk-esbuild";
49
49
  const bundledCode = new TypeScriptCode("src/index.ts");
50
50
 
51
51
  const fn = new lambda.Function(stack, "MyFunction", {
52
- runtime: lambda.Runtime.NODEJS_14_X,
52
+ runtime: lambda.Runtime.NODEJS_16_X,
53
53
  handler: "index.handler",
54
54
  code: bundledCode,
55
55
  });
@@ -112,7 +112,7 @@ const canary = new synthetics.Canary(stack, "MyCanary", {
112
112
  });
113
113
  ```
114
114
 
115
- # Documentation
115
+ ## Documentation
116
116
 
117
117
  The 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.
118
118
 
@@ -129,9 +129,9 @@ For use with **S3 bucket deployments**, classes implementing `s3deploy.ISource`
129
129
 
130
130
  - `TypeScriptSource` & `JavaScriptSource`
131
131
 
132
- > _Code and Source constructs seamlessly plugin to high-level CDK features. They share the same set of parameters, props and build options._
132
+ > _Code and Source constructs seamlessly plug-in to other high-level CDK constructs. They share the same set of parameters, props and build options._
133
133
 
134
- Underlying classes power the other features. You normally won't have to use them, but they are there if you need them:
134
+ The following classes power the other features. You normally won't have to use them, but they are there if you need them:
135
135
 
136
136
  - `TypeScriptAsset` & `JavaScriptAsset` implements `s3.Asset` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html)) \
137
137
  creates an asset uploaded to S3 which can be referenced by other constructs
@@ -139,21 +139,21 @@ Underlying classes power the other features. You normally won't have to use them
139
139
  - `EsbuildBundler` implements `core.BundlingOptions` ([reference](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.BundlingOptions.html)) \
140
140
  provides an interface for a _esbuild_ bundler wherever needed
141
141
 
142
- ## [API Reference](API.md)
142
+ ### [API Reference](API.md)
143
143
 
144
- Auto-generated reference for classes and structs. This information is also available within the code completion of your IDE.
144
+ Auto-generated reference for classes and structs. This information is also available as part of your IDE's code completion.
145
145
 
146
- ## Escape hatches
146
+ ### Escape hatches
147
147
 
148
- It's possible that you want to use a implementation of esbuild that's different to the default one. Common reasons are:
148
+ It's possible that you want to use an implementation of esbuild that's different to the default one. Common reasons are:
149
149
 
150
150
  - The current version constraints for esbuild are not suitable
151
- - To use version of esbuild that is installed by any other means than `npm`, including Docker
152
- - Plugin support is needed for the building
151
+ - To use a version of esbuild that is installed by any other means than `npm`, including Docker
152
+ - Plugin support is needed for building
153
153
 
154
154
  For these situations, this package offers an escape hatch to bypass regular the implementation and provide a custom build and transform function.
155
155
 
156
- ### Custom build function
156
+ #### Custom build function
157
157
 
158
158
  > 💡 See [Using esbuild with plugins](examples/esbuild-with-plugins) for a complete working example of a custom build function using this escape hatch.
159
159
 
@@ -175,7 +175,7 @@ Instead of esbuild, the provided function will be invoked with the calculated bu
175
175
 
176
176
  Failures have to cause a `BuildFailure` exception in order to be fully handled.
177
177
 
178
- ### Custom transform function
178
+ #### Custom transform function
179
179
 
180
180
  Constructs 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.
181
181
 
@@ -195,11 +195,11 @@ Instead of esbuild, the provided function will be invoked with the calculated tr
195
195
 
196
196
  Failures have to cause a `TransformFailure` exception in order to be fully handled.
197
197
 
198
- ## Migrating to v3
198
+ ### Migrating to v3
199
199
 
200
200
  The 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.
201
201
 
202
- ### Upgrading
202
+ #### Upgrading
203
203
 
204
204
  - 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.
205
205
  - Update the package dependency to v3: `npm install --save @mrgrain/cdk-esbuild@^3.0.0`
@@ -217,7 +217,7 @@ The release of cdk-esbuild v3 brings compatibility with AWS CDK v2. Furthermore
217
217
 
218
218
  ## Versioning
219
219
 
220
- 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`.
220
+ This 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`.
221
221
 
222
222
  ### Npm Tags
223
223
 
@@ -233,15 +233,15 @@ These tags also exist, but usage is strongly not recommended:
233
233
 
234
234
  - ~~`cdk-1.x.x`~~ tags have been deprecated in favour of `cdk-v1`. Use that one instead.
235
235
 
236
- ## Future releases
236
+ ## Roadmap & Contributions
237
237
 
238
- ### Stable esbuild
238
+ [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.
239
239
 
240
- 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.
240
+ All contributions are welcome, no matter if they are for already planned or completely new features.
241
241
 
242
242
  ## Library authors
243
243
 
244
- When 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):
244
+ Building 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):
245
245
 
246
246
  ```ts
247
247
  // file: project/src/index.ts
@@ -253,3 +253,5 @@ const props = {
253
253
  ```
254
254
 
255
255
  This will dynamically resolve to the correct path, wherever the package is installed.
256
+
257
+ Please open an issue if you encounter any difficulties.
package/lib/asset.d.ts CHANGED
@@ -16,14 +16,9 @@ export interface AssetBaseProps extends BundlerProps {
16
16
  */
17
17
  readonly assetHash?: string;
18
18
  }
19
- /**
20
- * @stability stable
21
- */
22
19
  export interface AssetProps extends AssetBaseProps {
23
20
  /**
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`.
21
+ * 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`.
27
22
  *
28
23
  * @stability stable
29
24
  */
@@ -59,3 +54,4 @@ export declare class JavaScriptAsset extends Asset<JavaScriptAssetProps> {
59
54
  export declare class TypeScriptAsset extends Asset<TypeScriptAssetProps> {
60
55
  }
61
56
  export {};
57
+ //# sourceMappingURL=asset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../src/asset.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAQ,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAkB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AAED,aAAK,oBAAoB,GAAG,UAAU,CAAC;AACvC,aAAK,oBAAoB,GAAG,UAAU,CAAC;AAEvC;;GAEG;AACH,uBAAe,KAAK,CAAC,KAAK,SAAS,UAAU,CAAE,SAAQ,OAAO;IAC5D;;OAEG;gBAED,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,KAAK;CA2Cf;AAED;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,KAAK,CAAC,oBAAoB,CAAC;CAAG;AAEnE;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,KAAK,CAAC,oBAAoB,CAAC;CAAG"}