hey all, I want to split up my index.ts main file ...
# getting-started
f
hey all, I want to split up my index.ts main file into resource group files (e.g. database.ts and beanstalk.ts) And have the different files connect to each other using es6 imports When I tried this earlier it fails and only picks up index.ts for changes : / Is there a way I can make pulumi pick up changes for a folder? or even a collection of files?
s
You need to import the other files into your index.ts
and then t should just work
For example my index.ts looks like this
Copy code
import { staticBucketName, sitemapBucketName } from "./backend/app/buckets";
import { ipv4, ipv6 } from "./frontend/lb";

export const app = { staticBucketName, sitemapBucketName };

export const lb = { ipv4, ipv6 };
the import from "./frontend/lb" loads the lb.ts file which in turn loads a bunch of other files and their associated resources until it has every resource in the plan.
f
ahhh, awesome thanks so much John!
c
@swift-telephone-15894 @flat-queen-33017 if you want to avoid importing and then exporting, if you set
importsNotUsedAsValues
to
preserve
in
tsconfig.json
then you can just re-export modules in your index file, like:
Copy code
export * from './buckets';
🙌 1
f
that’s really handy thanks @cuddly-father-4905!
👍 1
180 Views