crd2pulumi icon indicating copy to clipboard operation
crd2pulumi copied to clipboard

Typescript dependencies

Open maxemann96 opened this issue 8 months ago • 2 comments

What happened?

Typescript dependencies are possibly broken. The genrated code mixes dev and normal dependencies (for example @types/node-fetch should be a dev dependency.

Also I wonder why these dependencies are even included. Shouldn't it be enough to just include @pulumi/kubernetes and @pulumi/pulumi as before (in 1.4.0)?

Example

I pinned k8s and pulumi dep, rest is produced as output from crd2pulumi

[
  ...
  "dependencies": {
    "@pulumi/kubernetes": "4.23.0",
    "@pulumi/pulumi": "3.190.0",
    "@types/node-fetch": "^2.1.4",
    "@types/tmp": "^0.2.0",
    "glob": "^10.3.10",
    "node-fetch": "^2.3.0",
    "shell-quote": "^1.6.1",
    "tmp": "^0.2.0"
  },
  "devDependencies": {
    "@types/mocha": "^5.2.5",
    "@types/shell-quote": "^1.6.0",
    "mocha": "^5.2.0"
  }
]

Output of pulumi about

CLI
Version 3.190.0 Go Version go1.24.6 Go Compiler gc

Host
OS arch Version "rolling" Arch x86_64

crd2pulumi version: v1.5.4, manually installed from releases binary

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

maxemann96 avatar Aug 20 '25 14:08 maxemann96

Hi @maxemann96, just to confirm you're asking out the typescript dependencies of the generated SDKs, right?

The SDK is actually generated using the same logic we use for the pulumi-kubernetes provider, so you end up getting its same dependencies https://github.com/pulumi/pulumi-kubernetes/blob/6dbf4eb9efc405e7c310e30ac4e0b24bfd148a92/provider/pkg/gen/schema.go#L618-L633

This is admittedly a bit awkward/unnecessary. Is this causing version incompatibility issues for you, or anything like that?

If you have suggestions for how to improve the dependencies we can definitely look into it. I'm not sure why those types aren't dev dependencies like you pointed out.

blampe avatar Aug 21 '25 18:08 blampe

Hey @blampe, thanks for looking into my issue.

Yes, I'm referencing the typescript dependencies of the crd2pulumi generated sdk output.

So actually this produces 2 issues for me:

  1. Unnecessary dependencies
  2. Actual dev dependencies not listed in dev dependencies

You could argue that issue 1 is not a real issue since the unnecessary dependencies are also transitively introduced by the @pulumi/kubernetes dependency. This is correct, but introduces manually dependency checking of each pulumi/kubernetes update (i. e. for example regenerating the sdk on every @pulumi/kubernetes update). This is normally not necessary if the crds itself are not changing and not an expected procedure (i. e. needs to be additionally documented). Also a package should IMHO always contain only dependencies it actually depends on.

Regarding the second issue: Any @types/... dependency is as far as I know (I'm far away from being a JS/TS Pro) a dev dependency since it should only contain type definitions.

If any of [glob, node-fetch, shell-quote, tmp] should be a dev dependency or not is out of scope of this issue and should be checked in pulumi/kubernetes itself. In my generated sdk there is no direct use of any of these listed dependencies.

I don't have deep insights to the actual sdk generation. My suggestion would be do just add the @pulumi/pulumi and @pulumi/kubernetes dependency to the generated sdk (In 1.4.0 this was the case. Do you have some insights, why this was changed?)

Edit: I forgot the @types/node and typescript dependency. These also should be added to devDependencies.

maxemann96 avatar Aug 26 '25 08:08 maxemann96