From 4011448280b6adaab42800d35cd107838911fe13 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Mon, 21 Mar 2022 12:08:49 +0100 Subject: [PATCH] fix(core): Aspects from symlinked modules are not applied When construct libraries are purposely symlinked (as opposed of collectively `npm install`ed), depending on how this is done they may end up with multiple copies of `aws-cdk-lib`. If that happens, Aspects from a different `aws-cdk-lib` copy than the one providing `App` will not be applied. The reason is the use of `Symbol('...')` instead of `Symbol.for('...')` to keep the list of aspects on the construct object. - The first version creates a unique symbol per library, while adding a naming hint. - The second version deduplicates: all symbols with the same naming hint will receive the same symbol. The second version is necessary to make sure that different copies of the `aws-cdk-lib` library store their aspects under the same key. Fixes #18921, #18778, #19390. --- packages/@aws-cdk/core/lib/aspect.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/core/lib/aspect.ts b/packages/@aws-cdk/core/lib/aspect.ts index bde33e6724e9e..98a8cd977aaeb 100644 --- a/packages/@aws-cdk/core/lib/aspect.ts +++ b/packages/@aws-cdk/core/lib/aspect.ts @@ -1,6 +1,6 @@ import { IConstruct } from './construct-compat'; -const ASPECTS_SYMBOL = Symbol('cdk-aspects'); +const ASPECTS_SYMBOL = Symbol.for('cdk-aspects'); /** * Represents an Aspect