@jayjiang/byoao 1.0.3 → 1.0.4
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/lib/cjs-modules.js +38 -14
- package/dist/lib/cjs-modules.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/cjs-modules.js
CHANGED
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bun CJS interop shim.
|
|
3
3
|
*
|
|
4
|
-
* Bun 1.3.x
|
|
5
|
-
*
|
|
4
|
+
* Bun 1.3.x cannot reliably load the CJS build of packages that have an
|
|
5
|
+
* `exports` field (e.g. fs-extra): `import default` gives "Missing 'default'
|
|
6
|
+
* export" and `createRequire` gives "require() async module".
|
|
6
7
|
*
|
|
7
|
-
* For fs-extra we
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* For fs-extra we build a combined ESM-native namespace from node:fs,
|
|
9
|
+
* node:fs/promises, and fs-extra's own ESM subpath (which deliberately
|
|
10
|
+
* excludes node:fs re-exports).
|
|
11
|
+
*
|
|
12
|
+
* For packages without an `exports` field (handlebars, gray-matter, semver)
|
|
13
|
+
* createRequire works fine in both Bun and Node.js.
|
|
10
14
|
*/
|
|
11
15
|
import { createRequire } from "node:module";
|
|
16
|
+
// ── node:fs ──────────────────────────────────────────────────────────────────
|
|
17
|
+
import { existsSync, readFileSync, readdirSync, } from "node:fs";
|
|
18
|
+
// ── node:fs/promises ─────────────────────────────────────────────────────────
|
|
19
|
+
import { readFile, writeFile, readdir, } from "node:fs/promises";
|
|
20
|
+
// ── fs-extra ESM subpath ─────────────────────────────────────────────────────
|
|
21
|
+
// "fs-extra/esm" is a proper ESM module with named + default exports.
|
|
22
|
+
// It intentionally omits node:fs re-exports (those come from node:fs above).
|
|
23
|
+
import { copy, ensureDir, pathExists, pathExistsSync, readJson, readJsonSync, writeJson, writeJsonSync, remove, removeSync, } from "fs-extra/esm";
|
|
24
|
+
// Expose a unified `fs` object that matches the subset the codebase uses.
|
|
25
|
+
// Typed as FsExtra so callers keep full type-safety without changing their code.
|
|
26
|
+
export const fs = {
|
|
27
|
+
existsSync,
|
|
28
|
+
readFileSync,
|
|
29
|
+
readdirSync,
|
|
30
|
+
readFile,
|
|
31
|
+
writeFile,
|
|
32
|
+
readdir,
|
|
33
|
+
copy,
|
|
34
|
+
ensureDir,
|
|
35
|
+
pathExists,
|
|
36
|
+
pathExistsSync,
|
|
37
|
+
readJson,
|
|
38
|
+
readJsonSync,
|
|
39
|
+
writeJson,
|
|
40
|
+
writeJsonSync,
|
|
41
|
+
remove,
|
|
42
|
+
removeSync,
|
|
43
|
+
};
|
|
44
|
+
// ── CJS-only packages (no `exports` field — createRequire works in Bun) ──────
|
|
12
45
|
const _require = createRequire(import.meta.url);
|
|
13
|
-
// Bun 1.3.x treats `require("fs-extra")` (via createRequire) as an async module
|
|
14
|
-
// due to a bug in how it handles the package's `exports` field — use the CJS
|
|
15
|
-
// entry path directly to avoid this. Node.js enforces `exports` and rejects
|
|
16
|
-
// that subpath, so we fall back to the normal package name there.
|
|
17
|
-
const _fs = ("Bun" in globalThis
|
|
18
|
-
? _require("fs-extra/lib/index.js") // Bun: bypass exports resolution
|
|
19
|
-
: _require("fs-extra") // Node.js: normal resolution
|
|
20
|
-
);
|
|
21
46
|
const _matter = _require("gray-matter");
|
|
22
47
|
const _Handlebars = _require("handlebars");
|
|
23
48
|
const _semver = _require("semver");
|
|
24
49
|
const unwrap = (v) => (v["default"] ?? v);
|
|
25
|
-
export const fs = unwrap(_fs);
|
|
26
50
|
export const matter = unwrap(_matter);
|
|
27
51
|
export const Handlebars = unwrap(_Handlebars);
|
|
28
52
|
export const semver = unwrap(_semver);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cjs-modules.js","sourceRoot":"","sources":["../../src/lib/cjs-modules.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cjs-modules.js","sourceRoot":"","sources":["../../src/lib/c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