esmoduleserve is a lightweight, shim HTTP development server designed for serving ES modules directly in the browser without requiring a bundling step. Currently at version 0.3.1, it focuses on providing a direct ES module development experience by rewriting import specifiers on-the-fly to precise, resolved paths. It implements a Node-like module resolution algorithm, prioritizing `"module"` or `"jsnext"` fields in `package.json` over `"main"`. This differentiates it from more comprehensive dev servers (e.g., Vite, Webpack dev server) that typically integrate bundling, transpilation, and hot module reloading, by offering a simpler, unbundled approach for native ES module workflows. Its release cadence is likely infrequent, as it serves a specific, focused niche for rapid development and testing of native ES modules.
npm install esmoduleserveVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `esmoduleserve` as HTTP middleware into a basic Node.js server. It sets up a server that serves static files from a 'demo' directory and uses `ModuleServer` to rewrite and serve ES modules from the same directory under the `/_m/` path. This setup is ideal for local development and testing of native ES modules in the browser without a separate bundling step.
Ensure all direct and transitive dependencies provide native ES module builds. Check their `package.json` for a `module` or `exports` field pointing to an ES module entry. If CJS dependencies are unavoidable, consider using a traditional bundler (e.g., Vite, Rollup) instead.
If you explicitly need to access modules multiple levels up from the root, increase the `--depth` command-line option or the `maxDepth` configuration for `ModuleServer` (e.g., `{ maxDepth: 3 }`). Exercise caution when increasing this value, especially in shared development environments.Always use CommonJS `require` syntax: `const { ModuleServer } = require('esmoduleserve/moduleserver')` when integrating the server programmatically into a Node.js environment.Verify that all your project's dependencies are ES module compatible. Check their `package.json` for a `module` or `exports` field pointing to an ES module entry. If not, you may need to find an ES module alternative or use a bundler.
Change your import statement to use CommonJS `require` syntax: `const { ModuleServer } = require('esmoduleserve/moduleserver')`.If intentional, increase the `maxDepth` option in your `ModuleServer` configuration (e.g., `{ maxDepth: 2 }`) or the `--depth` flag if using the CLI, to allow access to more parent directories. Consider the security implications before increasing this value.No dependency data recorded yet.