Skip to content

Commit

Permalink
fix(core): tags disappear if CDK app is bundled+minified (#26181)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
rix0rrr authored Jul 3, 2023
1 parent fa3caf3 commit 1f81718
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/core/lib/tag-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { CfnTag } from './cfn-tag';
import { Lazy } from './lazy';
import { IResolvable } from './resolvable';

const TAG_MANAGER_SYM = Symbol.for('@aws-cdk/core.TagManager');

interface Tag {
key: string;
value: string;
Expand Down Expand Up @@ -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];
}

/**
Expand Down Expand Up @@ -461,3 +463,4 @@ export class TagManager {
}
}
}
(TagManager.prototype as any)[TAG_MANAGER_SYM] = true;

0 comments on commit 1f81718

Please sign in to comment.