Skip to content

TypeSafeApi generated client module format. #535

Answered by cogwirrel
zetashift asked this question in Q&A
Discussion options

You must be logged in to vote

Hey! Sorry for the slow reply! Glad you found a combination that solved it! 😄

I've experienced hurt with ESM vs CJS before too haha! You can get both building though instead of just choosing between one or the other if that helps :)

Here's an example of how to do it in your .projenrc (courtesy of @zsstiers !):

api.runtime.typescript!.addFields({
  module: "./lib/esm/index.js",
  sideEffects: false,
});
api.runtime.typescript!.compileTask.exec("tsc -p tsconfig.esm.json");
new JsonFile(api.runtime.typescript!, "tsconfig.esm.json", {
  obj: {
    extends: "./tsconfig.json",
    compilerOptions: {
      module: "esnext",
      moduleResolution: "nodenext",
      outDir: "lib/esm",
    },
  },
})

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@cogwirrel
Comment options

Answer selected by zetashift
@zetashift
Comment options

@zetashift
Comment options

@cogwirrel
Comment options

@zetashift
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants