barely-a-dev-server
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "barely-a-dev-server", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "", |
# `barely-a-dev-server` | ||
A thin, opinionated wrapper for `esbuild` as a `.ts` web server. Given a `srcRoot` folder, it: | ||
A thin, opinionated wrapper for `esbuild` as a `.ts` web server. Given a `entryRoot` folder, it: | ||
- finds all `.ts` file in `srcRoot` and uses them as entry files to run `esbuild` in `watch` mode, and | ||
- serves the built `.js` files together with a fallback to `srcRoot` for static files. | ||
- finds all `.ts` file in `entryRoot` and uses them as entry files to run `esbuild` in `watch` mode, and | ||
- serves the built `.js` files together with a fallback to `entryRoot` for static files. | ||
@@ -17,4 +17,4 @@ When run with `"dev": false`, it writes these files to an output dir (`dist/` + the source root by default), ready to serve using your favorite static file server. | ||
barelyServe({ | ||
srcRoot: "src/sites", | ||
dev, | ||
entryRoot: "src/sites", // the only required arg | ||
dev: true, | ||
port: 3333, | ||
@@ -21,0 +21,0 @@ esbuildOptions: { |
@@ -41,5 +41,5 @@ import { cp } from "fs/promises"; | ||
export async function barelyServe(options) { | ||
let { debug, dev, esbuildOptions, outDir, port, srcRoot, type } = options; | ||
if (!srcRoot) { | ||
throw new Error("Must specify `srcRoot`"); | ||
let { debug, dev, esbuildOptions, outDir, port, entryRoot, type } = options; | ||
if (!entryRoot) { | ||
throw new Error("Must specify `entryRoot`"); | ||
} | ||
@@ -51,8 +51,8 @@ debug ??= false; | ||
port ??= 1234; | ||
outDir ??= join(dev ? "dist/dev" : "dist", srcRoot); | ||
outDir ??= join(dev ? "dist/dev" : "dist", entryRoot); | ||
await restartEsbuild(srcRoot, outDir, dev, esbuildOptions); | ||
await restartEsbuild(entryRoot, outDir, dev, esbuildOptions); | ||
if (dev) { | ||
new CustomServer({ | ||
rootPaths: [outDir, srcRoot], | ||
rootPaths: [outDir, entryRoot], | ||
port, | ||
@@ -63,4 +63,4 @@ debug, | ||
// TODO: filter out `.ts` if they don't work for source maps? | ||
await cp(srcRoot, outDir, { recursive: true }); | ||
await cp(entryRoot, outDir, { recursive: true }); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8943