{"id":13580834,"url":"https://github.com/serverless/serverless-plugin-typescript","last_synced_at":"2025-05-14T16:03:20.074Z","repository":{"id":37436054,"uuid":"88510431","full_name":"serverless/serverless-plugin-typescript","owner":"serverless","description":"Serverless plugin for zero-config Typescript support","archived":false,"fork":false,"pushed_at":"2024-10-03T07:55:40.000Z","size":387,"stargazers_count":793,"open_issues_count":115,"forks_count":230,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-05-13T09:58:23.889Z","etag":null,"topics":["aws-lambda","babel","rollup","serverless","serverless-framework","serverless-plugin","typescript","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-17T13:26:19.000Z","updated_at":"2025-05-13T08:37:59.000Z","dependencies_parsed_at":"2024-10-11T09:32:16.455Z","dependency_job_id":"4e2d091a-e7d6-45ad-9c17-3c42473bcd52","html_url":"https://github.com/serverless/serverless-plugin-typescript","commit_stats":{"total_commits":153,"total_committers":32,"mean_commits":4.78125,"dds":0.7647058823529411,"last_synced_commit":"c23faad0f1704ee7a0f183911733bd9eeea8dfb9"},"previous_names":["prisma/serverless-plugin-typescript","graphcool/serverless-plugin-typescript"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-plugin-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-plugin-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-plugin-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fserverless-plugin-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/serverless-plugin-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253919618,"owners_count":21984262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","babel","rollup","serverless","serverless-framework","serverless-plugin","typescript","webpack"],"created_at":"2024-08-01T15:01:55.525Z","updated_at":"2025-05-14T16:03:19.672Z","avatar_url":"https://github.com/serverless.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# serverless-plugin-typescript\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.org/prisma/serverless-plugin-typescript.svg?branch=master)](https://travis-ci.org/prisma/serverless-plugin-typescript)\n\n_Originally developed by [Prisma Labs](https://github.com/prisma-labs/), now maintained in scope of [Serverless, Inc](https://www.serverless.com/)_\n\nServerless plugin for zero-config Typescript support\n\n\n## Features\n\n* Zero-config: Works out of the box without the need to install any other compiler or plugins\n* Supports ES2015 syntax + features (`export`, `import`, `async`, `await`, `Promise`, ...)\n* Supports `sls package`, `sls deploy` and `sls deploy function`\n* Supports `sls invoke local` + `--watch` mode\n* Integrates nicely with [`serverless-offline`](https://github.com/dherault/serverless-offline)\n\n## Install\n\n```sh\nyarn add --dev serverless-plugin-typescript typescript\n# or\nnpm install -D serverless-plugin-typescript typescript\n```\n\nAdd the following plugin to your `serverless.yml`:\n\n```yaml\nplugins:\n  - serverless-plugin-typescript\n```\n\n## Configure\n\nSee [example folder](example) for a minimal example.\n\n### `tsconfig.json`\n\nThe default `tsconfig.json` file used by the plugin looks like this:\n\n```json\n{\n  \"compilerOptions\": {\n    \"preserveConstEnums\": true,\n    \"strictNullChecks\": true,\n    \"sourceMap\": true,\n    \"allowJs\": true,\n    \"target\": \"es5\",\n    \"outDir\": \".build\",\n    \"moduleResolution\": \"node\",\n    \"lib\": [\"es2015\"],\n    \"rootDir\": \"./\"\n  }\n}\n```\n\n\u003e Note 1: The `outDir` and `rootDir` options cannot be overwritten.\n\n\u003e Note 2: Don't confuse the [`tsconfig.json`](tsconfig.json) in this repository with the one mentioned above.\n\n### Including extra files\n\nAll files from `package/include` will be included in the final build file. See [Exclude/Include](https://serverless.com/framework/docs/providers/aws/guide/packaging#exclude--include)\n\n### Non-standard tsconfig.json locations\nOverride what tsconfig.json to use with the following snippet in your severless.yaml\n```\ncustom:\n  serverlessPluginTypescript:\n    tsConfigFileLocation: './tsconfig.build.json'\n\n```\n\n## Usage\n\n### Google Cloud Functions\n\nWhen using with Google Cloud Functions via the [serverless-google-cloudfunctions](https://github.com/serverless/serverless-google-cloudfunctions)\nplugin, you simply have to provide a `main` field in your `package.json`:\n\n```js\n{\n  // ...\n  \"main\": \"handler.js\",\n  // ..\n}\n```\n\nAnd this plugin will automatically compile your typescript correctly. Note\nthat the field must refer to the compiled file name, namely, ending with a `.js`\nextension.\n\nIf a `main` field was not found, then this plugin will use `index.js`. Before\ncompilation begins, it will check to see that the file indicated exists with a\n`.ts` extension before actually trying to compile it.\n\n### Automatic compilation\n\nThe normal Serverless deploy procedure will automatically compile with Typescript:\n\n- Create the Serverless project with `serverless create -t aws-nodejs`\n- Install Serverless Typescript as above\n- Deploy with `serverless deploy`\n\n### Usage with serverless-offline\n\nThe plugin integrates very well with [serverless-offline](https://github.com/dherault/serverless-offline) to\nsimulate AWS Lambda and AWS API Gateway locally.\n\nAdd the plugins to your `serverless.yml` file and make sure that `serverless-plugin-typescript`\nprecedes `serverless-offline` as the order is important:\n```yaml\n  plugins:\n    ...\n    - serverless-plugin-typescript\n    ...\n    - serverless-offline\n    ...\n```\n\nRun `serverless offline` or `serverless offline start` to start the Lambda/API simulation.\n\nIn comparison to `serverless offline`, the `start` command will fire an `init` and a `end` lifecycle hook which is needed for `serverless-offline` and e.g. `serverless-dynamodb-local` to switch off resources (see below)\n\n#### serverless-dynamodb-local\n\nConfigure your service the same as mentioned above, but additionally add the `serverless-dynamodb-local`\nplugin as follows:\n```yaml\n  plugins:\n    - serverless-plugin-typescript\n    - serverless-dynamodb-local\n    - serverless-offline\n```\n\nRun `serverless offline start`.\n\n#### Other useful options\n\nYou can reduce the clutter generated by `serverless-offline` with `--dontPrintOutput` and\ndisable timeouts with `--noTimeout`.\n\n### Run a function locally\n\nTo run your compiled functions locally you can:\n\n```bash\n$ serverless invoke local --function \u003cfunction-name\u003e\n```\n\nOptions are:\n\n- `--function` or `-f` (required) is the name of the function to run\n- `--watch` - recompile and run a function locally on source changes\n- `--path` or `-p` (optional) path to JSON or YAML file holding input data\n- `--data` or `-d` (optional) input data\n\n### Enabling source-maps\n\nYou can easily enable support for source-maps (making stacktraces easier to read) by installing and using the following plugin:\n\n```sh\nyarn add --dev source-map-support\n```\n\n```ts\n// inside of your function\nimport 'source-map-support/register'\n```\n\nIf you are using webpack (most likely). Add `devtool: 'source-map'` to `webpack.config.js`:\n```js\nmodule.exports = {\n  .... snip ....\n  devtool: 'source-map',\n  .... snip ....\n\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-plugin-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fserverless-plugin-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fserverless-plugin-typescript/lists"}