@t8/serve 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -2
- package/dist/run.cjs +3 -2
- package/dist/run.mjs +3 -2
- package/package.json +1 -1
- package/src/Config.ts +6 -4
- package/src/bundle.ts +5 -2
- package/src/serve.ts +3 -1
package/dist/index.js
CHANGED
|
@@ -37,8 +37,9 @@ var import_node_util = require("node:util");
|
|
|
37
37
|
var exec = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
38
38
|
async function bundle({ path = "", bundle: options } = {}) {
|
|
39
39
|
if (!options) return;
|
|
40
|
-
let
|
|
41
|
-
let
|
|
40
|
+
let normalizedOptions = typeof options === "boolean" ? {} : options;
|
|
41
|
+
let inputFile = (0, import_node_path.join)(path, normalizedOptions.input ?? "index.ts");
|
|
42
|
+
let outputFile = (0, import_node_path.join)(path, "dist", normalizedOptions.output ?? "index.js");
|
|
42
43
|
await (0, import_promises.rm)((0, import_node_path.join)(path, "dist"), { recursive: true, force: true });
|
|
43
44
|
await exec(
|
|
44
45
|
`npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=neutral --log-level=warning`
|
package/dist/run.cjs
CHANGED
|
@@ -14,8 +14,9 @@ var import_node_util = require("node:util");
|
|
|
14
14
|
var exec = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
15
15
|
async function bundle({ path = "", bundle: options } = {}) {
|
|
16
16
|
if (!options) return;
|
|
17
|
-
let
|
|
18
|
-
let
|
|
17
|
+
let normalizedOptions = typeof options === "boolean" ? {} : options;
|
|
18
|
+
let inputFile = (0, import_node_path.join)(path, normalizedOptions.input ?? "index.ts");
|
|
19
|
+
let outputFile = (0, import_node_path.join)(path, "dist", normalizedOptions.output ?? "index.js");
|
|
19
20
|
await (0, import_promises.rm)((0, import_node_path.join)(path, "dist"), { recursive: true, force: true });
|
|
20
21
|
await exec(
|
|
21
22
|
`npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=neutral --log-level=warning`
|
package/dist/run.mjs
CHANGED
|
@@ -13,8 +13,9 @@ import { promisify } from "node:util";
|
|
|
13
13
|
var exec = promisify(originalExec);
|
|
14
14
|
async function bundle({ path = "", bundle: options } = {}) {
|
|
15
15
|
if (!options) return;
|
|
16
|
-
let
|
|
17
|
-
let
|
|
16
|
+
let normalizedOptions = typeof options === "boolean" ? {} : options;
|
|
17
|
+
let inputFile = join(path, normalizedOptions.input ?? "index.ts");
|
|
18
|
+
let outputFile = join(path, "dist", normalizedOptions.output ?? "index.js");
|
|
18
19
|
await rm(join(path, "dist"), { recursive: true, force: true });
|
|
19
20
|
await exec(
|
|
20
21
|
`npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=neutral --log-level=warning`
|
package/package.json
CHANGED
package/src/Config.ts
CHANGED
package/src/bundle.ts
CHANGED
|
@@ -9,8 +9,11 @@ const exec = promisify(originalExec);
|
|
|
9
9
|
export async function bundle({ path = "", bundle: options }: Config = {}) {
|
|
10
10
|
if (!options) return;
|
|
11
11
|
|
|
12
|
-
let
|
|
13
|
-
|
|
12
|
+
let normalizedOptions: Exclude<Config["bundle"], boolean | undefined> =
|
|
13
|
+
typeof options === "boolean" ? {} : options;
|
|
14
|
+
|
|
15
|
+
let inputFile = join(path, normalizedOptions.input ?? "index.ts");
|
|
16
|
+
let outputFile = join(path, "dist", normalizedOptions.output ?? "index.js");
|
|
14
17
|
|
|
15
18
|
await rm(join(path, "dist"), { recursive: true, force: true });
|
|
16
19
|
await exec(
|
package/src/serve.ts
CHANGED
|
@@ -9,7 +9,9 @@ import { mimeTypes } from "./mimeTypes";
|
|
|
9
9
|
const defaultHost = "localhost";
|
|
10
10
|
const defaultPort = 3000;
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type Server = ReturnType<typeof createServer>;
|
|
13
|
+
|
|
14
|
+
export async function serve(config: Config = {}): Promise<Server> {
|
|
13
15
|
let [, , host, , port] =
|
|
14
16
|
config.url?.match(/^(https?:\/\/)?([^:/]+)(:(\d+))?\/?/) ?? [];
|
|
15
17
|
|