Observed since 20 Oct, 22:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xc/serverless-plugin-typescript
This is a fork of the `serverless-plugin-typescript` package.
This is a fork of the serverless-plugin-typescript package.
export, import, async, await, Promise, ...)sls package, sls deploy and sls deploy functionsls invoke local + --watch modeserverless-offlineyarn 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
See example folder for a minimal example.
tsconfig.jsonThe 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
outDirandrootDiroptions cannot be overwritten.
Note 2: Don't confuse the
tsconfig.jsonin this repository with the one mentioned above.
All files from package/include will be included in the final build file. See Exclude/Include
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.
The normal Serverless deploy procedure will automatically compile with Typescript:
serverless create -t aws-nodejsserverless deployThe 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)
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.
You can reduce the clutter generated by serverless-offline with --dontPrintOutput and
disable timeouts with --noTimeout.
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 dataYou 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 ....
}
Join our Spectrum community if you run into issues or have questions. We love talking to you!
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
fs-extraEnvironment{
"local_name": "fs-extra",
"alias": false,
"peer_metadata": null
} | ^7.0.1 | runtime |
globbyEnvironment{
"local_name": "globby",
"alias": false,
"peer_metadata": null
} | ^9.2.0 | runtime |
@types/fs-extraEnvironment{
"local_name": "@types/fs-extra",
"alias": false,
"peer_metadata": null
} | 5.0.5 | development |
@types/jestEnvironment{
"local_name": "@types/jest",
"alias": false,
"peer_metadata": null
} | 24.0.12 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | 12.6.2 | development |
@typescript-eslint/eslint-pluginEnvironment{
"local_name": "@typescript-eslint/eslint-plugin",
"alias": false,
"peer_metadata": null
} | ^3.2.0 | development |
@typescript-eslint/parserEnvironment{
"local_name": "@typescript-eslint/parser",
"alias": false,
"peer_metadata": null
} | ^3.2.0 | development |
eslintEnvironment{
"local_name": "eslint",
"alias": false,
"peer_metadata": null
} | latest | development |
jestEnvironment{
"local_name": "jest",
"alias": false,
"peer_metadata": null
} | 24.5.0 | development |
mock-fsEnvironment{
"local_name": "mock-fs",
"alias": false,
"peer_metadata": null
} | 4.9.0 | development |
rimrafEnvironment{
"local_name": "rimraf",
"alias": false,
"peer_metadata": null
} | 2.6.3 | development |
ts-jestEnvironment{
"local_name": "ts-jest",
"alias": false,
"peer_metadata": null
} | 24.0.2 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^3.4.1 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | >=2.2.2 | peer |
Source distribution
{
"integrity": "sha512-2gZ917vZmbXfIQz3x744zoz2R0aKIRldHkC9KudHzgkEuv5fbFwSjyC393IvPlLc2p252/p+7japAVH5rJMHdQ==",
"shasum": "f4cc0f73e9ba94c5d36e1674bf9f692db316fe15",
"tarball": "https://registry.npmjs.org/@0xc/serverless-plugin-typescript/-/serverless-plugin-typescript-2.0.1.tgz",
"fileCount": 11,
"unpackedSize": 43214,
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe4neoCRA9TVsSAnZWagAAnpgP/1XnUZoeRsD9SVg3SH+6\nGIR0Fc96AReOY9gwvp23DNAjdS/78Rvs3ZwHU/pPR/ozFUeiysAukxvr2N/y\nCp7B58/UfCy4vPxIoTaCZzX+k/aBN9KBo3BtNGElrIg6PAx8G1hilEZeFTJg\nAUPC4fKZutyjAV9dzfsN/OSTkoeOkgArLYSIGbHASLZy2NtwLlilpMcnJ9zl\nNaKC9Cm5p3j1zDpsfsF0BZnIep3nIyP3zISMkwdlb9ZGBtu05qlN/nWwJASm\nTgAO/6eADNNTF62ldjobmA7EiIGBuGmKqKM7rOPyvpPG4yd55vZGSH6GSJ1e\ngVRu29TjghcwFO9ThnDy5F3vPRWT47jtpe+dj8KhipgCOkJhSE71Dqp8tJOS\ngaBVm4WKZef8TxFtXAhoKHfJHGQ3h5v3xRBa96KaJVL7KANlgfK1qCkWlXqa\nS75LW0kSZ80bUI6eFIFihPNaAX4BYAmNWE9ZucyD5Joa7BUXyE95cNBSwGqh\nGZmIEnY4lS92w+YvJ3tg3eP3vpwbeoj1re6zShQ2R9u3dxhcquVl4ZjHq9fS\nzdQZ3n8F5B0rvHfiYFh2IFrVOhPMThH9hG3qN+X19sz/SjJ22ANECf/xHR0H\n9xlg25GHADZFBftkiCDPVVVT7/Jgsk+RmjoT9H9G5NmIBBc+SccwUmmxR5gs\n56JT\r\n=bIyO\r\n-----END PGP SIGNATURE-----\r\n",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIQCplsQEjf7r0FFjr0FjLHKgwD3BeVP4NfWcicYEZwm3ZwIgW8Nyo7BC+54jk1pY66ybEpurXLiMJpMM/MHqSQ52oQA="
}
]
}Shared repository data · GitHub
Observed since 20 Oct, 22:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:e49714b31f775678992c13d2b467aaa337bc76edf01f8e10baae3cd4d35289ec