https://pulumi.com logo
Title
m

magnificent-lifeguard-15082

11/28/2021, 10:32 PM
Is there any way to make pulumi less greedy when it comes to collecting properties from exported objects? I understand why it would happen but it's not ideal that even
private
properties on classes (in ts) end up in output. I had hoped
registerOutputs
might give pulumi some more sense as to what should actually be exported but alas, it does not. Context: exporting reference to a ComponentResource instance.
l

little-cartoon-10569

11/28/2021, 11:09 PM
Generally: don't export objects from the Pulumi program.
g

green-school-95910

11/29/2021, 10:44 AM
The
private
flag is just a TS thing. It doesn't affect anything at runtime. Try the new
#
prefix that is a real private field for JS https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields
But I would still not generally export entire instances, make an object just with the properties you want to export:
export const componentFoo = {
  propA: foo.propA,
  propB: foo.propB,
};
I prefer this way, but you can try the
#
field (I never tried, but I think it should work)
m

magnificent-lifeguard-15082

11/29/2021, 11:14 AM
Yeah that makes sense. Though honestly the Component was actually the unit of composition and encapsulation I was hoping I could use as "what should be shared".
Feel like it might fit in with the scope of a component to more explicitly define it's output interface. Will try find time and draft a feature proposal
l

little-cartoon-10569

11/29/2021, 7:50 PM
I don't think it would be feasible. Too much happens in ComponentResource constructors. It's unlikely that a stack reference could construct a ComponentResource without side effects.
And you certainly wouldn't want the resource to be constructed in two projects / stacks.