![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
esbuild-dev-server
Advanced tools
This plugin allows you to start a local server with hot reloading with Esbuild
npm i esbuild-dev-server -D
yarn add esbuild-dev-server -D
go get github.com/Falldot/esbuild-dev-server
options.Port
, string
: local server start port.options.Index
, string
: path to index html file.options.StaticDir
, string
: path to static files (js, css, img ...).options.WatchDir
, string
: path to working directory.options.OnLoad
, () => void
: local server restart event.const {build, formatMessages} = require("esbuild");
const {esBuildDevServer, startServer, sendError, sendReload} = require("esbuild-dev-server");
;(async () => {
const builder = await build({
entryPoints: ["src/index.js"],
bundle: true,
minify: false,
sourcemap: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge16'],
outdir: "dist/js",
incremental: true,
plugins: [
esBuildDevServer({
Port: "8080",
Index: "dist/index.html",
StaticDir: "dist",
WatchDir: "src",
OnLoad: async () => {
try {
await builder.rebuild();
await sendReload();
} catch(result) {
let str = await formatMessages(result.errors, {kind: 'error', color: true});
await sendError(str.join(""));
}
}
})
],
});
await startServer();
})();
func main() {
var result api.BuildResult
result = api.Build(api.BuildOptions{
EntryPoints: []string{"src/index.ts"},
Bundle: true,
MinifyWhitespace: true,
MinifyIdentifiers: true,
MinifySyntax: true,
Sourcemap: api.SourceMapInlineAndExternal,
Outdir: "public/js",
Write: true,
Engines: []api.Engine{
{Name: api.EngineChrome, Version: "58"},
{Name: api.EngineFirefox, Version: "57"},
{Name: api.EngineSafari, Version: "11"},
{Name: api.EngineEdge, Version: "16"},
},
Incremental: true,
Plugins: []api.Plugin{
devserver.Plugin(devserver.Options{
Port: ":8080",
Index: "public/index.html",
StaticDir: "public",
WatchDir: "src",
OnReload: func() {
result.Rebuild()
},
}),
},
})
if len(result.Errors) > 0 {
log.Fatalln(result.Errors)
}
if err := devserver.Start(); err != nil {
log.Fatalln(result.Errors)
}
}
FAQs
An fast JavaScript hot dev local server.
The npm package esbuild-dev-server receives a total of 19 weekly downloads. As such, esbuild-dev-server popularity was classified as not popular.
We found that esbuild-dev-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.