@b9g/libuild 0.1.11 → 0.1.13

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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.13] - 2025-01-14
6
+
7
+ ### Fixed
8
+ - **Dual runtime shebang for src/ executables** - src/ files referenced in package.json bin field now correctly receive dual runtime shebang support (previously only bin/ directory files were processed)
9
+ - All executable files now have consistent dual runtime behavior regardless of directory location
10
+
11
+ ## [0.1.12] - 2025-01-14
12
+
13
+ ### Added
14
+ - **Dual runtime support** for bin entries with intelligent bun/node detection based on package manager context
15
+ - **Top-level await (TLA) support** with graceful CJS fallback - automatically disables CJS generation when TLA is detected
16
+ - **bin/ directory support** for executable entrypoints alongside src/ entries
17
+ - Respect `engines.bun` field for runtime preferences in dual runtime detection
18
+ - Automatic shebang replacement with shell script wrapper for maximum compatibility
19
+
20
+ ### Changed
21
+ - **Single-batch ESM build** - combined src/ and bin/ builds for better performance
22
+ - **Smart externalization** - entry points are externalized, nested files are bundled to prevent code duplication
23
+ - TypeScript declarations now conditional on tsc availability (no failures in environments without TypeScript)
24
+
25
+ ### Fixed
26
+ - Fix TypeScript declaration generation for bin entries
27
+ - Fix CLI argument parsing for directory paths with npm flags
28
+ - Fix externalization to only apply to entry points, not nested utility files
29
+
5
30
  ## [0.1.11] - 2025-11-02
6
31
 
7
32
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b9g/libuild",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Zero-config library builds",
5
5
  "keywords": [
6
6
  "build",
package/src/cli.cjs CHANGED
@@ -83,7 +83,42 @@ async function main() {
83
83
  process.exit(0);
84
84
  }
85
85
  const command = positionals[0] || "build";
86
- const targetDir = positionals[1];
86
+ let targetDir;
87
+ for (let i = 1; i < positionals.length; i++) {
88
+ const arg = positionals[i];
89
+ const flagValueFlags = ["--tag", "--access", "--registry", "--otp", "--workspace"];
90
+ const isValueForFlag = flagValueFlags.some((flag) => {
91
+ const flagIndex = process.argv.indexOf(flag);
92
+ const argIndex = process.argv.indexOf(arg);
93
+ return flagIndex !== -1 && argIndex === flagIndex + 1;
94
+ });
95
+ if (isValueForFlag) {
96
+ continue;
97
+ }
98
+ if (!arg.startsWith("--")) {
99
+ try {
100
+ const isSystemPath = Path.isAbsolute(arg) && (arg.startsWith("/bin/") || arg.startsWith("/usr/") || arg.startsWith("/etc/") || arg.startsWith("/var/") || arg.startsWith("/opt/") || arg.startsWith("/tmp/") || arg.startsWith("/System/") || arg.startsWith("/Applications/"));
101
+ if (isSystemPath) {
102
+ continue;
103
+ }
104
+ const resolvedPath = Path.resolve(arg);
105
+ if (arg.includes("/") || arg.includes("\\") || arg === "." || arg === ".." || arg.startsWith("./") || arg.startsWith("../")) {
106
+ targetDir = arg;
107
+ break;
108
+ }
109
+ const fs = await import("fs/promises");
110
+ try {
111
+ const stat = await fs.stat(resolvedPath);
112
+ if (stat.isDirectory() && !Path.isAbsolute(arg)) {
113
+ targetDir = arg;
114
+ break;
115
+ }
116
+ } catch {
117
+ }
118
+ } catch {
119
+ }
120
+ }
121
+ }
87
122
  const cwd = targetDir ? Path.resolve(targetDir) : process.cwd();
88
123
  const shouldSave = values.save || command === "publish" && !values["no-save"];
89
124
  const allowedNpmFlags = [
@@ -98,7 +133,8 @@ async function main() {
98
133
  "--include-workspace-root"
99
134
  ];
100
135
  const rawExtraArgs = process.argv.slice(2).filter(
101
- (arg) => !["build", "publish"].includes(arg) && !["--save", "--no-save", "--help", "-h", "--version", "-v"].includes(arg)
136
+ (arg) => !["build", "publish"].includes(arg) && !["--save", "--no-save", "--help", "-h", "--version", "-v"].includes(arg) && arg !== targetDir
137
+ // Don't filter out the target directory
102
138
  );
103
139
  const extraArgs = [];
104
140
  for (let i = 0; i < rawExtraArgs.length; i++) {
package/src/cli.js CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env sh
2
+ //bin/true; exec "$({ [ "${npm_config_user_agent#bun/}" != "$npm_config_user_agent" ] || true; } && command -v bun || command -v node)" "$0" "$@"
2
3
  /// <reference types="./cli.d.ts" />
3
4
 
4
5
  // src/cli.ts
@@ -61,7 +62,42 @@ async function main() {
61
62
  process.exit(0);
62
63
  }
63
64
  const command = positionals[0] || "build";
64
- const targetDir = positionals[1];
65
+ let targetDir;
66
+ for (let i = 1; i < positionals.length; i++) {
67
+ const arg = positionals[i];
68
+ const flagValueFlags = ["--tag", "--access", "--registry", "--otp", "--workspace"];
69
+ const isValueForFlag = flagValueFlags.some((flag) => {
70
+ const flagIndex = process.argv.indexOf(flag);
71
+ const argIndex = process.argv.indexOf(arg);
72
+ return flagIndex !== -1 && argIndex === flagIndex + 1;
73
+ });
74
+ if (isValueForFlag) {
75
+ continue;
76
+ }
77
+ if (!arg.startsWith("--")) {
78
+ try {
79
+ const isSystemPath = Path.isAbsolute(arg) && (arg.startsWith("/bin/") || arg.startsWith("/usr/") || arg.startsWith("/etc/") || arg.startsWith("/var/") || arg.startsWith("/opt/") || arg.startsWith("/tmp/") || arg.startsWith("/System/") || arg.startsWith("/Applications/"));
80
+ if (isSystemPath) {
81
+ continue;
82
+ }
83
+ const resolvedPath = Path.resolve(arg);
84
+ if (arg.includes("/") || arg.includes("\\") || arg === "." || arg === ".." || arg.startsWith("./") || arg.startsWith("../")) {
85
+ targetDir = arg;
86
+ break;
87
+ }
88
+ const fs = await import("fs/promises");
89
+ try {
90
+ const stat = await fs.stat(resolvedPath);
91
+ if (stat.isDirectory() && !Path.isAbsolute(arg)) {
92
+ targetDir = arg;
93
+ break;
94
+ }
95
+ } catch {
96
+ }
97
+ } catch {
98
+ }
99
+ }
100
+ }
65
101
  const cwd = targetDir ? Path.resolve(targetDir) : process.cwd();
66
102
  const shouldSave = values.save || command === "publish" && !values["no-save"];
67
103
  const allowedNpmFlags = [
@@ -76,7 +112,8 @@ async function main() {
76
112
  "--include-workspace-root"
77
113
  ];
78
114
  const rawExtraArgs = process.argv.slice(2).filter(
79
- (arg) => !["build", "publish"].includes(arg) && !["--save", "--no-save", "--help", "-h", "--version", "-v"].includes(arg)
115
+ (arg) => !["build", "publish"].includes(arg) && !["--save", "--no-save", "--help", "-h", "--version", "-v"].includes(arg) && arg !== targetDir
116
+ // Don't filter out the target directory
80
117
  );
81
118
  const extraArgs = [];
82
119
  for (let i = 0; i < rawExtraArgs.length; i++) {