This message was deleted.
# typescript
s
This message was deleted.
g
Can you elaborate on how you're calling this external function?
l
It's an internal library in a separate codebase. The library's tsconfig includes this (don't know what half of it does, I just lifted it from a similar library):
Copy code
"compilerOptions": {
        "composite": true,
        "declaration": true,
        "declarationMap": true,
        "strict": true,
        "target": "es2017",
        "module": "esnext",
        "moduleResolution": "node",
The module in the library just exports a function,
registerAutoTags
The app project's tsconfig includes this:
Copy code
"references": [
        {
            "path": "../pulumi"
        }
And the app's index.ts has this:
Copy code
import { registerAutoTags } from "../../pulumi/autotag/autotag";

// Automatically inject tags.
registerAutoTags({
  "user:Project": pulumi.getProject(),
  "user:Stack": pulumi.getStack(),
  "Env": "Sandbox",
});
(The app's tsconfig is one directory up from index.ts, hence the different paths in references and import.)
g
And you're running this application with the Pulumi cli? e.g.
pulumi up
l
Yep. I'm seeing this with
pulumi preview
. I didn't know there was another way to run it...
g
There isn't. I wanted to make sure you were doing it that way.
l
I'm running Pulumi 2.1.1 via the pulumi/pulumi Docker image.
g
Is
registerAutoTags()
called before all Pulumi resource creations?
l
Yes, it's the first non-import in my index.ts.
Though I do import my other project's module before it.. I'll try moving that import down, see if that makes a difference.
No, same issue. In fact, commenting-out the import of my resource module and my use of it still produces the same issue. All I have left is my registerStackTransformation module and my call to it.
I removed importing pulumi in my autotag module, and instead passed the pulumi I imported in my app code into the
registerAutoTags
function. That works. This reminds me of the issue I had a few days ago where I was using awsx v0.18 with pulumi v2: the lack of peerDependencies in awsx cause a different but similar error.
But I'm using latest everything now. And in this code, only @pulumi/pulumi is used.
Maybe I need to have peerDependencies in my library to get this to work? I did try that, but then I couldn't compile my library because it said nothing was resolving my peerDependencies... 🤔
Ok I've switched all my pulumi dependencies in my library to be peerDependencies, and got it to compile by duplicating them in devDependencies. Deleted my app's node_modules and re-ran
npm install
, just in case.
pulumi preview
is still failing with the same error.