Skip to content

Latest commit

 

History

History
125 lines (93 loc) · 2.77 KB

CONTRIBUTING.md

File metadata and controls

125 lines (93 loc) · 2.77 KB

Contributing

Welcome, and thanks in advance for your help!

How to contribute to Serverless-Offline

To install all the locked versions for serverless-offline

npm ci

Development setup

You can test your local changes to serverless-offline if different ways

  • Point your serverless.yml directly to the local changes
    • agnostic to your tech stack, as long as you have serverless.yml
  • Point your npm package.json to the local changes
    • depends on an npm project

we are using Babel to transform ES6 modules (static imports and dynamic imports).

serverless.yml

you have several options:

  1. point your serverless.yml plugin entry point to src/main.js (https://github.com/dherault/serverless-offline/blob/master/src/main.js) and uncomment the block between use strict and module.exports. that way, babel/register will compile es6 module syntax on the fly.

    (as an alternative you can point the entry point to the package.json of the plugin and change main to src/main.js)

    service: foo
    
    plugins:
      - ../../../src/main.js
      # - ../../../  alternative: point to package.json
    
    provider:
      memorySize: 128
      name: aws
      # ....
  2. run the build step ahead of running the plugin. in that case don't uncomment anything in main.js!

    npm run build
    

    point your serverless.yml plugin entry to the build folder: ./dist/main.js (see 1. on how to)

package.json

  1. Make sure you install/build your local serverless-offline
    # serverless-offline
    npm ci
    npm run build
  2. Install the local serverless-offline in your other npm project as a dev dependency
    # in your-npm-project
    npm i -D serverless-offline@file:../serverless-offline
    After this, you should see a devDependencies like the following in your package.json
    {
      "devDependencies": {
        "serverless-offline": "file:serverless-offline"
      }
    }
  3. When you make changes to serverless-offline, re-run the build so Babel will re-compile the plugin source
    # serverless-offline
    npm run build
    The local file include in your-npm-project should have the linked changes in it's respective node_modules

Code Style

We're using Prettier, ESlint and the Airbnb preset. To fix errors which are automatically fixable, run:

npm run format

To run the linter, run:

npm run lint

Testing

There are a few test scripts, depending on what type of testing you want to run.

Unit tests

To run unit tests only:

npm run test:unit

Watch mode

To run all tests in watch mode (this skips npm install):

npm run test:watch

Test coverage

npm run test:cov