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-optimize-prisma

v4.2.1-rc.2

Published

Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript.

Downloads

8

Readme

Serverless Optimize Plugin

serverless npm version npm downloads license

Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript.

This plugin is a child of the great serverless-optimizer-plugin. Kudos!

Requirements:

  • Serverless v1.12.x or higher.
  • AWS provider and nodejs4.3/6.10/8.10/10.x/12.x/14.x runtimes

Setup

Install via npm in the root of your Serverless service:

npm install serverless-plugin-optimize --save-dev
  • Add the plugin to the plugins array in your Serverless serverless.yml:
plugins:
  - serverless-plugin-optimize
  • Set your packages to be built individually to have smaller packages:
package:
  individually: true
  • All done! Optimize will run on SLS deploy and invoke local commands

Options

Configuration options can be set globally in custom property and inside each function in optimize property. Function options overwrite global options.

Global

  • debug (default false) - When debug is set to true it won't remove prefix folder and will generate debug output at the end of package creation.
  • exclude (default ['aws-sdk']) - Array of modules or paths that will be excluded.
  • extensions (default ['.js', '.json']) - Array of optional extra extensions modules that will be included.
  • external Array of modules to be copied into node_modules instead of being loaded into browserify bundle. Note that external modules will require that its dependencies are within its directory and this plugin will not do this for you. e.g. you should execute the following: (cd external_modules/some-module && npm i --prod)
  • externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in node_modules.
  • global (default false) - When global is set to true transforms will run inside node_modules.
  • ignore - Array of modules or paths that won't be transformed with Babelify.
  • includePaths - Array of file paths that will be included in the bundle package. Read here how to call these files.
  • minify (default true) - When minify is set to false Babili preset won't be added.
  • plugins - Array of Babel plugins.
  • prefix (default _optimize) - Folder to output bundle.
  • presets (default ['env']) - Array of Babel presets.
custom:
  optimize:
    debug: true
    exclude: ['ajv']
    extensions: ['.extension']
    external: ['sharp']
    externalPaths:
      sharp: 'external_modules/sharp'
    global: true
    ignore: ['ajv']
    includePaths: ['bin/some-binary-file']
    minify: false
    prefix: 'dist'
    plugins: ['transform-decorators-legacy']
    presets: ['es2017']

Function

  • optimize (default true) - When optimize is set to false the function won't be optimized.
functions:
  hello:
    optimize: false
  • exclude - Array of modules or paths that will be excluded.
  • extensions - Array of optional extra extensions modules that will be included.
  • external Array of modules to be copied into node_modules instead of being loaded into browserify bundle. Note that external modules will require it's dependencies within it's directory. (cd external_modules/some-module && npm i --prod)
  • externalPaths Optional object key value pair of external module name and path. If not set, external modules will look for reference path in node_modules.
  • global - When global is set to true transforms will run inside node_modules.
  • ignore - Array of modules or paths that won't be transformed with Babelify.
  • includePaths - Array of file paths that will be included in the bundle package. Read here how to call these files.
  • minify - When minify is set to false Babili preset won't be added.
  • plugins - Array of Babel plugins.
  • presets - Array of Babel presets.
functions:
  hello:
    optimize:
      exclude: ['ajv']
      extensions: ['.extension']
      external: ['sharp']
      externalPaths:
        sharp: 'external_modules/sharp'
      global: false
      ignore: ['ajv']
      includePaths: ['bin/some-binary-file']
      minify: false
      plugins: ['transform-decorators-legacy']
      presets: ['es2017']

includePaths Files

There is a difference you must know between calling files locally and after optimization with includePaths.

When Optimize packages your functions, it bundles them inside /${prefix}/${functionName}/... and when your lambda function runs in AWS it will run from root /var/task/${prefix}/${functionName}/... and your CWD will be /var/task/.

Solution in #32 by @hlegendre. path.resolve(process.env.LAMBDA_TASK_ROOT, ${prefix}, process.env.AWS_LAMBDA_FUNCTION_NAME, ${includePathFile}).

Contribute

Help us making this plugin better and future proof.

  • Clone the code
  • Install the dependencies with npm install
  • Create a feature branch git checkout -b new_feature
  • Lint with standard npm run lint

License

This software is released under the MIT license. See the license file for more details.