-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External libraries in v0.33.0 throwing ${instance} does not implement DependableTrait
#2713
External libraries in v0.33.0 throwing ${instance} does not implement DependableTrait
#2713
Comments
Confirming this issue. |
This will affect any L3 framework/library since they will have a nested dependency on Instead of using a WeakMap to track an object's implementation, how about we store the trait on the object with an explicitly named Symbol? // change implement to:
public static implement(instance: IDependable, trait: DependableTrait) {
(instance as any)[Symbol.for('@aws-cdk/cdk/DependableTrait')] = trait;
}
// change get to:
public static get(instance: IDependable): DependableTrait {
const ret = (instance as any)[Symbol.for('@aws-cdk/cdk/DependableTrait')];
if (!ret) {
throw new Error(`${instance} does not implement DependableTrait`);
}
return ret;
} |
The issue is still present in v0.34.0 too. |
${instance} does not implement DependableTrait
${instance} does not implement DependableTrait
I can confirm it is still an issue in |
yes same here, still present in 0.34.0 |
Out of curiosity @joshlartz - in your cdk library with the helper functions, how are you defining your dependency on the cdk packages? Through the |
@skinny85 All the cdk packages are regular |
@rix0rrr, what do you think of the suggestion of @sam-goodwin? I'm kinda stuck at |
The use of the WeakMap caused difficulties for construct library authors, because they could occasionally operate on a different instance of the @aws-cdk/cdk library. Fixes #2713
I'm not sure how we end up in the situation where we have 2 different copies of the CDK core library. I thought our use of peerDependencies was supposed to (help) prevent that. |
The use of the WeakMap caused difficulties for construct library authors, because they could occasionally operate on a different instance of the @aws-cdk/cdk library. Fixes #2713
Describe the bug
I've got a few import helper functions I'm pulling in from a cdk library and getting some unexpected behavior trying to make it work on v0.33. If I move the functions into the same lib/stack.ts file they're being called from it works as expected.
From debugging, this error is thrown after the stack is processed.
To Reproduce
app lib/stack.ts
library lib/context-providers/vpcs.ts
library lib/context-providers/ecs.ts
cdk ls or diff
Expected behavior
The external functions should resolve like normal and allow the stack to be built and diff/ls commands to work.
Version:
The text was updated successfully, but these errors were encountered: