All Projects → prisma-labs → Serverless Plugin Typescript

prisma-labs / Serverless Plugin Typescript

Licence: mit
Serverless plugin for zero-config Typescript support

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Serverless Plugin Typescript

Serverless Plugin Git Variables
⚡️ Expose git variables to serverless
Stars: ✭ 75 (-87.73%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Plugin Canary Deployments
Canary deployments for your Serverless application
Stars: ✭ 283 (-53.68%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+329.62%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-91.65%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Wsgi
Serverless plugin to deploy WSGI applications (Flask/Django/Pyramid etc.) and bundle Python packages
Stars: ✭ 377 (-38.3%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Sentry Plugin
This plugin adds automatic forwarding of errors and exceptions to Sentry (https://sentry.io) and Serverless (https://serverless.com)
Stars: ✭ 146 (-76.1%)
Mutual labels:  serverless, aws-lambda, serverless-framework, serverless-plugin
Serverless Webpack
Serverless plugin to bundle your lambdas with Webpack
Stars: ✭ 1,595 (+161.05%)
Mutual labels:  webpack, serverless, serverless-plugin, babel
Fullstack App
⚡ Ready-to-use, serverless, full-stack application built with AWS Lambda, Express.js, React, AWS DynamoDB and AWS HTTP API.
Stars: ✭ 265 (-56.63%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Zappa
Serverless Python
Stars: ✭ 224 (-63.34%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Webiny Js
Enterprise open-source serverless CMS. Includes a headless CMS, page builder, form builder and file manager. Easy to customize and expand. Deploys to AWS.
Stars: ✭ 4,869 (+696.89%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Hands On Serverless Guide
A hands-on guide for building Serverless applications
Stars: ✭ 288 (-52.86%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Serverlessbydesign
A visual approach to serverless development. Think. Build. Repeat.
Stars: ✭ 254 (-58.43%)
Mutual labels:  serverless, aws-lambda, serverless-framework
serverless-rack
Serverless plugin to deploy Ruby Rack applications (Sinatra/Rails/Padrino/Cuba etc.) and bundle gems
Stars: ✭ 58 (-90.51%)
Mutual labels:  aws-lambda, serverless-framework, serverless-plugin
Ts Monorepo
Template for setting up a TypeScript monorepo
Stars: ✭ 459 (-24.88%)
Mutual labels:  webpack, rollup, babel
Xdm
a modern MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins
Stars: ✭ 206 (-66.28%)
Mutual labels:  webpack, rollup, babel
Serverless Prisma
AWS Serverless Prisma Boilerplate
Stars: ✭ 126 (-79.38%)
Mutual labels:  webpack, serverless, babel
Aws Auto Cleanup
Open-source application to programmatically clean your AWS resources based on a whitelist and time to live (TTL) settings
Stars: ✭ 276 (-54.83%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Serverless Golang
AWS Lambda Go functions using Serverless Framework and Python shim
Stars: ✭ 292 (-52.21%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Express
⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
Stars: ✭ 337 (-44.84%)
Mutual labels:  serverless, aws-lambda, serverless-framework
Midway Faas
🔱 A simple and lightweight serverless framework
Stars: ✭ 363 (-40.59%)
Mutual labels:  serverless, aws-lambda, serverless-framework

serverless-plugin-typescript

serverless npm version Build Status

Serverless plugin for zero-config Typescript support

Features

  • Zero-config: Works out of the box without the need to install any other compiler or plugins
  • Supports ES2015 syntax + features (export, import, async, await, Promise, ...)
  • Supports sls package, sls deploy and sls deploy function
  • Supports sls invoke local + --watch mode
  • Integrates nicely with serverless-offline

Install

yarn add --dev serverless-plugin-typescript typescript
# or
npm install -D serverless-plugin-typescript typescript

Add the following plugin to your serverless.yml:

plugins:
  - serverless-plugin-typescript

Configure

See example folder for a minimal example.

tsconfig.json

The default tsconfig.json file used by the plugin looks like this:

{
  "compilerOptions": {
    "preserveConstEnums": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "allowJs": true,
    "target": "es5",
    "outDir": ".build",
    "moduleResolution": "node",
    "lib": ["es2015"],
    "rootDir": "./"
  }
}

Note 1: The outDir and rootDir options cannot be overwritten.

Note 2: Don't confuse the tsconfig.json in this repository with the one mentioned above.

Including extra files

All files from package/include will be included in the final build file. See Exclude/Include

Usage

Google Cloud Functions

When using with Google Cloud Functions via the serverless-google-cloudfunctions plugin, you simply have to provide a main field in your package.json:

{
  // ...
  "main": "handler.js",
  // ..
}

And this plugin will automatically compile your typescript correctly. Note that the field must refer to the compiled file name, namely, ending with a .js extension.

If a main field was not found, then this plugin will use index.js. Before compilation begins, it will check to see that the file indicated exists with a .ts extension before actually trying to compile it.

Automatic compilation

The normal Serverless deploy procedure will automatically compile with Typescript:

  • Create the Serverless project with serverless create -t aws-nodejs
  • Install Serverless Typescript as above
  • Deploy with serverless deploy

Usage with serverless-offline

The plugin integrates very well with serverless-offline to simulate AWS Lambda and AWS API Gateway locally.

Add the plugins to your serverless.yml file and make sure that serverless-plugin-typescript precedes serverless-offline as the order is important:

  plugins:
    ...
    - serverless-plugin-typescript
    ...
    - serverless-offline
    ...

Run serverless offline or serverless offline start to start the Lambda/API simulation.

In 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)

serverless-dynamodb-local

Configure your service the same as mentioned above, but additionally add the serverless-dynamodb-local plugin as follows:

  plugins:
    - serverless-plugin-typescript
    - serverless-dynamodb-local
    - serverless-offline

Run serverless offline start.

Other useful options

You can reduce the clutter generated by serverless-offline with --dontPrintOutput and disable timeouts with --noTimeout.

Run a function locally

To run your compiled functions locally you can:

$ serverless invoke local --function <function-name>

Options are:

  • --function or -f (required) is the name of the function to run
  • --watch - recompile and run a function locally on source changes
  • --path or -p (optional) path to JSON or YAML file holding input data
  • --data or -d (optional) input data

Enabling source-maps

You can easily enable support for source-maps (making stacktraces easier to read) by installing and using the following plugin:

yarn add --dev source-map-support
// inside of your function
import 'source-map-support/register'

If you are using webpack (most likely). Add devtool: 'source-map' to webpack.config.js:

module.exports = {
  .... snip ....
  devtool: 'source-map',
  .... snip ....

}

Help & Community

Join our Spectrum community if you run into issues or have questions. We love talking to you!

Prisma

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].