@mrgrain/cdk-esbuild 3.3.0 → 4.0.0-alpha.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
@@ -19,7 +19,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
19
19
 
20
20
  // Project info
21
21
  name: '@mrgrain/cdk-esbuild',
22
- repositoryUrl: 'git@github.com:mrgrain/cdk-esbuild.git',
22
+ repositoryUrl: 'https://github.com/mrgrain/cdk-esbuild',
23
23
  description:
24
24
  'CDK constructs for esbuild, an extremely fast JavaScript bundler',
25
25
  homepage: 'https://github.com/mrgrain/cdk-esbuild',
@@ -58,22 +58,21 @@ 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
72
64
  packageManager: javascript.NodePackageManager.NPM,
73
- npmDistTag: 'latest',
74
- defaultReleaseBranch: 'main',
75
- majorVersion: 3,
76
- releaseTrigger: release.ReleaseTrigger.manual(),
65
+ npmDistTag: 'next',
66
+ defaultReleaseBranch: 'support-other-langs',
67
+ majorVersion: 4,
68
+ prerelease: 'alpha',
69
+ releaseTrigger: release.ReleaseTrigger.scheduled({
70
+ schedule: '0 17 * * *',
71
+ }),
72
+ publishToPypi: {
73
+ module: 'mrgrain.cdk-esbuild',
74
+ distName: 'mrgrain.cdk_esbuild',
75
+ },
77
76
  catalog: {
78
77
  twitter: '@mrgrain',
79
78
  },
@@ -85,14 +84,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
85
84
 
86
85
  // Dependencies
87
86
  cdkVersion: '2.0.0',
88
- peerDeps: [
89
- 'aws-cdk-lib@^2.0.0',
90
- ],
91
87
  devDeps: [
92
- '@aws-cdk/aws-synthetics-alpha',
88
+ '@aws-cdk/aws-synthetics-alpha@2.0.0-alpha.11',
93
89
  '@types/eslint',
94
- 'aws-cdk-lib@2.0.0',
95
- 'constructs@10.0.5',
96
90
  'esbuild@^0.14.0',
97
91
  'jest-mock',
98
92
  'ts-morph',
@@ -106,7 +100,6 @@ const project = new awscdk.AwsCdkConstructLibrary({
106
100
  'cdk.out',
107
101
  '.cdk.staging',
108
102
  'examples/template',
109
- '!/.github/workflows/manual-release.yml',
110
103
  '!/examples/**',
111
104
  ],
112
105
  npmignore: [
@@ -124,6 +117,17 @@ const project = new awscdk.AwsCdkConstructLibrary({
124
117
  ],
125
118
  });
126
119
 
120
+ // release only via manual trigger
121
+ project.tryFindObjectFile('.github/workflows/release.yml')?.addOverride('on', 'workflow_dispatch');
122
+
123
+ // eslint
124
+ project.eslint?.allowDevDeps('projenrc/**');
125
+ project.eslint?.addRules({
126
+ '@typescript-eslint/member-ordering': 'off',
127
+ });
128
+ project.eslint?.addIgnorePattern('examples/');
129
+ project.eslint?.addIgnorePattern('!projenrc/*.ts');
130
+
127
131
 
128
132
  // VSCode config
129
133
  new JsonFile(project, '.vscode/extensions.json', {
@@ -167,10 +171,6 @@ project.tryFindObjectFile('package.json')?.addOverride('optionalDependencies', {
167
171
  esbuild: '^0.14.0',
168
172
  });
169
173
 
170
- project.eslint?.addRules({
171
- '@typescript-eslint/member-ordering': 'off',
172
- });
173
-
174
174
  new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
175
175
  source: 'node_modules/esbuild/lib/main.d.ts',
176
176
  editGitignore: false,
@@ -191,6 +191,7 @@ new TypeScriptSourceFile(project, 'src/esbuild-types.ts', {
191
191
  esbuildTypes.getInterface('CommonOptions')?.getProperty('mangleProps')?.setType('any');
192
192
  esbuildTypes.getInterface('CommonOptions')?.getProperty('reserveProps')?.setType('any');
193
193
  esbuildTypes.getInterface('TransformOptions')?.getProperty('tsconfigRaw')?.setType('string');
194
+ esbuildTypes.getInterface('InitializeOptions')?.getProperty('wasmModule')?.setType('any');
194
195
  },
195
196
  });
196
197
 
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
@@ -805,15 +830,15 @@ public readonly buildOptions: BuildOptions;
805
830
 
806
831
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
807
832
 
808
- `buildOptions.outdir: string`
833
+ * `buildOptions.outdir: string`
809
834
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
810
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. \
811
836
  *Cannot be used together with `outfile`*.
812
- - `buildOptions.outfile: string`
837
+ * `buildOptions.outfile: string`
813
838
  Relative path to a file inside the CDK asset output directory.
814
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. \
815
840
  *Cannot be used with multiple entryPoints or together with `outdir`.*
816
- - `buildOptions.absWorkingDir: string`
841
+ * `buildOptions.absWorkingDir: string`
817
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). \
818
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).
819
844
 
@@ -824,14 +849,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
824
849
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.BundlerProps.property.copyDir"></a>
825
850
 
826
851
  ```typescript
827
- public readonly copyDir: string;
852
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
828
853
  ```
829
854
 
830
- - *Type:* `string`
855
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
831
856
 
832
- 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.
833
858
 
834
- 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 `..`.
835
873
 
836
874
  ---
837
875
 
@@ -893,15 +931,15 @@ public readonly buildOptions: BuildOptions;
893
931
 
894
932
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
895
933
 
896
- `buildOptions.outdir: string`
934
+ * `buildOptions.outdir: string`
897
935
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
898
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. \
899
937
  *Cannot be used together with `outfile`*.
900
- - `buildOptions.outfile: string`
938
+ * `buildOptions.outfile: string`
901
939
  Relative path to a file inside the CDK asset output directory.
902
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. \
903
941
  *Cannot be used with multiple entryPoints or together with `outdir`.*
904
- - `buildOptions.absWorkingDir: string`
942
+ * `buildOptions.absWorkingDir: string`
905
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). \
906
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).
907
945
 
@@ -912,14 +950,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
912
950
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptCodeProps.property.copyDir"></a>
913
951
 
914
952
  ```typescript
915
- public readonly copyDir: string;
953
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
916
954
  ```
917
955
 
918
- - *Type:* `string`
956
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
919
957
 
920
- Copy additional files to the output directory, before the build runs.
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.
921
959
 
922
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
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.
962
+
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 `..`.
923
974
 
924
975
  ---
925
976
 
@@ -975,15 +1026,15 @@ public readonly buildOptions: BuildOptions;
975
1026
 
976
1027
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
977
1028
 
978
- `buildOptions.outdir: string`
1029
+ * `buildOptions.outdir: string`
979
1030
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
980
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. \
981
1032
  *Cannot be used together with `outfile`*.
982
- - `buildOptions.outfile: string`
1033
+ * `buildOptions.outfile: string`
983
1034
  Relative path to a file inside the CDK asset output directory.
984
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. \
985
1036
  *Cannot be used with multiple entryPoints or together with `outdir`.*
986
- - `buildOptions.absWorkingDir: string`
1037
+ * `buildOptions.absWorkingDir: string`
987
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). \
988
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).
989
1040
 
@@ -994,14 +1045,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
994
1045
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.JavaScriptSourceProps.property.copyDir"></a>
995
1046
 
996
1047
  ```typescript
997
- public readonly copyDir: string;
1048
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
998
1049
  ```
999
1050
 
1000
- - *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.
1001
1054
 
1002
- 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.
1003
1057
 
1004
- 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 `..`.
1005
1069
 
1006
1070
  ---
1007
1071
 
@@ -1271,6 +1335,18 @@ Documentation: https://esbuild.github.io/api/#log-limit.
1271
1335
 
1272
1336
  ---
1273
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
+
1274
1350
  ##### `mangleCache`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TransformOptions.property.mangleCache"></a>
1275
1351
 
1276
1352
  ```typescript
@@ -1495,15 +1571,15 @@ public readonly buildOptions: BuildOptions;
1495
1571
 
1496
1572
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
1497
1573
 
1498
- `buildOptions.outdir: string`
1574
+ * `buildOptions.outdir: string`
1499
1575
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
1500
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. \
1501
1577
  *Cannot be used together with `outfile`*.
1502
- - `buildOptions.outfile: string`
1578
+ * `buildOptions.outfile: string`
1503
1579
  Relative path to a file inside the CDK asset output directory.
1504
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. \
1505
1581
  *Cannot be used with multiple entryPoints or together with `outdir`.*
1506
- - `buildOptions.absWorkingDir: string`
1582
+ * `buildOptions.absWorkingDir: string`
1507
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). \
1508
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).
1509
1585
 
@@ -1514,14 +1590,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
1514
1590
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptCodeProps.property.copyDir"></a>
1515
1591
 
1516
1592
  ```typescript
1517
- public readonly copyDir: string;
1593
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
1518
1594
  ```
1519
1595
 
1520
- - *Type:* `string`
1596
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
1521
1597
 
1522
- 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.
1523
1599
 
1524
- 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 `..`.
1525
1614
 
1526
1615
  ---
1527
1616
 
@@ -1577,15 +1666,15 @@ public readonly buildOptions: BuildOptions;
1577
1666
 
1578
1667
  Build options passed on to esbuild. Please refer to the esbuild Build API docs for details.
1579
1668
 
1580
- `buildOptions.outdir: string`
1669
+ * `buildOptions.outdir: string`
1581
1670
  The actual path for the output directory is defined by CDK. However setting this option allows to write files into a subdirectory. \
1582
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. \
1583
1672
  *Cannot be used together with `outfile`*.
1584
- - `buildOptions.outfile: string`
1673
+ * `buildOptions.outfile: string`
1585
1674
  Relative path to a file inside the CDK asset output directory.
1586
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. \
1587
1676
  *Cannot be used with multiple entryPoints or together with `outdir`.*
1588
- - `buildOptions.absWorkingDir: string`
1677
+ * `buildOptions.absWorkingDir: string`
1589
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). \
1590
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).
1591
1680
 
@@ -1596,14 +1685,27 @@ If paths cannot be found, a good starting point is to look at the concatenation
1596
1685
  ##### `copyDir`<sup>Optional</sup> <a name="@mrgrain/cdk-esbuild.TypeScriptSourceProps.property.copyDir"></a>
1597
1686
 
1598
1687
  ```typescript
1599
- public readonly copyDir: string;
1688
+ public readonly copyDir: string | string[] | {[ key: string ]: string | string[]};
1600
1689
  ```
1601
1690
 
1602
- - *Type:* `string`
1691
+ - *Type:* `string` | `string`[] | {[ key: string ]: `string` | `string`[]}
1603
1692
 
1604
- Copy additional files to the output directory, before the build runs.
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.
1605
1694
 
1606
- Files copied like this will be overwritten by esbuild if they share the same name as any of the outputs.
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.
1697
+
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 `..`.
1607
1709
 
1608
1710
  ---
1609
1711