This message was deleted.
# general
s
This message was deleted.
r
Hmm I guess I could define an entrypoint of dist/index.js and run babel before pulumi up
Having first class babel compatibility would be nice, if it exists! So I do not have to do that 😄
or just having some sort of hook that can be run
d
You can install pulumi into a subfolder and then move
Pulumi.yaml
one level up. Then inside
Pulumi.yaml
add the following:
Copy code
main: my-folder
config: my-folder
If you use yarn you can set
my-folder
as a workspace as well
r
I did exactly that and it works as for storing pulumi files in a subfolders. But that's only about where are the files. What I thought is that I could use
import * as aws from "@pulumi/aws";
inside my code. This is only true if you use Pulumi + TypeScript native support. I am not using TypeScript, so I had to have a build step using babel. Maybe having native babel support would be nice too!
d
What do you mean inside your code? In your next.js-app?
r
No, inside "my-folder" for example
Inside the pulumi code I am using
Example:
Copy code
import * as aws from "@pulumi/aws";

import slackSync from "./events/slack-sync";

const topic = new aws.sns.Topic("slack-sync-topic");
topic.onEvent("slack-sync", slackSync);
This can only work, if you opt in for the TypeScript option of pulumi, at least from my testing. Supporting not just TypeScript but also babel natively would be cool.
Just like the docs says: "Because programs are just JavaScript, you may elect to write them in any manner you’d normally write Node.js programs. That includes TypeScript, CoffeeScript, or Babel, in addition to your favorite tools such as build systems, linters, or test frameworks."
That's true, but you have to build/compile your programs then I guess
d
Oh I see, my point is you can install typescript in that subfolder and be done with it
Copy code
my-project
├── Pulumi.yaml
├── package.json
├── yarn.lock
└── my-pulumi-folder
    ├── Pulumi.main.yaml
    ├── index.ts
    ├── package.json
    └── tsconfig.json
r
Yes indeed, but as I said I am not using TypeScript 😄 and I won't be
👍 1
d
Ah sorry, didn't infer the "won't be" part
g
@refined-car-55506 I think you just need to use
require
instead of
import
. So
Copy code
import * as aws from "@pulumi/aws";
becomes
Copy code
const aws = require("@pulumi/aws");
unless I'm missing a deeper question here.
r
Hey I think I was not clear. I understand why I can't use import and I should use require (i.e. because I am not using pulumi + TypeScript). What I wanted to say/discuss/suggest was that it would be nice to support other types of JavaScript "bundlers" like babel so we can also use ES6 import syntax even if we're not using TypeScript.
For example, in Next.js, I can use every JavaScript feature I want because in the background Next.js will bundle my code using babel + preset-env (https://babeljs.io/docs/en/babel-preset-env)
And I wish pulumi would be able to do so