@b9g/libuild 0.1.23 → 0.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b9g/libuild",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Zero-config library builds",
5
5
  "keywords": [
6
6
  "build",
@@ -1,8 +1,7 @@
1
1
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
2
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
3
  }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
5
  throw Error('Dynamic require of "' + x + '" is not supported');
7
6
  });
8
7
 
package/src/cli.js CHANGED
@@ -17,18 +17,12 @@ program.command("publish").description("Build and publish the library").argument
17
17
  const cwd = Path.resolve(directory);
18
18
  const shouldSave = options.save !== false;
19
19
  const npmArgs = [];
20
- if (options.dryRun)
21
- npmArgs.push("--dry-run");
22
- if (options.tag)
23
- npmArgs.push("--tag", options.tag);
24
- if (options.access)
25
- npmArgs.push("--access", options.access);
26
- if (options.registry)
27
- npmArgs.push("--registry", options.registry);
28
- if (options.otp)
29
- npmArgs.push("--otp", options.otp);
30
- if (options.provenance)
31
- npmArgs.push("--provenance");
20
+ if (options.dryRun) npmArgs.push("--dry-run");
21
+ if (options.tag) npmArgs.push("--tag", options.tag);
22
+ if (options.access) npmArgs.push("--access", options.access);
23
+ if (options.registry) npmArgs.push("--registry", options.registry);
24
+ if (options.otp) npmArgs.push("--otp", options.otp);
25
+ if (options.provenance) npmArgs.push("--provenance");
32
26
  await publish(cwd, shouldSave, npmArgs);
33
27
  });
34
28
  program.command("test").description("Run tests across platforms").argument("[directory]", "Directory containing tests", ".").option("-p, --platform <platforms...>", "Platforms to test on (bun, node, chromium, firefox, webkit)").option("--debug", "Keep browser open for debugging").option("-w, --watch", "Watch mode - re-run tests on file changes").option("--timeout <ms>", "Test timeout in milliseconds", "60000").action(async (directory, options) => {
package/src/libuild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./libuild.d.ts" />
2
- import "./_chunks/chunk-IBOCQ33F.js";
2
+ import "./_chunks/chunk-CH5RFCXH.js";
3
3
 
4
4
  // src/libuild.ts
5
5
  import * as FS3 from "fs/promises";
@@ -15,8 +15,7 @@ function umdPlugin(options) {
15
15
  name: "umd",
16
16
  setup(build3) {
17
17
  build3.onEnd(async (result) => {
18
- if (result.errors.length > 0)
19
- return;
18
+ if (result.errors.length > 0) return;
20
19
  const outputDir = build3.initialOptions.outdir;
21
20
  if (outputDir) {
22
21
  const files = await FS.readdir(outputDir);
@@ -185,8 +184,7 @@ async function addTripleSlashReferences(tsFiles, outDir, rootDir) {
185
184
  FS2.access(jsPath).then(() => true).catch(() => false),
186
185
  FS2.access(dtsPath).then(() => true).catch(() => false)
187
186
  ]);
188
- if (!jsExists || !dtsExists)
189
- continue;
187
+ if (!jsExists || !dtsExists) continue;
190
188
  const content = await FS2.readFile(jsPath, "utf-8");
191
189
  const referenceComment = `/// <reference types="./${baseName}.d.ts" />`;
192
190
  let modifiedContent;
@@ -214,8 +212,7 @@ async function addAmbientReferences(tsFiles, outDir, rootDir) {
214
212
  } catch {
215
213
  return;
216
214
  }
217
- if (ambientFiles.length === 0)
218
- return;
215
+ if (ambientFiles.length === 0) return;
219
216
  for (const tsFile of tsFiles) {
220
217
  const relativePath = Path2.relative(rootDir, tsFile);
221
218
  const relativeDir = Path2.dirname(relativePath);
@@ -223,8 +220,7 @@ async function addAmbientReferences(tsFiles, outDir, rootDir) {
223
220
  const outputSubDir = relativeDir === "." ? outDir : Path2.join(outDir, relativeDir);
224
221
  const dtsPath = Path2.join(outputSubDir, `${baseName}.d.ts`);
225
222
  const dtsExists = await FS2.access(dtsPath).then(() => true).catch(() => false);
226
- if (!dtsExists)
227
- continue;
223
+ if (!dtsExists) continue;
228
224
  const content = await FS2.readFile(dtsPath, "utf-8");
229
225
  const relativeToRoot = relativeDir === "." ? "./" : "../".repeat(relativeDir.split(Path2.sep).length);
230
226
  const references = ambientFiles.map((ambientFile) => `/// <reference path="${relativeToRoot}${ambientFile}" />`).join("\n");
@@ -268,26 +264,19 @@ async function processJavaScriptExecutable(filePath, runtimeBanner) {
268
264
  }
269
265
  }
270
266
  function isValidEntrypoint(filename) {
271
- if (!filename.endsWith(".ts") && !filename.endsWith(".js"))
272
- return false;
273
- if (filename.endsWith(".d.ts"))
274
- return false;
275
- if (filename.startsWith("_"))
276
- return false;
277
- if (filename.startsWith("."))
278
- return false;
279
- if (filename.includes(".test."))
280
- return false;
281
- if (filename.includes(".spec."))
282
- return false;
267
+ if (!filename.endsWith(".ts") && !filename.endsWith(".js")) return false;
268
+ if (filename.endsWith(".d.ts")) return false;
269
+ if (filename.startsWith("_")) return false;
270
+ if (filename.startsWith(".")) return false;
271
+ if (filename.includes(".test.")) return false;
272
+ if (filename.includes(".spec.")) return false;
283
273
  return true;
284
274
  }
285
275
  async function findEntrypoints(srcDir) {
286
276
  const files = await FS3.readdir(srcDir, { withFileTypes: true });
287
277
  return files.filter((dirent) => {
288
278
  if (dirent.isDirectory()) {
289
- if (dirent.name === "__tests__" || dirent.name === "test")
290
- return false;
279
+ if (dirent.name === "__tests__" || dirent.name === "test") return false;
291
280
  return false;
292
281
  }
293
282
  return isValidEntrypoint(dirent.name);
@@ -523,8 +512,7 @@ async function generateExports(entries, mainEntry, options, existingExports = {}
523
512
  }
524
513
  }
525
514
  for (const entry of entries) {
526
- if (entry === "umd")
527
- continue;
515
+ if (entry === "umd") continue;
528
516
  const key = `./${entry}`;
529
517
  if (!exports[key]) {
530
518
  exports[key] = await createExportEntry(entry);
@@ -700,6 +688,9 @@ function fixExportsForDist(obj) {
700
688
  if (obj.startsWith("./dist/src/")) {
701
689
  return obj.replace("./dist/src/", "./src/");
702
690
  }
691
+ if (obj.startsWith("./dist/bin/")) {
692
+ return obj.replace("./dist/bin/", "./bin/");
693
+ }
703
694
  if (obj.includes("/dist/") && obj.endsWith("/package.json")) {
704
695
  return "./package.json";
705
696
  }
@@ -776,8 +767,7 @@ async function makeFilesExecutable(pkg, cwd, allBinEntries, runtimeBanner) {
776
767
  }
777
768
  }
778
769
  async function resolveWorkspaceDependencies(dependencies, cwd) {
779
- if (!dependencies)
780
- return void 0;
770
+ if (!dependencies) return void 0;
781
771
  const resolved = {};
782
772
  for (const [depName, depVersion] of Object.entries(dependencies)) {
783
773
  if (depVersion.startsWith("workspace:")) {
@@ -954,11 +944,9 @@ async function build2(cwd, save = false) {
954
944
  let srcEntries;
955
945
  if (pkg.exports && typeof pkg.exports === "object") {
956
946
  const srcExportKeys = Object.keys(pkg.exports).filter((key) => {
957
- if (key === "." || key === "./package.json")
958
- return false;
947
+ if (key === "." || key === "./package.json") return false;
959
948
  const val = pkg.exports[key];
960
- if (typeof val === "string")
961
- return val.includes("/src/");
949
+ if (typeof val === "string") return val.includes("/src/");
962
950
  if (typeof val === "object" && val !== null) {
963
951
  return Object.values(val).some((v) => typeof v === "string" && v.includes("/src/"));
964
952
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./test-browser.d.ts" />
2
- import "./_chunks/chunk-IBOCQ33F.js";
2
+ import "./_chunks/chunk-CH5RFCXH.js";
3
3
 
4
4
  // src/test-browser.ts
5
5
  var ExpectError = class extends Error {
@@ -9,14 +9,10 @@ var ExpectError = class extends Error {
9
9
  }
10
10
  };
11
11
  function stringify(value) {
12
- if (value === void 0)
13
- return "undefined";
14
- if (value === null)
15
- return "null";
16
- if (typeof value === "function")
17
- return "[Function]";
18
- if (typeof value === "symbol")
19
- return value.toString();
12
+ if (value === void 0) return "undefined";
13
+ if (value === null) return "null";
14
+ if (typeof value === "function") return "[Function]";
15
+ if (typeof value === "symbol") return value.toString();
20
16
  try {
21
17
  return JSON.stringify(value);
22
18
  } catch {
@@ -24,25 +20,18 @@ function stringify(value) {
24
20
  }
25
21
  }
26
22
  function deepEqual(a, b) {
27
- if (a === b)
28
- return true;
29
- if (typeof a !== typeof b)
30
- return false;
31
- if (a === null || b === null)
32
- return a === b;
33
- if (typeof a !== "object")
34
- return a === b;
23
+ if (a === b) return true;
24
+ if (typeof a !== typeof b) return false;
25
+ if (a === null || b === null) return a === b;
26
+ if (typeof a !== "object") return a === b;
35
27
  if (Array.isArray(a) && Array.isArray(b)) {
36
- if (a.length !== b.length)
37
- return false;
28
+ if (a.length !== b.length) return false;
38
29
  return a.every((item, i) => deepEqual(item, b[i]));
39
30
  }
40
- if (Array.isArray(a) !== Array.isArray(b))
41
- return false;
31
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
42
32
  const aKeys = Object.keys(a);
43
33
  const bKeys = Object.keys(b);
44
- if (aKeys.length !== bKeys.length)
45
- return false;
34
+ if (aKeys.length !== bKeys.length) return false;
46
35
  return aKeys.every(
47
36
  (key) => deepEqual(
48
37
  a[key],
@@ -293,19 +282,16 @@ queueMicrotask(async () => {
293
282
  try {
294
283
  for (const suite of chain) {
295
284
  if (!suiteRan.has(suite)) {
296
- for (const hook of suite.beforeAll)
297
- await hook();
285
+ for (const hook of suite.beforeAll) await hook();
298
286
  suiteRan.add(suite);
299
287
  }
300
288
  }
301
289
  for (const suite of chain) {
302
- for (const hook of suite.beforeEach)
303
- await hook();
290
+ for (const hook of suite.beforeEach) await hook();
304
291
  }
305
292
  await t.fn();
306
293
  for (const suite of [...chain].reverse()) {
307
- for (const hook of suite.afterEach)
308
- await hook();
294
+ for (const hook of suite.afterEach) await hook();
309
295
  }
310
296
  console.log("\u2713", fullName);
311
297
  globalThis.__LIBUILD_TEST__.passed++;
@@ -320,8 +306,7 @@ queueMicrotask(async () => {
320
306
  }
321
307
  }
322
308
  for (const suite of [...suiteRan].reverse()) {
323
- for (const hook of suite.afterAll)
324
- await hook();
309
+ for (const hook of suite.afterAll) await hook();
325
310
  }
326
311
  globalThis.__LIBUILD_TEST__.ended = true;
327
312
  });
package/src/test-bun.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./test-bun.d.ts" />
2
- import "./_chunks/chunk-IBOCQ33F.js";
2
+ import "./_chunks/chunk-CH5RFCXH.js";
3
3
 
4
4
  // src/test-bun.ts
5
5
  import {
package/src/test-node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./test-node.d.ts" />
2
- import "./_chunks/chunk-IBOCQ33F.js";
2
+ import "./_chunks/chunk-CH5RFCXH.js";
3
3
 
4
4
  // src/test-node.ts
5
5
  import {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="./test-runner.d.ts" />
2
2
  import {
3
3
  __require
4
- } from "./_chunks/chunk-IBOCQ33F.js";
4
+ } from "./_chunks/chunk-CH5RFCXH.js";
5
5
 
6
6
  // src/test-runner.ts
7
7
  import * as FS from "fs/promises";
@@ -188,10 +188,8 @@ function parseBunOutput(output) {
188
188
  const errors = [];
189
189
  const passMatch = output.match(/^\s*(\d+)\s+pass/m);
190
190
  const failMatch = output.match(/^\s*(\d+)\s+fail/m);
191
- if (passMatch)
192
- passed = parseInt(passMatch[1], 10);
193
- if (failMatch)
194
- failed = parseInt(failMatch[1], 10);
191
+ if (passMatch) passed = parseInt(passMatch[1], 10);
192
+ if (failMatch) failed = parseInt(failMatch[1], 10);
195
193
  return { passed, failed, errors };
196
194
  }
197
195
  async function runBunTests(bundlePath, timeout) {
package/src/test.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  * Provides a unified testing API across Bun, Node, and browsers.
5
5
  * Uses top-level await to detect runtime and load appropriate shim.
6
6
  */
7
- declare const describe: typeof import("node:test").describe | import("bun:test").Describe<[]>, test: typeof import("node:test") | import("bun:test").Test<[]>, it: typeof import("node:test") | import("bun:test").Test<[]>, expect: import("expect").Expect | import("bun:test").Expect, beforeAll: typeof import("node:test").before | typeof import("bun:test").beforeAll, afterAll: typeof import("node:test").after | typeof import("bun:test").afterAll, beforeEach: typeof import("node:test").beforeEach | typeof import("bun:test").beforeEach, afterEach: typeof import("node:test").afterEach | typeof import("bun:test").afterEach;
7
+ declare const describe: any, test: any, it: any, expect: any, beforeAll: any, afterAll: any, beforeEach: any, afterEach: any;
8
8
  export { describe, test, it, expect, beforeAll, afterAll, beforeEach, afterEach, };
package/src/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="./test.d.ts" />
2
- import "./_chunks/chunk-IBOCQ33F.js";
2
+ import "./_chunks/chunk-CH5RFCXH.js";
3
3
 
4
4
  // src/test.ts
5
5
  var isBun = typeof Bun !== "undefined";