I want to make a shared library that I use across ...
# general
m
I want to make a shared library that I use across all pulumi projects. So I have a file like:
Copy code
import * as aws from "@pulumi/aws";

export function newRdsCpu(...) {
  new aws.cloudwatch.MetricAlarm(...);
}
I am hoping to import it with something like
import * as alarms from "../../pulumi-shared/alarms";
but when I do, I get
Cannot find module '@pulumi/aws'
If I add a
package.json
to
pulumi-shared
with
@pulumi/aws
in it then it works… but I don’t really want that file as an independent library. It should use the
@pulumi/aws
of whatever library is calling it. Does anyone have any suggestions for how to proceed? I am searching lots of TypeScript on how to import files from outside the root dir, but so far not having any luck.
a
I believe this is called a peer dependency in TS.
m
Cool, I will look into that, thank you!