@emarketeer/ts-microservice-commons 10.2.0 → 10.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdk/cjs/index.js +18 -9
- package/dist/cdk/cjs/index.js.map +1 -1
- package/dist/cdk/index.js +19 -10
- package/dist/cdk/index.js.map +1 -1
- package/dist/handler-bundler.js +43 -9
- package/dist/types/cdk/utils/bundling.d.ts +22 -2
- package/package.json +1 -1
package/dist/cdk/cjs/index.js
CHANGED
|
@@ -10,13 +10,13 @@ var constructs = require('constructs');
|
|
|
10
10
|
var awsSsm = require('aws-cdk-lib/aws-ssm');
|
|
11
11
|
var path = require('path');
|
|
12
12
|
var fs = require('fs');
|
|
13
|
+
var crypto = require('crypto');
|
|
13
14
|
var child_process = require('child_process');
|
|
14
15
|
var awsDynamodb = require('aws-cdk-lib/aws-dynamodb');
|
|
15
16
|
var awsApigateway = require('aws-cdk-lib/aws-apigateway');
|
|
16
17
|
var awsApigatewayv2 = require('aws-cdk-lib/aws-apigatewayv2');
|
|
17
18
|
var awsApigatewayv2Integrations = require('aws-cdk-lib/aws-apigatewayv2-integrations');
|
|
18
19
|
var awsCertificatemanager = require('aws-cdk-lib/aws-certificatemanager');
|
|
19
|
-
var crypto = require('crypto');
|
|
20
20
|
var awsSqs = require('aws-cdk-lib/aws-sqs');
|
|
21
21
|
var awsSns = require('aws-cdk-lib/aws-sns');
|
|
22
22
|
var awsSnsSubscriptions = require('aws-cdk-lib/aws-sns-subscriptions');
|
|
@@ -518,7 +518,7 @@ function getHandlerBundlerPath() {
|
|
|
518
518
|
const cwd = process.cwd();
|
|
519
519
|
const candidates = [
|
|
520
520
|
path__namespace.join(cwd, 'node_modules', PACKAGE_NAME, HANDLER_BUNDLER_RELATIVE_PATH),
|
|
521
|
-
path__namespace.join(cwd, HANDLER_BUNDLER_RELATIVE_PATH)
|
|
521
|
+
path__namespace.join(cwd, HANDLER_BUNDLER_RELATIVE_PATH),
|
|
522
522
|
];
|
|
523
523
|
for (const candidate of candidates) {
|
|
524
524
|
if (fs__namespace.existsSync(candidate)) {
|
|
@@ -536,8 +536,11 @@ function getHandlerBundlerPath() {
|
|
|
536
536
|
* - Otherwise bundles `entryFile` via the project handler bundler at synth
|
|
537
537
|
* time, with overrides applied on top of the defaults.
|
|
538
538
|
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
539
|
+
* An explicit `assetHash` is derived from the entry path + bundling overrides.
|
|
540
|
+
* Without it, multiple handlers under the same source directory (the common
|
|
541
|
+
* `src/handlers/` layout) would share an asset — CDK would run `tryBundle`
|
|
542
|
+
* once and reuse that asset for every other lambda, silently dropping
|
|
543
|
+
* per-function overrides. The explicit hash gives each handler a unique asset.
|
|
541
544
|
*/
|
|
542
545
|
function resolveLambdaCode(options) {
|
|
543
546
|
if (options.codePath) {
|
|
@@ -552,8 +555,14 @@ function resolveLambdaCode(options) {
|
|
|
552
555
|
}
|
|
553
556
|
const overrides = options.bundling;
|
|
554
557
|
const bundlerPath = getHandlerBundlerPath();
|
|
558
|
+
const handlerName = path__namespace.basename(entry, path__namespace.extname(entry));
|
|
559
|
+
const hash = crypto.createHash('sha256')
|
|
560
|
+
.update(entry)
|
|
561
|
+
.update(JSON.stringify(overrides ?? {}))
|
|
562
|
+
.digest('hex');
|
|
563
|
+
const assetHash = `${handlerName}-${hash}`;
|
|
555
564
|
return awsLambda.Code.fromAsset(path__namespace.dirname(entry), {
|
|
556
|
-
|
|
565
|
+
assetHash,
|
|
557
566
|
bundling: {
|
|
558
567
|
// CDK requires `image` even when local bundling succeeds. We never use
|
|
559
568
|
// the Docker fallback — `tryBundle` always returns true.
|
|
@@ -563,12 +572,12 @@ function resolveLambdaCode(options) {
|
|
|
563
572
|
const stdin = JSON.stringify({ entry, outDir: outputDir, overrides });
|
|
564
573
|
child_process.execFileSync('node', [bundlerPath], {
|
|
565
574
|
input: stdin,
|
|
566
|
-
stdio: ['pipe', 'inherit', 'inherit']
|
|
575
|
+
stdio: ['pipe', 'inherit', 'inherit'],
|
|
567
576
|
});
|
|
568
577
|
return true;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
},
|
|
572
581
|
});
|
|
573
582
|
}
|
|
574
583
|
|