This message was deleted.
# general
s
This message was deleted.
c
@average-receptionist-65239 hard to say for sure, but usually this is usually a problem with the way JS/TS imports work. if you import but don’t use anything from a file then any resource definitions in there don’t get used.
a
Hm, okay. I put that import back, of course. I continued work by adding another resource in a separate module and importing it into my
index.ts
file. I had a similar experience where the Pulumi wants to delete 7 resources. If I place the new resource in one of my existing modules, then it works fine!
c
sorry, just to be clear—you have to import and also reference something from that file. otherwise the file does not get evaluated.
a
Yes, I understood you but I checked some of my existing modules and I don't export anything from them. I just expected them to get evaluated for their side effects (i.e.
new
some k8s resource). Quite a few of my existing modules to do not export anything. My index.ts looks something like:
Copy code
import * as pulumi from "@pulumi/pulumi";

export * from "./namespace";
export * from "./credentials"
export * from "./tls";
export * from "./serviceA";
export * from "./serviceB";
export * from "./cronJobA;
export * from "./cronJobB";
Occasionally, I do export from those resource modules for debugging/learning purposes. Something like:
Copy code
export const serviceaURN = serviceA.urn;
As I have gotten comfortable with Pulumi, I've been removing these exported constants.
When I add
export const useMe = 1;
to the top of every module, then everything seems fine. I can add my new module and Pulumi doesn't want to delete my old resources.
However, I can rollback to a point where
pulumi preview --expect-no-changes
succeeds. Then, I remove the
kx
import in my
index.ts
and then
pulumi preview --expect-no-changes
fails with the deletion of 7 resources.
Interestingly, the only resource that isn't scheduled for deletion is the namespace which still exports a couple of constants:
Copy code
export const namespaceNameX = namespace.metadata.name;
export const namespaceNameURN = namespace.urn;
So, it's a pretty surprising situation. Perhaps I'm running into an optimisation in TypeScript that only triggers when you hit a certain number of modules or top-level definitions or something.
I'm finding a lot of discussion here https://github.com/Microsoft/TypeScript/issues/9191.
Thanks for your help @creamy-potato-29402, I was about to give up 🙂. I'm on the Australian east coast, so last night when I was working on this, many folks on this channel were sleeping 🙂
c
@average-receptionist-65239 if you do figure it out I’d love to know what happened. I only ran into this once when I worked at pulumi and it drove me crazy for a few hours. 🙂
or if you have a small reproduction I could spend a couple minutes looking
a
Switching to
import "./serviceA"
for all modules that do not export anything works. This is the official TypeScript way to import for side-effects, AFAICS. The strange part is why, up to this point, the
export * from "./serviceA"
was working. I'll see if I can work up a small repro over the weekend.
c
oh that makes sense.