Catalog npm
Back to packageRELEASE DETAILS

2.0.3

npm

@0xc/serverless-plugin-typescript

This is a fork of the `serverless-plugin-typescript` package.

aws lambdaserverlessserverless plugintypescript
Published12 Jun 2020
Direct dependencies13
Transitive dependenciesNot calculated

README

Current package documentation

builds.sr.ht status License: MIT

@0xc/serverless-plugin-typescript

This is a fork of the serverless-plugin-typescript package.

Features

  • Zero-or-more-config: Works out of the box, but you can still define some configurations!
  • 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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 14

Native requirements
13 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
fs-extra
Environment
{
  "local_name": "fs-extra",
  "alias": false,
  "peer_metadata": null
}
^7.0.1runtime
globby
Environment
{
  "local_name": "globby",
  "alias": false,
  "peer_metadata": null
}
^9.2.0runtime
@types/fs-extra
Environment
{
  "local_name": "@types/fs-extra",
  "alias": false,
  "peer_metadata": null
}
5.0.5development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
24.0.12development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
12.6.2development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^3.2.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^3.2.0development
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
latestdevelopment
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
24.5.0development
mock-fs
Environment
{
  "local_name": "mock-fs",
  "alias": false,
  "peer_metadata": null
}
4.9.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
2.6.3development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
24.0.2development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^3.4.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
>=2.2.2peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-M/p7L5gMp/YNQ0BuKoS9l66YZNPj4opMP3jdI5T3s5mz/FexsHiPVoeKkPfOWbR59yl2eUkftZIO0AT7Fu3ogA==",
  "shasum": "e501ced12ac5896c86bc56f36d0afb92c40174ea",
  "tarball": "https://registry.npmjs.org/@0xc/serverless-plugin-typescript/-/serverless-plugin-typescript-2.0.3.tgz",
  "fileCount": 11,
  "unpackedSize": 43259,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe49PgCRA9TVsSAnZWagAAp4oP/2YBtDv1YmEKI/k42cSn\nTUKGYwGCDf3F8Chr/Kj9GrT1KLF20NVrgcyKuqkBLqviF42ztGMsLm/NQi+F\nsByjtMTt5xJJb6GyaZww2+tbYtbQV9B579TlXaXpLiW/xj8nSF34wbDDUUY9\n38cHnX+3qO4wu8QGcAJhXF03wWfUfvmWV1Jd79AXLgKRO74J5LTLaqnKrV+C\nJhOmAhWzWKOXDa6AIZNSwL02TTUbMTaKJmZLLvs2kjAIxVLIN0PbdIajppOb\nM4GQ+WIb6c1GBWxPJ4Kz/X9cmlehwa+GBzbQlldeyhXbswrTH6Fb99N0LeQq\nHMamdWADdyyU0hgEpnOjg/Efts6BH25qs2+1Tb8fPDfctvXI2sTA7jOX0sCo\nrjpTMPjlUCvmuHx9esqSdWDWNfqYnPNq4WYBv3N0j9ndMg9AagV62JuAbZsD\nFUlQzoYHJthyAKNEC3yVcmiG/JWa6WNMM4imic9nTemdymFh1hD5wGs2mTyy\n96H9F4kq8qi43jdP8YBwlZPrbL/rxQPY5TkFSPupxTIY5iaF5d8cCZImwuYs\nPROwPB7Ng6wozWbdNjCtBxJTfWMXiH0LHYTXugndTGQ4lXin6pYuIR5Pis1y\nMCN722t8ijQb4p2dI9jvVrCkzSkzjX/heqNZMcMpH3xJBs1OlblvzYSc7Xl0\nW7Vi\r\n=4q1R\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIAIVvPAVu2na4mLNi3bHbrYYDugZhd3GpsITPoZKpW1kAiB9+zw91E48NawDi24581fVQ+87aVwiDPvG/MSoRuImEA=="
    }
  ]
}

Repository

PENDING
prisma/serverless-plugin-typescript

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:44 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:74e3606153c510c4ba5e4f6fb0ccb438d5a005712c3d21fc2f9ba1dcd8488deb

Other collected versions

2.0.412 Jun2.0.211 Jun2.0.111 Jun2.0.011 Jun1.2.111 Jun1.2.011 JunView all collected versions →