Socket
Socket
Sign inDemoInstall

es6-dev-server

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-dev-server

Serve ES6 modules ensuring node resolution via the node algorithm. Express middleware and full server


Version published
Weekly downloads
11
Maintainers
1
Weekly downloads
 
Created
Source

Serve ES6 modules

This module serves ES6 modules ensuring node resolution via the node algorithm. Express middleware included.

Resolution is done via the node algorithm, but letting "module" or "jsnext" fields in package.json take precedence over "main".

NOTE: this module draws strong inspiration (and large chunks of repurposed code) from Marijn Haverbeke's awesome esmoduleserve.

Usage as a stand alone server

You can use es6-dev-server as a server:

$ ../es6-dev-server/server --help
Usage: server [options]

Options:
  -V, --version        output the version number
  -p, --port <port>    Set the port (default: 3000)
  -e, --entry <entry>  Default file for SPAs (never returning "not found"). (default: "")
  -h, --help           display help for command

It will run the server in the current directory; javascript modules will be translate so that import 'lit-element' will be translated into `import '../../node_modules/lit-element.js'

Usage as middleware

You can use it as middleware in your programs:

const moduleMiddleware = require('es6-dev-server').moduleMiddleware

(...)

app.use(moduleMiddleware({ root: '.') })

The parameter is the directory that will be served.

Usage as middleware (advanced)

You can call the internal middleware function of es6-dev-server, and have full control over the way the middleware is called:

const ModuleMiddleware = require('es6-dev-server').ModuleMiddleware

const mm = new ModuleMiddleware({ root: '.' })
app.use((req, res, next) => {
  if (mm.handleRequest(req, res)) {
    // The request WAS handled by the middleware's handleRequest() function
  } else {
    // The request was NOT handled by the middleware's handleRequest() function
    next()
  }
})

FAQs

Package last updated on 05 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc