Skip to content

Commit 1f81718

Browse files
authored
fix(core): tags disappear if CDK app is bundled+minified (#26181)
Caused by a check for `constructor.name` which `esbuild` may rename. Replace with a checkable symbol. Closes #26169. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent fa3caf3 commit 1f81718

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/aws-cdk-lib/core/lib/tag-manager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { CfnTag } from './cfn-tag';
33
import { Lazy } from './lazy';
44
import { IResolvable } from './resolvable';
55

6+
const TAG_MANAGER_SYM = Symbol.for('@aws-cdk/core.TagManager');
7+
68
interface Tag {
79
key: string;
810
value: string;
@@ -301,7 +303,7 @@ export class TagManager {
301303
*/
302304
public static isTaggable(construct: any): construct is ITaggable {
303305
const tags = (construct as any).tags;
304-
return tags && typeof tags === 'object' && tags.constructor.name === 'TagManager';
306+
return tags && typeof tags === 'object' && (tags as any)[TAG_MANAGER_SYM];
305307
}
306308

307309
/**
@@ -461,3 +463,4 @@ export class TagManager {
461463
}
462464
}
463465
}
466+
(TagManager.prototype as any)[TAG_MANAGER_SYM] = true;

0 commit comments

Comments
 (0)