From 3297e82ade6d49539dac98119dfc0ddf4adbdeeb Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Fri, 30 Jun 2023 11:39:26 +0200 Subject: [PATCH] fix(core): tags disappear if CDK library is bundled/minified Caused by a check for `constructor.name` which `esbuild` may rename. Replace with a checkable symbol. Closes #26169. --- packages/aws-cdk-lib/core/lib/tag-manager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/core/lib/tag-manager.ts b/packages/aws-cdk-lib/core/lib/tag-manager.ts index c2ef6ec60c3e7..af77f5bcfd6c2 100644 --- a/packages/aws-cdk-lib/core/lib/tag-manager.ts +++ b/packages/aws-cdk-lib/core/lib/tag-manager.ts @@ -3,6 +3,8 @@ import { CfnTag } from './cfn-tag'; import { Lazy } from './lazy'; import { IResolvable } from './resolvable'; +export const TAG_MANAGER_SYM = Symbol.for('@aws-cdk/core.TagManager'); + interface Tag { key: string; value: string; @@ -301,7 +303,7 @@ export class TagManager { */ public static isTaggable(construct: any): construct is ITaggable { const tags = (construct as any).tags; - return tags && typeof tags === 'object' && tags.constructor.name === 'TagManager'; + return tags && typeof tags === 'object' && (tags as any)[TAG_MANAGER_SYM]; } /** @@ -461,3 +463,4 @@ export class TagManager { } } } +(TagManager.prototype as any)[TAG_MANAGER_SYM] = true;