Skip to content

Commit

Permalink
fix(core): Aspects from symlinked modules are not applied
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rix0rrr committed Mar 21, 2022
1 parent e6b414f commit 4011448
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 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
Expand Down

0 comments on commit 4011448

Please sign in to comment.