npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-modularize

v3.0.0

Published

Modularize your serverless definitions

Downloads

814

Readme

serverless-plugin-modularize

Allows modularized serverless definitions to be merged into a root project. Making decoupled code more config driven and encapsulated.

Downloads Version License

header

Installation

npm install -D serverless-plugin-modularize

or

yarn add -D serverless-plugin-modularize

Usage

Plugin Dependency

In your projects serverless file, add serverless-plugin-modularize to the list of your plugins:

plugins:
  - serverless-plugin-modularize

Custom Declaration

Add the following declaration to the custom definiton of your serverless file:

custom:
  modularize:
    glob: 'src/**/*.module.yml' # glob pattern

The plugin uses glob patterns to resolve matching modularized files. For a primer on glob usage, visit here. If no glob is provided, the plugin will not merge anything. When matches are found, the result will be dynamically merged into the base serverless.yml definition as required.

Supported Module File Types

  • yaml
  • js
  • json

Commands

modularize info

The info command can be used to debug what each module is responsible for. In the example here, running the command will produce the following:

$ npx serverless modularize info
modularize: src/goodbye/goodbye.module.yml 
 {
  "functions": {
    "goodbye": {
      "handler": "src/goodbye/index.goodbye"
    }
  }
} 

modularize: src/hello/hello.module.yml 
 {
  "functions": {
    "hello": {
      "handler": "src/hello/index.hello"
    }
  }
} 
modularize merged

The merged command will display what the serverless definition will look like once all the modules are merged:

$ npx serverless modularize merged
modularize: {
  "functions": {
    "goodbye": {
      "handler": "src/goodbye/index.goodbye",
      "events": [],
      "name": "modular-example-dev-goodbye"
    },
    "hello": {
      "handler": "src/hello/index.hello",
      "events": [],
      "name": "modular-example-dev-hello"
    }
  },
  "plugins": [
    "serverless-plugin-modularize"
  ],
  "custom": {
    "modularize": {
      "glob": "src/**/*.module.yml"
    }
  },
  "provider": {
    "stage": "dev",
    "variableSyntax": "\\${([ ~:a-zA-Z0-9._@'\",\\-\\/\\(\\)*?]+?)}",
    "name": "aws",
    "runtime": "nodejs10.x",
    "region": "us-east-1",
    "versionFunctions": true,
    "remoteFunctionData": null
  },
  "resources": {}
}

Supported Mergeable Properties

To avoid mutating the base serverless framework, only the following properties are supported when merging. Unfortunately to help in merging, please follow the Expected Type(s) from the table below to avoid collisions between arrays and object.

| Property | Expected Type | |-----|-----| | provider | Object | | plugins | String[] | | custom | Object or File Reference | | functions | Object | | resources | Object |

Sample Project

A simple example can be found here, showing how two lambda resource definitions can be modularized into one project.

Changelog

1.0.9

  • Array de-duplication
  • Moved merge to run once at beginning only

1.0.8

  • Using deep merge with Ramda instead of es6 syntax

1.0.7

  • Adding Outputs fix to resources merge

1.0.6

  • Fixing merge issue regarding Resources, thanks to LoZeno

1.0.5

  • Removed external dependency that was causing merge duplication

1.0.4

  • Deduplicating non-mergeable array items

1.0.3

  • Adding check for Fn:Get keys