Hi, I am trying to package my own library with com...
# typescript
g
Hi, I am trying to package my own library with component resources. However, after compiling the code with
tsc
my package also contains
.ts
files. How can I exclude
.ts
files from the artifact? I tried to look at synced folder repo for example. But I when I compile my code into the
bin
folder it does not contain
package.json
like here https://github.com/pulumi/pulumi-synced-folder/blob/main/.github/workflows/release.yaml#LL132C11-L132C69 what step am I missing to get the package.json inside
bin
?
l
All of this is handled manually or via packaging tools or libraries. If you're using plain tsc, you can get most of the way by specifying outDir in your tsconfig.json. After compiling, copy your package.json in there and package up that directory.
g
Thanks, I found out myself. Now I am researching into differences between
CommonJS
and
NodeNext
ESM imports https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs It looks like you mess with the paths for imports https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#esm-nodejs I will try to play around and see if I can get it working with pulumi. According to issues on github it should be supported since ~3.22.0
l
Yes it's all working. The only thing that isn't working is Yarn2's PnP: you have to use
nodeLinker: node-modules
in your Yarn config, if you use Yarn2.
Note that for ESM, you need to add this to every Pulumi.yaml:
Copy code
runtime:
  name: nodejs
  options:
    nodeargs: "--loader ts-node/esm --no-warnings"
It's documented in the GitHub PR that adds this feature.. not sure if it's documented elsewhere...