Pulumi seems to be running my TS code without tran...
# typescript
Pulumi seems to be running my TS code without transpiling it according to the directions in tsconfig.json. I've just added baseUrl/paths/moduleAliases, but it's complaining that it can't find the JS files in dist/.../*.js...
How can I require that Pulumi (or tsc/yarn/npm?) transpiles every run?
Are you talking about your application, or Pulumi plan?
I want pulumi preview to (potentially) update dist/.../*.js (if my .ts files have changed).
My tsconfig.json says
outDir: "./dist"
. Something has put files there. But I don't know what. Certainly there should be many more files.
How are you deploying your code? Using a Lambda Callback Function?
pulumi up
Maybe we're talking at cross purposes?
My Pulumi code is in typescript. It uses baseUrl/paths in its imports (
"@myorg": "./src/pulumi/"
and similar). VSCode and typescript honour this.
However the JS that's actually being run is complaining that it can't find module "@myorg", since JS doesn't know about paths.
So I've added _moduleAliases saying "@myorg" is "./dist/src/pulumi/", which is where I expect the transpiled JS code to go.
But it's not there.
Interestingly, I tried compiling it manually and it turns out
isn't even installed! I don't know how Pulumi is running my typescript...
I'm finding this hard to understand without an example, but these two documents should add clarity about how Pulumi's typescript / tsconfig.json support work, and function serialization for determining which dependencies get magically deployed with it: https://www.pulumi.com/docs/intro/concepts/function-serialization/ https://www.pulumi.com/docs/intro/languages/javascript/#3-create-tsconfigjson Personally, I decouple the application build process from Pulumi's magic.
Pulumi's engine has typescript support
you can choose to disable it.
No function serialization is involved. I'm talking about the actual Pulumi program, not code to be run in the cloud.
Ahh, okay
My issue is that there are no (findable) JS files that contain the transpiled TS code of my Pulumi program.
That 2nd link you posted has
"outDir": "bin"
in its recommended tsconfig.json, but afaict, the bin dir is not being updated
Maybe you want this option? https://www.typescriptlang.org/docs/handbook/module-resolution.html
 module resolution is the most-commonly used in the TypeScript community and is recommended for most projects. If you are having resolution problems with `import`s and `export`s in TypeScript, try setting 
moduleResolution: "node"
 to see if it fixes the issue.
Yep, that's what I'm using. Specifically, the part here: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
Unfortanuately, only the typescript part works. The lower-level javascript part isn't yet working.
Okay, so you have a TypeScript Pulumi plan that's trying to import JavaScript, and it's failing to run the JavaScript imports on the TypeScript language host?
I'm only running a normal typescript Pulumi program, nothing else.
Typescript isn't an interpreted language, it's transpiled to javascript, then interpreted.
I am using a typescript-only technology to make my files easier to read.
In the transpiled JS files, this isn't recognized, so I'm using a 2nd, JS technology, to support it.
However, Pulumi cannot find the transpiled JS files which I believe it should be running.
I presume it's transpiling them into memory, and this must be breaking stuff? But I don't know.
Hmm. Not exactly the same, but adopting that might resolve the issue incidentally.. plus I like modules, so I'll make this changes anyway 🙂
Thanks for finding it.
👍 1
That lead me down another rabbit hole. Big warren. Gave up, raised an issue: https://github.com/pulumi/pulumi/issues/8787
i just ran into this as well. so far i've been able to ram path-mapping into Pulumi by using
and doing the path mapping instantiation in index.ts as it gets read by Pulumi (and similarly, I can run Jest via moduleMapper), but static analysis of files still fails
using the bundled
will always throw errors about modules missing
will always throw the same errors