@t8/serve 0.1.18 → 0.1.19

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 CHANGED
@@ -4,11 +4,9 @@ import { createServer } from "node:http";
4
4
  import { extname } from "node:path";
5
5
 
6
6
  // src/bundle.ts
7
- import { exec as originalExec } from "node:child_process";
8
7
  import { rm } from "node:fs/promises";
9
8
  import { join } from "node:path";
10
- import { promisify } from "node:util";
11
- var exec = promisify(originalExec);
9
+ import { build } from "esbuild";
12
10
  async function bundle({ path = "", bundle: options } = {}) {
13
11
  if (!options) return;
14
12
  let normalizedOptions;
@@ -21,9 +19,13 @@ async function bundle({ path = "", bundle: options } = {}) {
21
19
  let inputFile = join(path, normalizedOptions.input ?? "index.ts");
22
20
  let outputFile = join(path, "dist", normalizedOptions.output ?? "index.js");
23
21
  await rm(join(path, "dist"), { recursive: true, force: true });
24
- await exec(
25
- `npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=browser --log-level=warning`
26
- );
22
+ await build({
23
+ entryPoints: [inputFile],
24
+ outfile: outputFile,
25
+ bundle: true,
26
+ platform: "browser",
27
+ logLevel: "warning"
28
+ });
27
29
  }
28
30
 
29
31
  // src/getFilePath.ts
package/dist/run.cjs CHANGED
@@ -7,11 +7,9 @@ var import_node_http = require("node:http");
7
7
  var import_node_path3 = require("node:path");
8
8
 
9
9
  // src/bundle.ts
10
- var import_node_child_process = require("node:child_process");
11
10
  var import_promises = require("node:fs/promises");
12
11
  var import_node_path = require("node:path");
13
- var import_node_util = require("node:util");
14
- var exec = (0, import_node_util.promisify)(import_node_child_process.exec);
12
+ var import_esbuild = require("esbuild");
15
13
  async function bundle({ path = "", bundle: options } = {}) {
16
14
  if (!options) return;
17
15
  let normalizedOptions;
@@ -24,9 +22,13 @@ async function bundle({ path = "", bundle: options } = {}) {
24
22
  let inputFile = (0, import_node_path.join)(path, normalizedOptions.input ?? "index.ts");
25
23
  let outputFile = (0, import_node_path.join)(path, "dist", normalizedOptions.output ?? "index.js");
26
24
  await (0, import_promises.rm)((0, import_node_path.join)(path, "dist"), { recursive: true, force: true });
27
- await exec(
28
- `npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=browser --log-level=warning`
29
- );
25
+ await (0, import_esbuild.build)({
26
+ entryPoints: [inputFile],
27
+ outfile: outputFile,
28
+ bundle: true,
29
+ platform: "browser",
30
+ logLevel: "warning"
31
+ });
30
32
  }
31
33
 
32
34
  // src/getFilePath.ts
package/dist/run.mjs CHANGED
@@ -6,11 +6,9 @@ import { createServer } from "node:http";
6
6
  import { extname } from "node:path";
7
7
 
8
8
  // src/bundle.ts
9
- import { exec as originalExec } from "node:child_process";
10
9
  import { rm } from "node:fs/promises";
11
10
  import { join } from "node:path";
12
- import { promisify } from "node:util";
13
- var exec = promisify(originalExec);
11
+ import { build } from "esbuild";
14
12
  async function bundle({ path = "", bundle: options } = {}) {
15
13
  if (!options) return;
16
14
  let normalizedOptions;
@@ -23,9 +21,13 @@ async function bundle({ path = "", bundle: options } = {}) {
23
21
  let inputFile = join(path, normalizedOptions.input ?? "index.ts");
24
22
  let outputFile = join(path, "dist", normalizedOptions.output ?? "index.js");
25
23
  await rm(join(path, "dist"), { recursive: true, force: true });
26
- await exec(
27
- `npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=browser --log-level=warning`
28
- );
24
+ await build({
25
+ entryPoints: [inputFile],
26
+ outfile: outputFile,
27
+ bundle: true,
28
+ platform: "browser",
29
+ logLevel: "warning"
30
+ });
29
31
  }
30
32
 
31
33
  // src/getFilePath.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/serve",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "node",
@@ -21,9 +21,9 @@
21
21
  "scripts": {
22
22
  "build": "npx npm-run-all clean -p compile compile-mjs-bin compile-cjs-bin",
23
23
  "clean": "node -e \"require('node:fs').rmSync('dist', {force: true, recursive: true});\"",
24
- "compile": "npx esbuild index.ts --bundle --outdir=dist --platform=node --format=esm",
25
- "compile-mjs-bin": "npx esbuild src/run.ts --bundle --outfile=dist/run.mjs --platform=node --format=esm",
26
- "compile-cjs-bin": "npx esbuild src/run.ts --bundle --outfile=dist/run.cjs --platform=node --format=cjs",
24
+ "compile": "npx esbuild index.ts --bundle --outdir=dist --platform=node --format=esm --external:esbuild",
25
+ "compile-mjs-bin": "npx esbuild src/run.ts --bundle --outfile=dist/run.mjs --platform=node --format=esm --external:esbuild",
26
+ "compile-cjs-bin": "npx esbuild src/run.ts --bundle --outfile=dist/run.cjs --platform=node --format=cjs --external:esbuild",
27
27
  "prepublishOnly": "npm run build",
28
28
  "preversion": "npx npm-run-all typecheck shape build",
29
29
  "shape": "npx codeshape",
@@ -32,5 +32,8 @@
32
32
  "devDependencies": {
33
33
  "@types/node": "^24.5.2",
34
34
  "typescript": "^5.9.2"
35
+ },
36
+ "dependencies": {
37
+ "esbuild": "^0.25.10"
35
38
  }
36
39
  }
package/src/bundle.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { exec as originalExec } from "node:child_process";
2
1
  import { rm } from "node:fs/promises";
3
2
  import { join } from "node:path";
4
- import { promisify } from "node:util";
3
+ import { build } from "esbuild";
5
4
  import type { BundleConfig } from "./BundleConfig";
6
5
  import type { Config } from "./Config";
7
6
 
8
- const exec = promisify(originalExec);
9
-
10
7
  export async function bundle({ path = "", bundle: options }: Config = {}) {
11
8
  if (!options) return;
12
9
 
@@ -23,7 +20,12 @@ export async function bundle({ path = "", bundle: options }: Config = {}) {
23
20
  let outputFile = join(path, "dist", normalizedOptions.output ?? "index.js");
24
21
 
25
22
  await rm(join(path, "dist"), { recursive: true, force: true });
26
- await exec(
27
- `npx esbuild ${inputFile} --outfile=${outputFile} --bundle --platform=browser --log-level=warning`,
28
- );
23
+
24
+ await build({
25
+ entryPoints: [inputFile],
26
+ outfile: outputFile,
27
+ bundle: true,
28
+ platform: "browser",
29
+ logLevel: "warning",
30
+ });
29
31
  }