diff --git a/README.md b/README.md index 16b7d00a..e579f231 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,21 @@ plugin as follows: Run `serverless offline start`. +#### serverless-plugin-simulate + +Add the plugins to your `serverless.yml` file and make sure that `serverless-plugin-typescript` +precedes `serverless-plugin-simulate` as the order is important: +```yaml + plugins: + ... + - serverless-plugin-typescript + ... + - serverless-simulate-simulate + ... +``` + +`serverless-plugin-typescript` attaches to `simulate lambda` and `simulate apigateway` events + #### Other useful options You can reduce the clutter generated by `serverless-offline` with `--dontPrintOutput` and diff --git a/src/index.ts b/src/index.ts index ef134950..03b6efac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,6 +39,8 @@ export class TypeScriptPlugin { await this.compileTs() this.watchAll() }, + 'before:simulate:lambda:start': this.compileTs.bind(this), + 'before:simulate:apigateway:initialize': this.compileTs.bind(this), 'before:package:createDeploymentArtifacts': this.compileTs.bind(this), 'after:package:createDeploymentArtifacts': this.cleanup.bind(this), 'before:deploy:function:packageFunction': this.compileTs.bind(this), @@ -138,12 +140,12 @@ export class TypeScriptPlugin { async copyExtras() { // include node_modules into build if (!fs.existsSync(path.resolve(path.join(buildFolder, 'node_modules')))) { - fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules'))) + fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules')), 'dir') } // include package.json into build so Serverless can exlcude devDeps during packaging if (!fs.existsSync(path.resolve(path.join(buildFolder, 'package.json')))) { - fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json'))) + fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json')), 'file') } // include any "extras" from the "include" section