Simple static server middleware with ES Module path resolution https://www.npmjs.com/package/es-module-devserver
  • JavaScript 100%
Find a file
2024-02-29 06:47:58 -03:00
.gitignore Initial commit 2018-07-02 22:50:04 +03:00
CODE_OF_CONDUCT.md Initial commit 2018-07-02 22:50:04 +03:00
index.js Allow no whitespace after the 'export' keyword 2021-08-09 13:08:38 +03:00
package.json release 0.1.6 2024-02-29 06:47:58 -03:00
README.md release 0.1.5 2024-02-29 06:45:53 -03:00
UNLICENSE Initial commit 2018-07-02 22:50:04 +03:00

npm version npm downloads Unlicense Support me on Patreon

es-module-devserver

Simple static server middleware for express/polka/etc. that resolves npm style module imports in JavaScript files to make them available for the browser in development. Just like Polymer CLI / polyserve does. But using regular expressions instead of dragging in a whole JS parser :D

Installation

Install with npm, obviously:

npm install --save-dev es-module-devserver

Usage

Something like this:

const fs = require('fs')
const polka = require('polka')
const esModuleDevserver = require('es-module-devserver')

polka()
	.use(esModuleDevserver.middleware(__dirname))
	.get('/', (req, res) => {
		const content = fs.readFileSync('demo.html')
		return res.end(content)
	})
	.listen(3003)
	.then(_ => console.log('Running on localhost:3003'))

Contributing

Please feel free to submit pull requests!

By participating in this project you agree to follow the Contributor Code of Conduct and to release your contributions under the Unlicense.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.