@aws-blocks/core 0.1.18 → 0.2.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/__fixtures__/import-meta-handler.d.ts +6 -0
- package/dist/cdk/__fixtures__/import-meta-handler.d.ts.map +1 -0
- package/dist/cdk/__fixtures__/import-meta-handler.js +13 -0
- package/dist/cdk/blocks-backend.d.ts +11 -0
- package/dist/cdk/blocks-backend.d.ts.map +1 -1
- package/dist/cdk/blocks-backend.js +22 -6
- package/dist/cdk/blocks-backend.test.js +66 -0
- package/dist/cdk/blocks-defaults.d.ts +44 -0
- package/dist/cdk/blocks-defaults.d.ts.map +1 -0
- package/dist/cdk/blocks-defaults.js +23 -0
- package/dist/cdk/blocks-defaults.test.d.ts +2 -0
- package/dist/cdk/blocks-defaults.test.d.ts.map +1 -0
- package/dist/cdk/blocks-defaults.test.js +22 -0
- package/dist/cdk/blocks-stack.test.js +8 -1
- package/dist/cdk/bundling.d.ts +42 -0
- package/dist/cdk/bundling.d.ts.map +1 -0
- package/dist/cdk/bundling.js +72 -0
- package/dist/cdk/bundling.test.d.ts +2 -0
- package/dist/cdk/bundling.test.d.ts.map +1 -0
- package/dist/cdk/bundling.test.js +80 -0
- package/dist/cdk/compute/compute.d.ts +33 -0
- package/dist/cdk/compute/compute.d.ts.map +1 -0
- package/dist/cdk/compute/compute.js +28 -0
- package/dist/cdk/index.d.ts +46 -7
- package/dist/cdk/index.d.ts.map +1 -1
- package/dist/cdk/index.js +84 -18
- package/dist/cdk/internal.d.ts +24 -0
- package/dist/cdk/internal.d.ts.map +1 -0
- package/dist/cdk/internal.js +27 -0
- package/dist/cdk/mixins.d.ts +18 -4
- package/dist/cdk/mixins.d.ts.map +1 -1
- package/dist/cdk/mixins.js +31 -7
- package/dist/cdk/mixins.test.js +45 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/index.cdk.d.ts +2 -1
- package/dist/index.cdk.d.ts.map +1 -1
- package/dist/index.cdk.js +2 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +12 -3
- package/dist/rpc.test.js +20 -0
- package/dist/scripts/telemetry.test.js +2 -0
- package/dist/telemetry/environment.d.ts.map +1 -1
- package/dist/telemetry/environment.js +3 -1
- package/dist/telemetry/telemetry.test.js +10 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
- package/src/cdk/__fixtures__/import-meta-handler.ts +16 -0
- package/src/cdk/blocks-backend.test.ts +76 -0
- package/src/cdk/blocks-backend.ts +35 -6
- package/src/cdk/blocks-defaults.test.ts +25 -0
- package/src/cdk/blocks-defaults.ts +49 -0
- package/src/cdk/blocks-stack.test.ts +8 -1
- package/src/cdk/bundling.test.ts +90 -0
- package/src/cdk/bundling.ts +76 -0
- package/src/cdk/compute/compute.ts +37 -0
- package/src/cdk/index.ts +94 -19
- package/src/cdk/internal.ts +29 -0
- package/src/cdk/mixins.test.ts +56 -1
- package/src/cdk/mixins.ts +32 -7
- package/src/common/index.ts +9 -0
- package/src/index.cdk.ts +5 -1
- package/src/rpc.test.ts +22 -0
- package/src/rpc.ts +19 -3
- package/src/scripts/telemetry.test.ts +2 -0
- package/src/telemetry/environment.ts +3 -1
- package/src/telemetry/telemetry.test.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-meta-handler.d.ts","sourceRoot":"","sources":["../../../src/cdk/__fixtures__/import-meta-handler.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,SAAS,QAAiC,CAAC;AAGxD,eAAO,MAAM,OAAO;;;EAAyE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Repro fixture for the "handler bundles to CJS but uses import.meta.url" bug.
|
|
4
|
+
//
|
|
5
|
+
// The handler is bundled to CJS by NodejsFunction. In a CJS bundle `import.meta`
|
|
6
|
+
// is empty, so this top-level `fileURLToPath(import.meta.url)` would become
|
|
7
|
+
// `fileURLToPath(undefined)` and throw at Lambda load. blocksNodejsBundling shims
|
|
8
|
+
// `import.meta.url` to a CommonJS equivalent, so the bundle loads and resolves a
|
|
9
|
+
// real path instead of crashing — see bundling.test.ts.
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
export const moduleDir = fileURLToPath(import.meta.url);
|
|
12
|
+
// Reference moduleDir so esbuild can't tree-shake the import.meta.url usage away.
|
|
13
|
+
export const handler = async () => ({ statusCode: 200, body: JSON.stringify({ moduleDir }) });
|
|
@@ -2,6 +2,7 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
2
2
|
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
|
|
3
3
|
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
4
4
|
import { Construct } from 'constructs';
|
|
5
|
+
import type { BlocksDefaults } from './blocks-defaults.js';
|
|
5
6
|
/**
|
|
6
7
|
* Validate that the Node.js process was started with `--conditions=cdk`.
|
|
7
8
|
*
|
|
@@ -14,6 +15,14 @@ export declare function assertCdkConditionActive(): void;
|
|
|
14
15
|
export interface BlocksBackendProps {
|
|
15
16
|
backendHandlerPath: string;
|
|
16
17
|
backendCDKPath: string;
|
|
18
|
+
/**
|
|
19
|
+
* Stack-wide infrastructure defaults applied to every Building Block (removal
|
|
20
|
+
* policy, deletion protection, …). See {@link BlocksDefaults}. Start from
|
|
21
|
+
* `BlocksPresets.sandbox` or `BlocksPresets.production` and override
|
|
22
|
+
* individual fields as needed. A per-block option always wins over the
|
|
23
|
+
* corresponding stack default.
|
|
24
|
+
*/
|
|
25
|
+
defaults: BlocksDefaults;
|
|
17
26
|
}
|
|
18
27
|
/** Shared infra setup — creates Lambda + API Gateway on the given scope. */
|
|
19
28
|
export declare function setupBlocksInfra(scope: Construct, props: BlocksBackendProps, id?: string): {
|
|
@@ -46,6 +55,8 @@ export declare class BlocksBackend extends Construct {
|
|
|
46
55
|
readonly backendHandlerPath: string;
|
|
47
56
|
/** Shared IAM role assumed by all Blocks compute. Building Blocks grant to this role. */
|
|
48
57
|
readonly executionRole: iam.IRole;
|
|
58
|
+
/** Infrastructure defaults for Building Blocks created under this backend. */
|
|
59
|
+
readonly defaults: BlocksDefaults;
|
|
49
60
|
/**
|
|
50
61
|
* The fullId used by child Scopes to compute their env var names,
|
|
51
62
|
* construct IDs, and physical resource names (e.g., DynamoDB table names).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks-backend.d.ts","sourceRoot":"","sources":["../../src/cdk/blocks-backend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"blocks-backend.d.ts","sourceRoot":"","sources":["../../src/cdk/blocks-backend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAkB/C;AAED,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,CAAC,EAAE,MAAM;;;;;EAyIxF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;IAC5C,SAAgB,OAAO,EAAE,GAAG,CAAC,iBAAiB,CAAC,cAAc,CAAC;IAC9D,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,yFAAyF;IACzF,SAAgB,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC;IACzC,8EAA8E;IAC9E,SAAgB,QAAQ,EAAE,cAAc,CAAC;IAEzC;;;;;;;;;;;;;;;;;;OAkBG;IACH,IAAI,MAAM,IAAI,MAAM,CAUnB;IAED,OAAO;WAyBM,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB;CAsB5E"}
|
|
@@ -8,6 +8,7 @@ import { CfnGroup } from 'aws-cdk-lib/aws-resourcegroups';
|
|
|
8
8
|
import { Construct } from 'constructs';
|
|
9
9
|
import { pathToFileURL } from 'node:url';
|
|
10
10
|
import { DEFAULT_NODE_RUNTIME } from './node-version.js';
|
|
11
|
+
import { blocksNodejsBundling } from './bundling.js';
|
|
11
12
|
import { addBlocksStackMetadata } from './stack-metadata.js';
|
|
12
13
|
import { finalizeConfigRegistry, registerConfig } from './config-registry.js';
|
|
13
14
|
import { BLOCKS_NAMESPACE, BLOCKS_RPC_PREFIX } from '../constants.js';
|
|
@@ -36,14 +37,20 @@ export function assertCdkConditionActive() {
|
|
|
36
37
|
}
|
|
37
38
|
/** Shared infra setup — creates Lambda + API Gateway on the given scope. */
|
|
38
39
|
export function setupBlocksInfra(scope, props, id) {
|
|
40
|
+
// Fail fast with an actionable message at the create() call site if `defaults`
|
|
41
|
+
// is missing (e.g. a plain-JS caller, `as any`, or a dynamically-built props
|
|
42
|
+
// object) — otherwise the first Building Block to read `scope.defaults` throws
|
|
43
|
+
// a cryptic `Cannot read properties of undefined (reading 'removalPolicy')`.
|
|
44
|
+
if (!props.defaults) {
|
|
45
|
+
throw new Error('BlocksStack/BlocksBackend requires a `defaults` field. Pass a posture from ' +
|
|
46
|
+
'`@aws-blocks/core/cdk` — typically `defaults: sandboxMode ? BlocksPresets.sandbox : BlocksPresets.production`.');
|
|
47
|
+
}
|
|
39
48
|
// ── Shared execution role ──────────────────────────────────────────────
|
|
40
49
|
// A single IAM role that every Building Block grants to. Provisioned here so
|
|
41
50
|
// it exists before the backend module is imported (Building Blocks reach it
|
|
42
51
|
// via `scope.executionRole`). Block grants sit on the role's default (inline)
|
|
43
|
-
// policy
|
|
44
|
-
//
|
|
45
|
-
// AWSLambdaBasicExecutionRole is attached explicitly because the auto-role
|
|
46
|
-
// included it by default — omitting it would silently break CloudWatch Logs.
|
|
52
|
+
// policy. AWSLambdaBasicExecutionRole is attached so the handler retains
|
|
53
|
+
// CloudWatch Logs permissions.
|
|
47
54
|
const executionRole = new iam.Role(scope, 'BlocksRole', {
|
|
48
55
|
// CompositePrincipal (rather than a bare ServicePrincipal) so additional
|
|
49
56
|
// compute types can assume this same shared role as they are introduced
|
|
@@ -73,10 +80,13 @@ export function setupBlocksInfra(scope, props, id) {
|
|
|
73
80
|
*/
|
|
74
81
|
BLOCKS_STACK_NAME: id ?? cdk.Stack.of(scope).stackName,
|
|
75
82
|
},
|
|
76
|
-
|
|
83
|
+
// blocksNodejsBundling shims import.meta.* to CommonJS equivalents so a
|
|
84
|
+
// CJS-bundled `fileURLToPath(import.meta.url)` resolves instead of throwing at
|
|
85
|
+
// Lambda load. See ./bundling.ts.
|
|
86
|
+
bundling: blocksNodejsBundling({
|
|
77
87
|
minify: true,
|
|
78
88
|
esbuildArgs: { '--conditions': 'aws-runtime' },
|
|
79
|
-
},
|
|
89
|
+
}),
|
|
80
90
|
});
|
|
81
91
|
// In sandbox mode, allow localhost origins so the local dev frontend can
|
|
82
92
|
// reach the deployed Lambda API via CORS.
|
|
@@ -171,6 +181,8 @@ export class BlocksBackend extends Construct {
|
|
|
171
181
|
backendHandlerPath;
|
|
172
182
|
/** Shared IAM role assumed by all Blocks compute. Building Blocks grant to this role. */
|
|
173
183
|
executionRole;
|
|
184
|
+
/** Infrastructure defaults for Building Blocks created under this backend. */
|
|
185
|
+
defaults;
|
|
174
186
|
/**
|
|
175
187
|
* The fullId used by child Scopes to compute their env var names,
|
|
176
188
|
* construct IDs, and physical resource names (e.g., DynamoDB table names).
|
|
@@ -206,6 +218,10 @@ export class BlocksBackend extends Construct {
|
|
|
206
218
|
this.backendHandlerPath = props.backendHandlerPath;
|
|
207
219
|
// Expose self to Building Blocks at CDK time
|
|
208
220
|
globalThis.CURRENT_BLOCKS_STACK = this;
|
|
221
|
+
// Store defaults on the backend (not the stack) so several BlocksBackends
|
|
222
|
+
// in one stack each keep their own posture; Building Blocks resolve them by
|
|
223
|
+
// walking up to their owning backend (see Scope.defaults).
|
|
224
|
+
this.defaults = props.defaults;
|
|
209
225
|
const infra = setupBlocksInfra(this, props, id);
|
|
210
226
|
this.handler = infra.handler;
|
|
211
227
|
this.gateway = infra.gateway;
|
|
@@ -8,6 +8,7 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
8
8
|
import { Template, Match } from 'aws-cdk-lib/assertions';
|
|
9
9
|
import { PolicyStatement } from 'aws-cdk-lib/aws-iam';
|
|
10
10
|
import { BlocksBackend } from './blocks-backend.js';
|
|
11
|
+
import { BlocksPresets } from './blocks-defaults.js';
|
|
11
12
|
import { Scope } from './index.js';
|
|
12
13
|
// Simulate the CDK condition being active (tests import CDK files directly)
|
|
13
14
|
before(() => {
|
|
@@ -19,6 +20,7 @@ const sideEffectBackendPath = join(__dirname, '__fixtures__', 'side-effect-backe
|
|
|
19
20
|
const factoryBackendPath = join(__dirname, '__fixtures__', 'factory-backend.js');
|
|
20
21
|
const fullIdConstructBackendPath = join(__dirname, '__fixtures__', 'fullid-construct-backend.js');
|
|
21
22
|
const EXECUTION_ROLE_MARKER_ACTION = 'blocks-test:MarkerAction';
|
|
23
|
+
const importMetaHandlerPath = join(__dirname, '__fixtures__', 'import-meta-handler.js');
|
|
22
24
|
describe('ESM cache-busting (multi-stage)', () => {
|
|
23
25
|
test('BlocksBackend.create() with same backendCDKPath but different IDs produces constructs in each', async () => {
|
|
24
26
|
const app = new cdk.App();
|
|
@@ -26,10 +28,12 @@ describe('ESM cache-busting (multi-stage)', () => {
|
|
|
26
28
|
const backend1 = await BlocksBackend.create(stack, 'Stage1', {
|
|
27
29
|
backendHandlerPath: handlerPath,
|
|
28
30
|
backendCDKPath: sideEffectBackendPath,
|
|
31
|
+
defaults: BlocksPresets.production,
|
|
29
32
|
});
|
|
30
33
|
const backend2 = await BlocksBackend.create(stack, 'Stage2', {
|
|
31
34
|
backendHandlerPath: handlerPath,
|
|
32
35
|
backendCDKPath: sideEffectBackendPath,
|
|
36
|
+
defaults: BlocksPresets.production,
|
|
33
37
|
});
|
|
34
38
|
const findMarker = (scope) => scope.node.tryFindChild('SideEffectMarker');
|
|
35
39
|
assert.ok(findMarker(backend1), 'Stage1 backend should have SideEffectMarker construct from module side effect');
|
|
@@ -43,6 +47,7 @@ describe('synth shape (drop into existing stack)', () => {
|
|
|
43
47
|
const backend = await BlocksBackend.create(parent, 'Blocks', {
|
|
44
48
|
backendHandlerPath: handlerPath,
|
|
45
49
|
backendCDKPath: sideEffectBackendPath,
|
|
50
|
+
defaults: BlocksPresets.production,
|
|
46
51
|
});
|
|
47
52
|
// Public surface mirrors BlocksStack.
|
|
48
53
|
assert.ok(backend.handler, 'BlocksBackend should expose .handler');
|
|
@@ -60,10 +65,12 @@ describe('synth shape (drop into existing stack)', () => {
|
|
|
60
65
|
await BlocksBackend.create(parent, 'BackendA', {
|
|
61
66
|
backendHandlerPath: handlerPath,
|
|
62
67
|
backendCDKPath: sideEffectBackendPath,
|
|
68
|
+
defaults: BlocksPresets.production,
|
|
63
69
|
});
|
|
64
70
|
await BlocksBackend.create(parent, 'BackendB', {
|
|
65
71
|
backendHandlerPath: handlerPath,
|
|
66
72
|
backendCDKPath: sideEffectBackendPath,
|
|
73
|
+
defaults: BlocksPresets.production,
|
|
67
74
|
});
|
|
68
75
|
const template = Template.fromStack(parent);
|
|
69
76
|
template.resourceCountIs('AWS::ApiGateway::RestApi', 2);
|
|
@@ -76,6 +83,7 @@ describe('shared execution role', () => {
|
|
|
76
83
|
const backend = await BlocksBackend.create(parent, 'Blocks', {
|
|
77
84
|
backendHandlerPath: handlerPath,
|
|
78
85
|
backendCDKPath: sideEffectBackendPath,
|
|
86
|
+
defaults: BlocksPresets.production,
|
|
79
87
|
});
|
|
80
88
|
assert.ok(backend.executionRole, 'BlocksBackend should expose .executionRole');
|
|
81
89
|
});
|
|
@@ -85,6 +93,7 @@ describe('shared execution role', () => {
|
|
|
85
93
|
await BlocksBackend.create(parent, 'Blocks', {
|
|
86
94
|
backendHandlerPath: handlerPath,
|
|
87
95
|
backendCDKPath: sideEffectBackendPath,
|
|
96
|
+
defaults: BlocksPresets.production,
|
|
88
97
|
});
|
|
89
98
|
const template = Template.fromStack(parent);
|
|
90
99
|
// The shared role (logical id derived from the 'BlocksRole' construct id)
|
|
@@ -113,6 +122,7 @@ describe('shared execution role', () => {
|
|
|
113
122
|
const backend = await BlocksBackend.create(parent, 'Blocks', {
|
|
114
123
|
backendHandlerPath: handlerPath,
|
|
115
124
|
backendCDKPath: sideEffectBackendPath,
|
|
125
|
+
defaults: BlocksPresets.production,
|
|
116
126
|
});
|
|
117
127
|
// Build nested Scopes under the backend (outer → inner), the same shape a
|
|
118
128
|
// real Building Block tree has, and grant a uniquely-named marker action to
|
|
@@ -136,6 +146,23 @@ describe('shared execution role', () => {
|
|
|
136
146
|
});
|
|
137
147
|
});
|
|
138
148
|
});
|
|
149
|
+
describe('CJS bundle: import.meta.url in the handler is shimmed (no Lambda-load crash)', () => {
|
|
150
|
+
test('a handler that uses import.meta.url bundles successfully instead of throwing at load', async () => {
|
|
151
|
+
// The handler is bundled to CJS, where `import.meta` is empty. Left unshimmed,
|
|
152
|
+
// `fileURLToPath(import.meta.url)` compiles to `fileURLToPath(undefined)` and
|
|
153
|
+
// throws at Lambda load (esbuild only warns, so the broken bundle would deploy).
|
|
154
|
+
// blocksNodejsBundling shims import.meta.* to CommonJS equivalents, so bundling
|
|
155
|
+
// (which runs synchronously during construction) succeeds. The runtime behaviour
|
|
156
|
+
// of the emitted shim is verified directly in bundling.test.ts.
|
|
157
|
+
const app = new cdk.App();
|
|
158
|
+
const stack = new cdk.Stack(app, 'ImportMetaStack');
|
|
159
|
+
await assert.doesNotReject(() => BlocksBackend.create(stack, 'blocks', {
|
|
160
|
+
backendHandlerPath: importMetaHandlerPath,
|
|
161
|
+
backendCDKPath: sideEffectBackendPath,
|
|
162
|
+
defaults: BlocksPresets.production,
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
});
|
|
139
166
|
describe('factory function support', () => {
|
|
140
167
|
test('BlocksBackend.create() calls default export function with the backend instance', async () => {
|
|
141
168
|
const app = new cdk.App();
|
|
@@ -143,6 +170,7 @@ describe('factory function support', () => {
|
|
|
143
170
|
const backend = await BlocksBackend.create(stack, 'FactoryStage', {
|
|
144
171
|
backendHandlerPath: handlerPath,
|
|
145
172
|
backendCDKPath: factoryBackendPath,
|
|
173
|
+
defaults: BlocksPresets.production,
|
|
146
174
|
});
|
|
147
175
|
const marker = backend.node.tryFindChild('FactoryMarker');
|
|
148
176
|
assert.ok(marker, 'Factory function should have created FactoryMarker on the backend');
|
|
@@ -155,6 +183,7 @@ describe('fullId is token-free (construct IDs / env-var keys)', () => {
|
|
|
155
183
|
const backend = await BlocksBackend.create(stack, 'blocks', {
|
|
156
184
|
backendHandlerPath: handlerPath,
|
|
157
185
|
backendCDKPath: sideEffectBackendPath,
|
|
186
|
+
defaults: BlocksPresets.production,
|
|
158
187
|
});
|
|
159
188
|
assert.strictEqual(backend.fullId, 'TopLevelStack-blocks');
|
|
160
189
|
assert.ok(!cdk.Token.isUnresolved(backend.fullId), 'fullId must not contain a token');
|
|
@@ -172,6 +201,7 @@ describe('fullId is token-free (construct IDs / env-var keys)', () => {
|
|
|
172
201
|
const backend = await BlocksBackend.create(nested, 'blocks', {
|
|
173
202
|
backendHandlerPath: handlerPath,
|
|
174
203
|
backendCDKPath: sideEffectBackendPath,
|
|
204
|
+
defaults: BlocksPresets.production,
|
|
175
205
|
});
|
|
176
206
|
assert.ok(!cdk.Token.isUnresolved(backend.fullId), `fullId must be token-free inside a nested stack, got: ${backend.fullId}`);
|
|
177
207
|
// Falls back to the top-level (concrete) stack name, keeping uniqueness.
|
|
@@ -186,6 +216,7 @@ describe('fullId is token-free (construct IDs / env-var keys)', () => {
|
|
|
186
216
|
const backend = await BlocksBackend.create(nested, 'blocks', {
|
|
187
217
|
backendHandlerPath: handlerPath,
|
|
188
218
|
backendCDKPath: fullIdConstructBackendPath,
|
|
219
|
+
defaults: BlocksPresets.production,
|
|
189
220
|
});
|
|
190
221
|
// The construct ID is `${scope.fullId}Marker` → `ParentStack-blocks-blocks-dbMarker`.
|
|
191
222
|
const expectedId = `${backend.fullId}-dbMarker`;
|
|
@@ -206,6 +237,7 @@ describe('fullId is token-free (construct IDs / env-var keys)', () => {
|
|
|
206
237
|
const backend = await BlocksBackend.create(nested, 'blocks', {
|
|
207
238
|
backendHandlerPath: handlerPath,
|
|
208
239
|
backendCDKPath: sideEffectBackendPath,
|
|
240
|
+
defaults: BlocksPresets.production,
|
|
209
241
|
});
|
|
210
242
|
const template = Template.fromStack(nested);
|
|
211
243
|
const fns = template.findResources('AWS::Lambda::Function');
|
|
@@ -219,3 +251,37 @@ describe('fullId is token-free (construct IDs / env-var keys)', () => {
|
|
|
219
251
|
}
|
|
220
252
|
});
|
|
221
253
|
});
|
|
254
|
+
describe('infrastructure defaults (backend-anchored)', () => {
|
|
255
|
+
test('each backend exposes its own defaults', async () => {
|
|
256
|
+
const app = new cdk.App();
|
|
257
|
+
const stack = new cdk.Stack(app, 'TwoBackendsStack');
|
|
258
|
+
const a = await BlocksBackend.create(stack, 'A', {
|
|
259
|
+
backendHandlerPath: handlerPath,
|
|
260
|
+
backendCDKPath: sideEffectBackendPath,
|
|
261
|
+
defaults: BlocksPresets.production,
|
|
262
|
+
});
|
|
263
|
+
const b = await BlocksBackend.create(stack, 'B', {
|
|
264
|
+
backendHandlerPath: handlerPath,
|
|
265
|
+
backendCDKPath: sideEffectBackendPath,
|
|
266
|
+
defaults: BlocksPresets.sandbox,
|
|
267
|
+
});
|
|
268
|
+
// Two backends in one stack must NOT clobber each other — defaults are
|
|
269
|
+
// anchored on the backend, not the shared stack.
|
|
270
|
+
assert.strictEqual(a.defaults, BlocksPresets.production);
|
|
271
|
+
assert.strictEqual(b.defaults, BlocksPresets.sandbox);
|
|
272
|
+
});
|
|
273
|
+
test('a nested block resolves its owning backend defaults via the tree-walk', async () => {
|
|
274
|
+
const app = new cdk.App();
|
|
275
|
+
const stack = new cdk.Stack(app, 'ResolveDefaultsStack');
|
|
276
|
+
const backend = await BlocksBackend.create(stack, 'Blocks', {
|
|
277
|
+
backendHandlerPath: handlerPath,
|
|
278
|
+
backendCDKPath: sideEffectBackendPath,
|
|
279
|
+
defaults: BlocksPresets.sandbox,
|
|
280
|
+
});
|
|
281
|
+
// A Scope under the backend resolves scope.defaults by walking up to it.
|
|
282
|
+
const outer = new Scope('outer');
|
|
283
|
+
const inner = new Scope('inner', { parent: outer });
|
|
284
|
+
assert.strictEqual(inner.defaults, backend.defaults);
|
|
285
|
+
assert.strictEqual(inner.defaults, BlocksPresets.sandbox);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RemovalPolicy } from 'aws-cdk-lib';
|
|
2
|
+
/**
|
|
3
|
+
* Default values for every Amazon-authored Building Block created within a
|
|
4
|
+
* `BlocksStack` or `BlocksBackend`. A per-block option always overrides the
|
|
5
|
+
* corresponding default (`option ?? scope.defaults.field`).
|
|
6
|
+
*
|
|
7
|
+
* Start from {@link BlocksPresets} and override individual fields as needed.
|
|
8
|
+
*/
|
|
9
|
+
export interface BlocksDefaults {
|
|
10
|
+
/**
|
|
11
|
+
* What happens to a stateful resource (table, bucket, user pool) when the
|
|
12
|
+
* stack is deleted, via CDK/CloudFormation: `RETAIN` keeps the resource (and
|
|
13
|
+
* its data) behind; `DESTROY` tears it down. Applies only to CDK/CloudFormation
|
|
14
|
+
* deletions.
|
|
15
|
+
*/
|
|
16
|
+
removalPolicy: RemovalPolicy;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to block deletion of a stateful resource. Unlike `removalPolicy`,
|
|
19
|
+
* this guards against deletion through **any** path — CDK/CloudFormation as
|
|
20
|
+
* well as the CLI, API, and AWS console — until it is turned off.
|
|
21
|
+
*/
|
|
22
|
+
deletionProtection: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Prepared starting points for {@link BlocksDefaults}. Pick one and override
|
|
26
|
+
* individual fields with a spread:
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* defaults: { ...BlocksPresets.production, deletionProtection: false }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const BlocksPresets: {
|
|
33
|
+
/** Disposable development stacks: tear down cleanly, no delete guard. */
|
|
34
|
+
sandbox: {
|
|
35
|
+
removalPolicy: RemovalPolicy.DESTROY;
|
|
36
|
+
deletionProtection: false;
|
|
37
|
+
};
|
|
38
|
+
/** Durable, protected posture for permanent deployments. */
|
|
39
|
+
production: {
|
|
40
|
+
removalPolicy: RemovalPolicy.RETAIN;
|
|
41
|
+
deletionProtection: true;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=blocks-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks-defaults.d.ts","sourceRoot":"","sources":["../../src/cdk/blocks-defaults.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;OAKG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;;;OAIG;IACH,kBAAkB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;IACzB,yEAAyE;;;;;IAKzE,4DAA4D;;;;;CAKnB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { RemovalPolicy } from 'aws-cdk-lib';
|
|
4
|
+
/**
|
|
5
|
+
* Prepared starting points for {@link BlocksDefaults}. Pick one and override
|
|
6
|
+
* individual fields with a spread:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* defaults: { ...BlocksPresets.production, deletionProtection: false }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export const BlocksPresets = {
|
|
13
|
+
/** Disposable development stacks: tear down cleanly, no delete guard. */
|
|
14
|
+
sandbox: {
|
|
15
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
16
|
+
deletionProtection: false,
|
|
17
|
+
},
|
|
18
|
+
/** Durable, protected posture for permanent deployments. */
|
|
19
|
+
production: {
|
|
20
|
+
removalPolicy: RemovalPolicy.RETAIN,
|
|
21
|
+
deletionProtection: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks-defaults.test.d.ts","sourceRoot":"","sources":["../../src/cdk/blocks-defaults.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
/**
|
|
4
|
+
* BlocksPresets carry the expected posture. Resolution/anchoring (a block
|
|
5
|
+
* reading its owning backend's defaults, and two backends in one stack keeping
|
|
6
|
+
* separate postures) is covered in blocks-backend.test.ts, which has the
|
|
7
|
+
* fixtures to construct real backends.
|
|
8
|
+
*/
|
|
9
|
+
import { test, describe } from 'node:test';
|
|
10
|
+
import assert from 'node:assert';
|
|
11
|
+
import { RemovalPolicy } from 'aws-cdk-lib';
|
|
12
|
+
import { BlocksPresets } from './blocks-defaults.js';
|
|
13
|
+
describe('BlocksPresets', () => {
|
|
14
|
+
test('sandbox is disposable: DESTROY + deletion protection off', () => {
|
|
15
|
+
assert.strictEqual(BlocksPresets.sandbox.removalPolicy, RemovalPolicy.DESTROY);
|
|
16
|
+
assert.strictEqual(BlocksPresets.sandbox.deletionProtection, false);
|
|
17
|
+
});
|
|
18
|
+
test('production is durable: RETAIN + deletion protection on', () => {
|
|
19
|
+
assert.strictEqual(BlocksPresets.production.removalPolicy, RemovalPolicy.RETAIN);
|
|
20
|
+
assert.strictEqual(BlocksPresets.production.deletionProtection, true);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
7
|
import * as cdk from 'aws-cdk-lib';
|
|
8
8
|
import { BlocksBackend } from './blocks-backend.js';
|
|
9
|
-
import { BlocksStack, Scope } from './index.js';
|
|
9
|
+
import { BlocksStack, BlocksPresets, Scope } from './index.js';
|
|
10
10
|
// Simulate the CDK condition being active (tests import CDK files directly)
|
|
11
11
|
before(() => {
|
|
12
12
|
process.env.NODE_OPTIONS = (process.env.NODE_OPTIONS ?? '') + ' --conditions=cdk';
|
|
@@ -21,10 +21,12 @@ describe('ESM cache-busting (multi-stage)', () => {
|
|
|
21
21
|
const stack1 = await BlocksStack.create(app, 'PipelineStage1', {
|
|
22
22
|
backendHandlerPath: handlerPath,
|
|
23
23
|
backendCDKPath: sideEffectBackendPath,
|
|
24
|
+
defaults: BlocksPresets.production,
|
|
24
25
|
});
|
|
25
26
|
const stack2 = await BlocksStack.create(app, 'PipelineStage2', {
|
|
26
27
|
backendHandlerPath: handlerPath,
|
|
27
28
|
backendCDKPath: sideEffectBackendPath,
|
|
29
|
+
defaults: BlocksPresets.production,
|
|
28
30
|
});
|
|
29
31
|
const findMarker = (scope) => scope.node.tryFindChild('SideEffectMarker');
|
|
30
32
|
assert.ok(findMarker(stack1), 'First stack should have SideEffectMarker from module side effect');
|
|
@@ -37,6 +39,7 @@ describe('factory function support', () => {
|
|
|
37
39
|
const stack = await BlocksStack.create(app, 'FactoryBlocksStack', {
|
|
38
40
|
backendHandlerPath: handlerPath,
|
|
39
41
|
backendCDKPath: factoryBackendPath,
|
|
42
|
+
defaults: BlocksPresets.production,
|
|
40
43
|
});
|
|
41
44
|
const marker = stack.node.tryFindChild('FactoryMarker');
|
|
42
45
|
assert.ok(marker, 'Factory function should have created FactoryMarker on the stack');
|
|
@@ -49,6 +52,7 @@ describe('legacy side-effect mode (no default export)', () => {
|
|
|
49
52
|
const backend = await BlocksBackend.create(stack, 'LegacyStage', {
|
|
50
53
|
backendHandlerPath: handlerPath,
|
|
51
54
|
backendCDKPath: sideEffectBackendPath,
|
|
55
|
+
defaults: BlocksPresets.production,
|
|
52
56
|
});
|
|
53
57
|
const marker = backend.node.tryFindChild('SideEffectMarker');
|
|
54
58
|
assert.ok(marker, 'Side-effect-only module should register construct via globalThis.CURRENT_BLOCKS_STACK');
|
|
@@ -64,6 +68,7 @@ describe('shared execution role (BlocksStack)', () => {
|
|
|
64
68
|
const stack = await BlocksStack.create(app, 'StackRoleStack', {
|
|
65
69
|
backendHandlerPath: handlerPath,
|
|
66
70
|
backendCDKPath: sideEffectBackendPath,
|
|
71
|
+
defaults: BlocksPresets.production,
|
|
67
72
|
});
|
|
68
73
|
assert.ok(stack.executionRole, 'BlocksStack should expose a populated .executionRole');
|
|
69
74
|
});
|
|
@@ -74,6 +79,7 @@ describe('executionRole globalThis fallback', () => {
|
|
|
74
79
|
const stack = await BlocksStack.create(app, 'FallbackStack', {
|
|
75
80
|
backendHandlerPath: handlerPath,
|
|
76
81
|
backendCDKPath: sideEffectBackendPath,
|
|
82
|
+
defaults: BlocksPresets.production,
|
|
77
83
|
});
|
|
78
84
|
// A Scope whose construct-tree ancestry has no BlocksStack/BlocksBackend
|
|
79
85
|
// (parented under a plain cdk.Stack) exhausts the tree-walk and falls back
|
|
@@ -96,6 +102,7 @@ describe('assertCdkConditionActive', () => {
|
|
|
96
102
|
await assert.rejects(BlocksStack.create(app, 'MissingConditionStack', {
|
|
97
103
|
backendHandlerPath: handlerPath,
|
|
98
104
|
backendCDKPath: sideEffectBackendPath,
|
|
105
|
+
defaults: BlocksPresets.production,
|
|
99
106
|
}), (err) => {
|
|
100
107
|
assert.ok(err.message.includes('Missing --conditions=cdk'), `Expected condition error, got: ${err.message}`);
|
|
101
108
|
return true;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type BundlingOptions } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
2
|
+
/**
|
|
3
|
+
* Wrap a `NodejsFunction` `bundling` config with the framework's hardened esbuild
|
|
4
|
+
* defaults, so every Lambda the framework bundles behaves consistently.
|
|
5
|
+
*
|
|
6
|
+
* **What it fixes.** `NodejsFunction` bundles to **CommonJS**, where `import.meta` is
|
|
7
|
+
* empty. Any bundled code that does `fileURLToPath(import.meta.url)` (a customer
|
|
8
|
+
* handler, a Building Block's `aws-runtime` code, or a dependency) would otherwise
|
|
9
|
+
* become `fileURLToPath(undefined)` and throw at Lambda load — esbuild only *warns*
|
|
10
|
+
* (`empty-import-meta`), so the broken bundle deploys and 502s on first invocation.
|
|
11
|
+
*
|
|
12
|
+
* **How.** For CJS output this shims `import.meta.url` / `import.meta.dirname` /
|
|
13
|
+
* `import.meta.filename` to their CommonJS equivalents (`pathToFileURL(__filename)`,
|
|
14
|
+
* `__dirname`, `__filename`) via an esbuild `--define` + `banner`. This is the same
|
|
15
|
+
* approach esbuild blesses (defining `import.meta` also suppresses the warning) and
|
|
16
|
+
* that Rollup applies by default, so:
|
|
17
|
+
* - a handler that reads `import.meta.url` no longer crashes at load, and
|
|
18
|
+
* - a bundled dependency that merely *contains* `import.meta` (even in dead code) no
|
|
19
|
+
* longer trips a build failure.
|
|
20
|
+
*
|
|
21
|
+
* The value resolves to the **bundled output file** (esbuild flattens the module tree),
|
|
22
|
+
* which is correct for the common cases — a value computed at synth (e.g. a
|
|
23
|
+
* `migrationsPath`) or dead interop fallbacks — but note it does not point at your
|
|
24
|
+
* source layout. Runtime code that must read a file relative to itself should not rely
|
|
25
|
+
* on `import.meta.url` inside a bundle; resolve such paths at synth time or ship the
|
|
26
|
+
* file as an asset. ESM output (`OutputFormat.ESM`) supports `import.meta` natively and
|
|
27
|
+
* is left untouched.
|
|
28
|
+
*
|
|
29
|
+
* All other options (`minify`, `commandHooks`, `externalModules`, other `esbuildArgs`
|
|
30
|
+
* such as `--conditions`, and any caller `banner`) are preserved.
|
|
31
|
+
*
|
|
32
|
+
* @param options - The site-specific `NodejsFunction` bundling options (optional).
|
|
33
|
+
* @returns The same options with the CJS `import.meta` shim merged in.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* new lambda.NodejsFunction(scope, 'Handler', {
|
|
37
|
+
* entry,
|
|
38
|
+
* bundling: blocksNodejsBundling({ minify: true, esbuildArgs: { '--conditions': 'aws-runtime' } }),
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
41
|
+
export declare function blocksNodejsBundling(options?: BundlingOptions): BundlingOptions;
|
|
42
|
+
//# sourceMappingURL=bundling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundling.d.ts","sourceRoot":"","sources":["../../src/cdk/bundling.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AASnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,eAAoB,GAAG,eAAe,CAwBnF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { OutputFormat } from 'aws-cdk-lib/aws-lambda-nodejs';
|
|
4
|
+
/** Banner-defined identifiers the shim substitutes `import.meta.*` with (CJS only). */
|
|
5
|
+
const IMPORT_META_SHIM = {
|
|
6
|
+
url: '__blocksImportMetaUrl',
|
|
7
|
+
dirname: '__blocksImportMetaDirname',
|
|
8
|
+
filename: '__blocksImportMetaFilename',
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a `NodejsFunction` `bundling` config with the framework's hardened esbuild
|
|
12
|
+
* defaults, so every Lambda the framework bundles behaves consistently.
|
|
13
|
+
*
|
|
14
|
+
* **What it fixes.** `NodejsFunction` bundles to **CommonJS**, where `import.meta` is
|
|
15
|
+
* empty. Any bundled code that does `fileURLToPath(import.meta.url)` (a customer
|
|
16
|
+
* handler, a Building Block's `aws-runtime` code, or a dependency) would otherwise
|
|
17
|
+
* become `fileURLToPath(undefined)` and throw at Lambda load — esbuild only *warns*
|
|
18
|
+
* (`empty-import-meta`), so the broken bundle deploys and 502s on first invocation.
|
|
19
|
+
*
|
|
20
|
+
* **How.** For CJS output this shims `import.meta.url` / `import.meta.dirname` /
|
|
21
|
+
* `import.meta.filename` to their CommonJS equivalents (`pathToFileURL(__filename)`,
|
|
22
|
+
* `__dirname`, `__filename`) via an esbuild `--define` + `banner`. This is the same
|
|
23
|
+
* approach esbuild blesses (defining `import.meta` also suppresses the warning) and
|
|
24
|
+
* that Rollup applies by default, so:
|
|
25
|
+
* - a handler that reads `import.meta.url` no longer crashes at load, and
|
|
26
|
+
* - a bundled dependency that merely *contains* `import.meta` (even in dead code) no
|
|
27
|
+
* longer trips a build failure.
|
|
28
|
+
*
|
|
29
|
+
* The value resolves to the **bundled output file** (esbuild flattens the module tree),
|
|
30
|
+
* which is correct for the common cases — a value computed at synth (e.g. a
|
|
31
|
+
* `migrationsPath`) or dead interop fallbacks — but note it does not point at your
|
|
32
|
+
* source layout. Runtime code that must read a file relative to itself should not rely
|
|
33
|
+
* on `import.meta.url` inside a bundle; resolve such paths at synth time or ship the
|
|
34
|
+
* file as an asset. ESM output (`OutputFormat.ESM`) supports `import.meta` natively and
|
|
35
|
+
* is left untouched.
|
|
36
|
+
*
|
|
37
|
+
* All other options (`minify`, `commandHooks`, `externalModules`, other `esbuildArgs`
|
|
38
|
+
* such as `--conditions`, and any caller `banner`) are preserved.
|
|
39
|
+
*
|
|
40
|
+
* @param options - The site-specific `NodejsFunction` bundling options (optional).
|
|
41
|
+
* @returns The same options with the CJS `import.meta` shim merged in.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* new lambda.NodejsFunction(scope, 'Handler', {
|
|
45
|
+
* entry,
|
|
46
|
+
* bundling: blocksNodejsBundling({ minify: true, esbuildArgs: { '--conditions': 'aws-runtime' } }),
|
|
47
|
+
* });
|
|
48
|
+
*/
|
|
49
|
+
export function blocksNodejsBundling(options = {}) {
|
|
50
|
+
// ESM output has real `import.meta` — nothing to shim, and `require` in the banner
|
|
51
|
+
// wouldn't resolve. Only the CommonJS bundle needs the shim.
|
|
52
|
+
if (options.format === OutputFormat.ESM)
|
|
53
|
+
return options;
|
|
54
|
+
const shimBanner = [
|
|
55
|
+
`const ${IMPORT_META_SHIM.url}=require('url').pathToFileURL(__filename).href;`,
|
|
56
|
+
`const ${IMPORT_META_SHIM.dirname}=__dirname;`,
|
|
57
|
+
`const ${IMPORT_META_SHIM.filename}=__filename;`,
|
|
58
|
+
].join('');
|
|
59
|
+
return {
|
|
60
|
+
...options,
|
|
61
|
+
// Prepend the shim definitions; keep any caller-supplied banner after them.
|
|
62
|
+
banner: options.banner ? `${shimBanner}\n${options.banner}` : shimBanner,
|
|
63
|
+
esbuildArgs: {
|
|
64
|
+
...options.esbuildArgs,
|
|
65
|
+
// Substitute import.meta.* with the banner identifiers. Also suppresses esbuild's
|
|
66
|
+
// empty-import-meta warning, so import.meta anywhere in the graph is safe.
|
|
67
|
+
'--define:import.meta.url': IMPORT_META_SHIM.url,
|
|
68
|
+
'--define:import.meta.dirname': IMPORT_META_SHIM.dirname,
|
|
69
|
+
'--define:import.meta.filename': IMPORT_META_SHIM.filename,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundling.test.d.ts","sourceRoot":"","sources":["../../src/cdk/bundling.test.ts"],"names":[],"mappings":""}
|