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

netlify-local

v1.8.2

Published

Local Netlify service emulation

Downloads

107

Readme

Netlify Local

Travis CI badge Codeclimate maintainability Dependabot Status

Local Netlify service emulation.

Experimental: This package has not been heavily tested or used, some of the Netlify Services are incorrectly implemented. Submit an issue if you find any!

Semver Notice: Breaking changes which increase compatibility with Netlify services and features are not considered breaking 🤷‍♂️

For help bundling your Javascript to work with Netlify Functions, checkout netlify/netlify-lambda or 8eecf0d2/webpack-netlify-lambda-plugin.

An example Netlify deployable application is available at 8eecf0d2/netlify-local-example.

Install

You should probably install as a dev dependency, but globally works too.

yarn add -D netlify-local

Usage

serve command

The serve command will attempt to emulate Netlify Services.

netlify-local serve <options>

build command

The build command will attempt to correctly execute the build.command property within netlify.toml.

netlify-local build <options>

bundle command

The bundle command will attempt to parse your netlify.toml and build a Webpack Configuration with the correct entry and output properties before running a Webpack compiler with the computed configuration.

netlify-local bundle <options>

Options

You can view a detailed list of options in the wiki.

Features

Static Router

The static router refers to the static server functionality of Netlify Continuous Deployment, which serves files from the build.publish directory, specified within the toml configuration.

Lambda Router

The lambda router refers to the Netlify Functions feature which serves Lambda's or Cloud Functions from the build.functions directory, specified within the toml configuration.

Redirects

This feature refers to Netlify Redirects, this has not been correctly implemented and is missing a lot of functionality, see Issue #8 for progress.

Headers

This feature refers to Netlify Headers, for the most part this works as expected however the Netlify Basic Auth portion is not supported.

API

Specific classes and methods are exposed for running netlify-local programmatically, see Issue #6 for more information and documentation.

Typings

Relevant Typescript typings are exposed for the API and also Netlify Function handlers.

import { Netlify } from "netlify-local";

export const handler: Netlify.Handler<handler.Request, handler.Context, handler.Response> = (request, context, callback) => {

  return callback(null, {
    statusCode: 200,
    body: "foo"
  })
}

export namespace handler {
  export interface Request extends Netlify.Handler.Request {
    headers: {
      example: string;
    };
  }
  export interface Context extends Netlify.Handler.Context {
    user: { ... };
  }
  export interface Response extends Netlify.Handler.Response {
    body: { ... };
  }
}

Webpack

Multiple Configs

If you use multiple Webpack configurations for your application (one for the client, another for lambda) you should set the name property within the Webpack configuration to get better logging, otherwise config's will be named by their index.

Issues

To correctly execute lambda's they must be self contained bundles, a common issue when bundled incorrectly is missing modules similar to the error below.

Error: Cannot find module '/.../path/file'

To bundle your files correctly ensure that module.exports.handler is exposed for each handler file and that you're using individual entires within webpack.

module.exports = {
  target: "node",
  entry: {
    foo: "./src/ts/handlers/foo.ts",
    bar: "./src/ts/handlers/bar.ts",
    ...
  },
  ...
}

If you're starting a new project or not currently bundling, the easiest solution would be to use netlify/netlify-lambda and it's build command.

If you've got a pre-existing webpack config I'd suggest using a webpack helper library such as 8eecf0d2/webpack-netlify-lambda-plugin.

Credit

This project is inspired by netlify/netlify-lambda.