elegant-pager-5412
04/28/2021, 9:32 AMtarget: "es2020"
and compile the project myself, piping the output JS to Pulumi?billowy-army-68599
04/28/2021, 2:50 PMPulumi.yaml
options
typescript: false
https://www.pulumi.com/docs/reference/pulumi-yaml/lemon-monkey-228
04/28/2021, 3:25 PMpulumi up
?name: creatio-sync
description: Creatio Sync
runtime: nodejs
options:
typescript: false
is my Pulumi.yaml
npx tsc index.ts
it compiles the index.js
pulumi up
still seems to be trying to use itpackage.json
or something too?runtime:
name: nodejs
options:
typescript: false
but still no dicebillowy-army-68599
04/28/2021, 3:33 PMpulumi up
seems to be trying to use it, do you mean your index.ts ?elegant-pager-5412
04/28/2021, 3:41 PMtsconfig.json
specifies that the output dir should be dist
which is ignored in .gitignore
. Then I needed to tell Pulumi to use the JS file, which we can do so by adding the main
property to the package.json
.
The thing is that unless we use amd
as the module
definition in tsconfig
, TSC cannot combine all files into a single index.js
file.
To solve this, I did some bash magic and created the following command:
"scripts": {
"deploy": "tsc && sed -i '' \"s#\\\"main\\\": \\\".*,#\\\"main\\\": \\\"$(find dist -name 'index.js' -print -maxdepth 3 -quit)\\\",#\" package.json && pulumi up"
},
lemon-monkey-228
04/28/2021, 3:41 PMelegant-pager-5412
04/28/2021, 3:41 PM{
"compilerOptions": {
"strict": true,
"outDir": "dist",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictPropertyInitialization": false,
"forceConsistentCasingInFileNames": true,
"removeComments": true
}
}
lemon-monkey-228
04/28/2021, 3:46 PMDiagnostics:
pulumi:pulumi:Stack (creatio-sync-production):
error: Running program '/Users/james/projects/creatio/creatio-sync/deploy' failed with an unhandled exception:
/Users/james/projects/creatio/creatio-sync/deploy/node_modules/@devops/pulumi-utils/index.ts:1
import * as fs from 'fs'
^^^^^^
SyntaxError: Cannot use import statement outside a module
npx tsc
if the settings were till wrong (feel free to correct me if I’m wrong)elegant-pager-5412
04/28/2021, 3:51 PMlemon-monkey-228
04/28/2021, 4:38 PM{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
}
}
{
"name": "creatio-sync",
"main": "bin/index.js",
"devDependencies": {
"@types/node": "^10.0.0"
},
"dependencies": {
"@devops/pulumi-utils": "^0.1.2",
"@pulumi/kubernetes": "^2.0.0",
"@pulumi/kubernetesx": "^0.1.1",
"@pulumi/pulumi": "^2.0.0"
}
}
tsc
call to the library too