Skip to content

Instantly share code, notes, and snippets.

@cmckni3
Last active January 30, 2024 22:22
Show Gist options
  • Save cmckni3/1602f695f7f3d20bebbc7e6726c4a730 to your computer and use it in GitHub Desktop.
Save cmckni3/1602f695f7f3d20bebbc7e6726c4a730 to your computer and use it in GitHub Desktop.
Package TypeScript CLIs with zeit/pkg

TypeScript & zeit/pkg

zeit/pkg needs to know which assets to include for TypeScript (tsconfig.json) and be able to resolve any dynamic requires.

This package.json shows how to configure zeit/pkg with gluegun.

In this example, the assets key is used for pkg to copy necessary files into the built binary and resolve the dynamic requires to find extensions and commands. TypeScript requires some basic type definitions (*.d.ts files) to compile and run which are included with the TypeScript compiler.

The assets option for pkg specifies to copy the specified files to a know path inside of the binary.

{
"pkg": {
"assets": [
"./node_modules/@types",
"./node_modules/typescript/lib/*.d.ts",
"src/**/*.ts",
"./tsconfig.json"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment