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-parcel

v0.1.1

Published

A Serverless plugin to bundle your functions and assets with Parcel Bundler

Downloads

19

Readme

serverless-plugin-parcel

serverless npm version

Serverless plugin for zero-config ES6/7 and Typescript support

This project is mostly a fork of serverless-plugin-typescript and was heavily inspired by that.

Features

  • Zero-config: Works out of the box without the need to install any other compiler or plugins
  • Supports sls package, sls deploy and sls deploy function
  • Supports sls invoke local
  • Integrates nicely with serverless-offline

Install

yarn add -D parcel-bundler serverless-plugin-parcel

or

npm install -D parcel-bundler serverless-plugin-parcel

Add the following plugin to your serverless.yml:

plugins:
    - serverless-plugin-parcel

Configure

By default, no configuration required, but you can change Parcel behavior by creating custom .babelrc file and in custom parcel section in serverless.yaml config:

custom:
    parcel:
        target: node
        cache: false

Check parceljs documentation for the full list of available options.

See example folder for a minimal example.

Automatic compilation

The normal Serverless deploy procedure will automatically compile with Parcel:

  • Create the Serverless project with serverless create -t aws-nodejs
  • Install Serverless Parcel Plugin as above
  • Deploy with serverless deploy

Usage with serverless-offline

The 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-parcel precedes serverless-offline as the order is important:

plugins: ...
    - serverless-plugin-parcel
    ...
    - 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)

serverless-dynamodb-local

Configure your service the same as mentioned above, but additionally add the serverless-dynamodb-local plugin as follows:

plugins:
    - serverless-plugin-parcel
    - serverless-dynamodb-local
    - serverless-offline

Run serverless offline start.

Run a function locally

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
  • --path or -p (optional) path to JSON or YAML file holding input data
  • --data or -d (optional) input data

Enabling source-maps

You can easily enable support for source-maps (making stacktraces easier to read) by installing and using the following plugin:

yarn add -D source-map-support
// inside of your function
import 'source-map-support/register';

or using babel plugin:

yarn add source-map-support
yarn add -D babel-plugin-source-map-support

in .babelrc:

{
    "plugins": [
        "source-map-support"
    ]
    ...
}

Alternatives

serverless-parcel