-
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
[core] Multiple projects breaks CDK synth (using instanceof cross-project) #10977
Comments
BTW. I tried to fix this issue by replacing
But that kind of blew up the tests in core Test result after
Maybe someone with more in-depth experience with the core package can see what is going on. |
This seems to be the same problem but the issue is closed: #10210 (comment) |
I think this just flat-out won't work, and Lerna isn't smart enough to do it. Yarn will hoist the modules appropriately. Otherwise you're going to have to declare a dependency on CDK in |
I understand that CDK, as a project, does not want to fix the dependency problems with npm/lerna. Totally understandable. Still, this will most likely become a problem lots of people will face in the future, when their CDK projects gets bigger and they need to rearrange their source code into separate projects. @rix0rrr would it be interesting to have a section in the developer guide for organising bigger CDK projects? What is the best way to proceed with this? |
#11113 will most likely fix this issue (still needs to be confirmed when CDK 1.72.0 is released) |
For future reference, when people face this issue: I created a new branch use_lerna_yarn_workspaces testing @rix0rrr suggestion using yarn hoisting. It works... but please read this before choosing this path: https://rushjs.io/pages/advanced/phantom_deps/ For our project we chose another path, using Rush instead of lerna/yarn. The switch is not a not small task for a big project, but the dependency handling solutions seems so much better, we figured it was worth it. See this branch: try_with_rush for a minimal example of what is required and that it actually works. Note I will close this issue because I don't expect any solution to be found within the CDK project. |
|
❓ General Issue
Creating a Construct, shared by multiple stacks, in a separate project, fails to deploy in CDK version >= 1.57.0
In our setup we have multiple stacks sharing misc. Constructs. These Constructs are all in separate Typescript/NodeJS projects.
We use Lerna to maintain/link dependencies between projects.
A simplified example of the structure could be:
(an example can be found here: https://github.com/gwriss/upgrade_bug)
Running
will npm-install all dependencies and link projects like this (snipped for better overview):
Now, when the Construct in
myconstruct
contains a Lambda Function and the Myapp inmyapp
instantiate an instance of Myconstruct, the synth of the app fails:(an example of the setup can be found and tested here: https://github.com/gwriss/upgrade_bug)
Diving into the problem, it seems like it's another issue with
instanceof
comparing two instances of the same class, but from differentnode_modules
.I think @tneely was onto something in #9546 (comment), but decided to close the issue without a resolution.
Another issued related to this is the "Duck Typing" fix of Stack in #10671.
Please don't pollute the discussion with suggestions about "deleting node_modules & reinstall" and "checking modules are all of the same version".
That is another issue but has nothing to do with this issue!
The Question
Did I miss som crucial point in our preferred project setup? I would really like a discussion about the recommended way of organising bigger CDK apps/projects. This could hopefully lead to a new topic in developer guide.
@rix0rrr suggest a peerDependency solution for a similar problem here: 5e10b94
but I fail to see how this would solve the problem. (please enlighten me if I missed something 😃 )
At the moment this is a show-stopper for our long-overdue upgrade of CDK
Reference
Environment
Other information
The text was updated successfully, but these errors were encountered: