Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(type-safe-api): add compilation to ESM for TypeScript #561

Merged
merged 8 commits into from
Sep 12, 2023
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0 */
import { NodePackageUtils } from "@aws/monorepo";
import { IgnoreFile } from "projen";
import { IgnoreFile, JsonFile } from "projen";
import { NodePackageManager } from "projen/lib/javascript";
import { TypeScriptProject } from "projen/lib/typescript";
import { Language } from "../../languages";
Expand Down Expand Up @@ -121,6 +121,22 @@ export class GeneratedTypescriptRuntimeProject extends TypeScriptProject {

this.preCompileTask.spawn(generateTask);

// Add compilation to ESM as well
const compileESMTask = this.addTask("compile-esm");
compileESMTask.exec("tsc -p tsconfig.esm.json");
new JsonFile(this, "tsconfig.esm.json", {
obj: {
extends: "./tsconfig.dev.json",
compilerOptions: {
module: "esnext",
moduleResolution: "nodenext",
cogwirrel marked this conversation as resolved.
Show resolved Hide resolved
outDir: "lib/esm",
},
},
});

this.compileTask.spawn(compileESMTask);

// Ignore all the generated code
this.gitignore.addPatterns(
"src",
Expand Down
Loading
Loading