adrian-goe/nx-aws-cdk-v2

Using shared libraries within CDK app

Closed this issue · 3 comments

Hi @adrian-goe, thanks for this awesome plugin!

I'm trying to use a shared library that was generated by the NX workspace plugin within the CDK app but I'm unable to deploy the app due to a 'MODULE_NOT_FOUND' error that's produced when running the deploy command.

image

This is the AppStack that's generated by default:
image

As you can see, TypeScript detects the shared module without issues due to the configured paths in tsconfig.base.json at the root of the workspace directory.

Have you ever encountered anything like this, and if so, do you recommend any solutions?

Hi, thanks 😊

I haven't had this issue before. So I don't have an idea in my mind. Unfortunately I'm also unable to check this until next weekend.
But if you can't solve this issue until then, I will look into it! Have a nice day

Thanks, I'll try and investigate!

Found a fix. It's seems like the below needs to be added to the tsconfig.base.json located at the root of the workspace directory:

"ts-node": {
    "require": ["tsconfig-paths/register"]
}

This requires tsconfig-paths package to be installed as well.

Reference: https://stackoverflow.com/a/72622089

This allows me to reference a shared library within the CDK app generated by this plugin.