@sssb/cdk 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/sssb-app.js +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sssb/cdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,11 +26,11 @@
26
26
  "peerDependencies": {
27
27
  "aws-cdk-lib": "^2.274.0",
28
28
  "constructs": "^10.8.1",
29
- "@sssb/tools": "0.6.0"
29
+ "@sssb/tools": "0.7.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "aws-cdk-lib": "^2.274.0",
33
33
  "constructs": "^10.8.1",
34
- "@sssb/tools": "0.6.0"
34
+ "@sssb/tools": "0.7.0"
35
35
  }
36
36
  }
package/src/sssb-app.js CHANGED
@@ -245,6 +245,13 @@ export const HSTS_MAX_AGE_SECONDS = 31_536_000
245
245
  /** AWS's managed SecurityHeadersPolicy (CloudFront's guide, "Use managed response headers policies"). */
246
246
  export const MANAGED_SECURITY_HEADERS_POLICY_ID = '67f7725c-6f97-4210-82d7-5512b31e9d03'
247
247
 
248
+ /**
249
+ * The first line of the Migrator's ESM bundle: a `require` for the CommonJS code esbuild inlines. Under its own name, so
250
+ * a bundled module's `createRequire` import cannot collide with it.
251
+ */
252
+ const MIGRATOR_REQUIRE_BANNER =
253
+ "import { createRequire as __sssbCreateRequire } from 'node:module'; const require = __sssbCreateRequire(import.meta.url);"
254
+
248
255
  /** After every tag aspect: CDK's own run at `AspectPriority.MUTATING` (200) or the default (500). */
249
256
  const MIRROR_PRIORITY = 900
250
257
 
@@ -577,6 +584,10 @@ export class SssbApp extends Construct {
577
584
  : { DATABASE_TRANSPORT: 'pg', DB_SECRET_ARN: secret.secretArn, DATABASE_NAME: databaseName },
578
585
  bundling: {
579
586
  format: aws_lambda_nodejs.OutputFormat.ESM,
587
+ // An ESM bundle has no `require`, and esbuild's stand-in for the CommonJS packages it inlines (`pg`,
588
+ // whose `require('events')` runs when the handler module loads, on either transport) throws "Dynamic
589
+ // require of ... is not supported". So the bundle defines one, Node's own, for its own path.
590
+ banner: MIGRATOR_REQUIRE_BANNER,
580
591
  // pg's optional native/cloudflare shims must stay external or esbuild chokes
581
592
  externalModules: ['@aws-sdk/*', 'pg-native', 'cloudflare:sockets'],
582
593
  esbuildArgs: { '--alias:@sssb/app-config': migratorSource.seamDir },