Skip to content

Commit 4742bd6

Browse files
authoredJul 27, 2023
feat: create cdk with esm (#402)
1 parent 4b4b025 commit 4742bd6

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed
 

‎packages/create-eventual/src/create-new-aws-cdk-project.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,9 @@ packages:
274274
compilerOptions: {
275275
outDir: "lib",
276276
rootDir: "src",
277-
module: "CommonJS",
278-
moduleResolution: "Node",
277+
module: "esnext",
278+
target: "ESNext",
279+
moduleResolution: "NodeNext",
279280
},
280281
references: [
281282
{
@@ -286,6 +287,7 @@ packages:
286287
writeJsonFile("package.json", {
287288
name: infraPkgName,
288289
version: "0.0.0",
290+
type: "module",
289291
scripts: {
290292
synth: "cdk synth",
291293
deploy: "cdk deploy",
@@ -310,14 +312,17 @@ packages:
310312
},
311313
}),
312314
writeJsonFile("cdk.json", {
313-
app: "ts-node ./src/app.ts",
315+
app: "ts-node-esm ./src/app.mts",
314316
}),
315317

316318
fs
317319
.mkdir("src")
318320
.then(() =>
319321
Promise.all([
320-
fs.writeFile(path.join("src", "app.ts"), sampleCDKApp(serviceName)),
322+
fs.writeFile(
323+
path.join("src", "app.mts"),
324+
sampleCDKApp(serviceName)
325+
),
321326
])
322327
),
323328
]);

‎packages/create-eventual/src/sample-code.ts

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export function sampleCDKApp(serviceName: string) {
5959

6060
return `import { App, Stack, CfnOutput } from "aws-cdk-lib";
6161
import { Service } from "@eventual/aws-cdk";
62+
import { createRequire } from "module";
63+
64+
const require = createRequire(import.meta.url);
6265
6366
const app = new App();
6467
const stack = new Stack(app, "${serviceName}")

0 commit comments

Comments
 (0)
Please sign in to comment.