From b65a7f3752db9b32e833cddab51b296d89310814 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Wed, 8 Jan 2025 12:11:36 +0100 Subject: [PATCH 01/14] allow importing `bun.lock` (+ types for it) --- packages/bun-types/ambient.d.ts | 5 +++ packages/bun-types/bun.d.ts | 71 +++++++++++++++++++++++++++++++++ src/bun.js/module_loader.zig | 2 + src/fs.zig | 15 +++++-- src/options.zig | 24 +++++++---- 5 files changed, 107 insertions(+), 10 deletions(-) diff --git a/packages/bun-types/ambient.d.ts b/packages/bun-types/ambient.d.ts index b4ac81a0a3e277..503b91be6ed328 100644 --- a/packages/bun-types/ambient.d.ts +++ b/packages/bun-types/ambient.d.ts @@ -7,3 +7,8 @@ declare module "*.toml" { var contents: any; export = contents; } + +declare module '*bun.lock' { + var contents: import("bun").BunLockFile; + export = contents; +} diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index e4f66b59f93faa..cb130374d7fb32 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -6417,6 +6417,77 @@ declare module "bun" { */ timestamp?: number | Date, ): Buffer; + + /** + * Types for `bun.lock` + */ + type BunLockFile = { + lockfileVersion: 0; + workspaces: { + [workspace: string]: { + name?: string; + version?: string; + dependencies?: Record; + devDependencies?: Record; + optionalDependencies?: Record; + peerDependencies?: Record; + }; + }; + trustedDependencies?: string[]; + + /** + * ``` + * INFO = { prod/dev/optional/peer dependencies, os, cpu, libc (TODO), bin, binDir } + * + * npm -> [ "name@version", registry (TODO: remove if default), INFO, integrity] + * symlink -> [ "name@link:path", INFO ] + * folder -> [ "name@file:path", INFO ] + * workspace -> [ "name@workspace:path", INFO ] + * tarball -> [ "name@tarball", INFO ] + * root -> [ "name@root:", { bin, binDir } ] + * git -> [ "name@git+repo", INFO, .bun-tag string (TODO: remove this) ] + * github -> [ "name@github:user/repo", INFO, .bun-tag string (TODO: remove this) ] + * ``` + * */ + packages: { + [package: string]: + | { + /** npm */ + 1: string; + 2: string; + 3: BunLockFilePackageInfo; + 4: string; + } + | { + /** symlink, folder, tarball, workspace */ + 1: string; + 2: BunLockFilePackageInfo; + } + | { + /** git, github */ + 1: string; + 2: BunLockFilePackageInfo; + 3: string; + } + | { + /** root */ + 1: string; + 2: Pick + } + | ({} & []); + }; + }; + + type BunLockFilePackageInfo = { + dependencies?: Record; + optionalDependencies?: Record; + devDependencies?: Record; + peerDependencies?: Record; + os?: string | string[]; + cpu?: string | string[]; + bin?: Record; + binDir?: string; + }; } // extends lib.dom.d.ts diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 8b7103acf1cfe1..bb564975ef7595 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -2326,6 +2326,8 @@ pub const ModuleLoader = struct { loader = .ts; } else if (attribute.eqlComptime("tsx")) { loader = .tsx; + } else if (attribute.eqlComptime("bun.lock")) { + loader = .json; } } diff --git a/src/fs.zig b/src/fs.zig index b1feeadd4b5165..850bccf5fe81ab 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1608,8 +1608,13 @@ pub const PathName = struct { // Strip off the extension if (strings.lastIndexOfChar(base, '.')) |dot| { - ext = base[dot..]; - base = base[0..dot]; + if (strings.endsWith(base, "bun.lock")) { + ext = "bun.lock"; + base = ""; + } else { + ext = base[dot..]; + base = base[0..dot]; + } } else { ext = ""; } @@ -1713,7 +1718,11 @@ pub const Path = struct { pub fn isJSONCFile(this: *const Path) bool { const str = this.name.filename; - if (strings.eqlComptime(str, "package.json")) { + if (strings.eqlComptime(str, "package.json") or strings.eqlComptime(str, "bun.lock")) { + return true; + } + + if (strings.hasSuffixComptime(str, ".jsonc")) { return true; } diff --git a/src/options.zig b/src/options.zig index 63e6582d1a3618..b1682ff9268cb4 100644 --- a/src/options.zig +++ b/src/options.zig @@ -758,6 +758,7 @@ pub const Loader = enum(u8) { .{ "css", .css }, .{ "file", .file }, .{ "json", .json }, + .{ "jsonc", .json }, .{ "toml", .toml }, .{ "wasm", .wasm }, .{ "node", .napi }, @@ -769,6 +770,7 @@ pub const Loader = enum(u8) { .{ "sqlite", .sqlite }, .{ "sqlite_embedded", .sqlite_embedded }, .{ "html", .html }, + .{ "bun.lock", .json }, }); pub const api_names = bun.ComptimeStringMap(Api.Loader, .{ @@ -783,6 +785,7 @@ pub const Loader = enum(u8) { .{ "css", .css }, .{ "file", .file }, .{ "json", .json }, + .{ "jsonc", .json }, .{ "toml", .toml }, .{ "wasm", .wasm }, .{ "node", .napi }, @@ -793,6 +796,7 @@ pub const Loader = enum(u8) { .{ "sh", .file }, .{ "sqlite", .sqlite }, .{ "html", .html }, + .{ "bun.lock", .json }, }); pub fn fromString(slice_: string) ?Loader { @@ -908,6 +912,8 @@ const default_loaders_posix = .{ .{ ".txt", .text }, .{ ".text", .text }, .{ ".html", .html }, + .{ ".jsonc", .json }, + .{ "bun.lock", .json }, }; const default_loaders_win32 = default_loaders_posix ++ .{ .{ ".sh", .bunsh }, @@ -1286,16 +1292,18 @@ pub fn definesFromTransformOptions( const default_loader_ext_bun = [_]string{".node"}; const default_loader_ext = [_]string{ - ".jsx", ".json", - ".js", ".mjs", - ".cjs", ".css", + ".jsx", ".json", + ".js", ".mjs", + ".cjs", ".css", // https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#new-file-extensions - ".ts", ".tsx", - ".mts", ".cts", + ".ts", ".tsx", + ".mts", ".cts", - ".toml", ".wasm", - ".txt", ".text", + ".toml", ".wasm", + ".txt", ".text", + + "bun.lock", ".jsonc", }; // Only set it for browsers by default. @@ -1314,12 +1322,14 @@ const node_modules_default_loader_ext = [_]string{ ".toml", ".txt", ".json", + ".jsonc", ".css", ".tsx", ".cts", ".wasm", ".text", ".html", + "bun.lock", }; pub const ResolveFileExtensions = struct { From 963d21af5461f342b3bcd471c6df22ff7d26d835 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Wed, 8 Jan 2025 12:15:09 +0100 Subject: [PATCH 02/14] jsonc --- packages/bun-types/ambient.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/bun-types/ambient.d.ts b/packages/bun-types/ambient.d.ts index 503b91be6ed328..357dc31442320d 100644 --- a/packages/bun-types/ambient.d.ts +++ b/packages/bun-types/ambient.d.ts @@ -8,6 +8,11 @@ declare module "*.toml" { export = contents; } +declare module "*.jsonc" { + var contents: any; + export = contents; +} + declare module '*bun.lock' { var contents: import("bun").BunLockFile; export = contents; From 1be4b090d3aba21e018ac102c6e36e4ef6d8efb8 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Wed, 8 Jan 2025 12:17:38 +0100 Subject: [PATCH 03/14] . --- packages/bun-types/ambient.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bun-types/ambient.d.ts b/packages/bun-types/ambient.d.ts index 357dc31442320d..a69f0ba805d74d 100644 --- a/packages/bun-types/ambient.d.ts +++ b/packages/bun-types/ambient.d.ts @@ -14,6 +14,6 @@ declare module "*.jsonc" { } declare module '*bun.lock' { - var contents: import("bun").BunLockFile; + var contents: import("bun").BunLockFile; export = contents; } From 5a106d1d3df87f9d65ce7116ef328d91b488769f Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Wed, 8 Jan 2025 14:09:18 +0100 Subject: [PATCH 04/14] base --- src/fs.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fs.zig b/src/fs.zig index 850bccf5fe81ab..e58c917a5c6f14 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1610,7 +1610,7 @@ pub const PathName = struct { if (strings.lastIndexOfChar(base, '.')) |dot| { if (strings.endsWith(base, "bun.lock")) { ext = "bun.lock"; - base = ""; + base = base[0..(base.len - "bun.lock".len)]; } else { ext = base[dot..]; base = base[0..dot]; From 03cb25a2a4aabeb152c08ef27e19100f23bf1596 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Thu, 9 Jan 2025 02:07:19 +0100 Subject: [PATCH 05/14] better types --- packages/bun-types/ambient.d.ts | 2 +- packages/bun-types/bun.d.ts | 34 +++++++++------------------------ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/packages/bun-types/ambient.d.ts b/packages/bun-types/ambient.d.ts index a69f0ba805d74d..40caf19001263f 100644 --- a/packages/bun-types/ambient.d.ts +++ b/packages/bun-types/ambient.d.ts @@ -13,7 +13,7 @@ declare module "*.jsonc" { export = contents; } -declare module '*bun.lock' { +declare module "*bun.lock" { var contents: import("bun").BunLockFile; export = contents; } diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index cb130374d7fb32..da9a26ebc367f8 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -6450,31 +6450,15 @@ declare module "bun" { * ``` * */ packages: { - [package: string]: - | { - /** npm */ - 1: string; - 2: string; - 3: BunLockFilePackageInfo; - 4: string; - } - | { - /** symlink, folder, tarball, workspace */ - 1: string; - 2: BunLockFilePackageInfo; - } - | { - /** git, github */ - 1: string; - 2: BunLockFilePackageInfo; - 3: string; - } - | { - /** root */ - 1: string; - 2: Pick - } - | ({} & []); + [pkg: string]: /**/ + /** npm */ + | [pkg: string, registry: string, info: BunLockFilePackageInfo, integrity: string] + /** symlink, folder, tarball, workspace */ + | [pkg: string, info: BunLockFilePackageInfo] + /** git, github */ + | [pkg: string, info: BunLockFilePackageInfo, bunTag: string] + /** root */ + | [pkg: string, info: Pick]; }; }; From 1616b177a98299a15be528698a277755a1052e0e Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Thu, 9 Jan 2025 02:14:36 +0100 Subject: [PATCH 06/14] patchedDependencies --- packages/bun-types/bun.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index da9a26ebc367f8..ebfdb7d92d2be6 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -6431,6 +6431,7 @@ declare module "bun" { devDependencies?: Record; optionalDependencies?: Record; peerDependencies?: Record; + patchedDependencies?: Record; }; }; trustedDependencies?: string[]; From de9a0be1709fb58271541333e6cafdc9db8fa517 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Thu, 9 Jan 2025 02:15:23 +0100 Subject: [PATCH 07/14] woops --- packages/bun-types/bun.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index ebfdb7d92d2be6..a7572da5ce7b4d 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -6431,9 +6431,9 @@ declare module "bun" { devDependencies?: Record; optionalDependencies?: Record; peerDependencies?: Record; - patchedDependencies?: Record; }; }; + patchedDependencies?: Record; trustedDependencies?: string[]; /** From 1aa6f09226697b29f520d3db69962126b63106cf Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Thu, 9 Jan 2025 02:31:48 +0100 Subject: [PATCH 08/14] more types --- packages/bun-types/bun.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index a7572da5ce7b4d..fa04174f021400 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -6431,8 +6431,10 @@ declare module "bun" { devDependencies?: Record; optionalDependencies?: Record; peerDependencies?: Record; + optionalPeers?: string[] }; }; + overrides?: Record; patchedDependencies?: Record; trustedDependencies?: string[]; @@ -6468,10 +6470,12 @@ declare module "bun" { optionalDependencies?: Record; devDependencies?: Record; peerDependencies?: Record; + optionalPeers?: string[]; os?: string | string[]; cpu?: string | string[]; bin?: Record; binDir?: string; + bundled?: true; }; } From ca132c022b00dd50dc2d266ffa2722fd4daecd22 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Fri, 10 Jan 2025 10:37:55 +0100 Subject: [PATCH 09/14] require full filename to be `bun.lock` --- packages/bun-types/ambient.d.ts | 2 +- src/fs.zig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bun-types/ambient.d.ts b/packages/bun-types/ambient.d.ts index 40caf19001263f..bd10bfb0d35e66 100644 --- a/packages/bun-types/ambient.d.ts +++ b/packages/bun-types/ambient.d.ts @@ -13,7 +13,7 @@ declare module "*.jsonc" { export = contents; } -declare module "*bun.lock" { +declare module "*/bun.lock" { var contents: import("bun").BunLockFile; export = contents; } diff --git a/src/fs.zig b/src/fs.zig index e58c917a5c6f14..fd1effd4a71c56 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1608,9 +1608,9 @@ pub const PathName = struct { // Strip off the extension if (strings.lastIndexOfChar(base, '.')) |dot| { - if (strings.endsWith(base, "bun.lock")) { + if (strings.eqlComptime(base, "bun.lock")) { ext = "bun.lock"; - base = base[0..(base.len - "bun.lock".len)]; + base = ""; } else { ext = base[dot..]; base = base[0..dot]; From 157786bb2adcd4a05b5cdc283dc3b26515e3d84e Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Fri, 10 Jan 2025 11:08:54 +0100 Subject: [PATCH 10/14] lol i really did overcomplicate everything --- src/bun.js/module_loader.zig | 6 ++++-- src/fs.zig | 9 ++------- src/options.zig | 6 +----- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index bb564975ef7595..019352a346cfda 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -2326,11 +2326,13 @@ pub const ModuleLoader = struct { loader = .ts; } else if (attribute.eqlComptime("tsx")) { loader = .tsx; - } else if (attribute.eqlComptime("bun.lock")) { - loader = .json; } } + if (strings.eqlComptime(path.name.filename, "bun.lock")) { + loader = .json; + } + // We only run the transpiler concurrently when we can. // Today, that's: // diff --git a/src/fs.zig b/src/fs.zig index fd1effd4a71c56..fff9b10a92a3a6 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1608,13 +1608,8 @@ pub const PathName = struct { // Strip off the extension if (strings.lastIndexOfChar(base, '.')) |dot| { - if (strings.eqlComptime(base, "bun.lock")) { - ext = "bun.lock"; - base = ""; - } else { - ext = base[dot..]; - base = base[0..dot]; - } + ext = base[dot..]; + base = base[0..dot]; } else { ext = ""; } diff --git a/src/options.zig b/src/options.zig index b1682ff9268cb4..f8eb32e77071b3 100644 --- a/src/options.zig +++ b/src/options.zig @@ -770,7 +770,6 @@ pub const Loader = enum(u8) { .{ "sqlite", .sqlite }, .{ "sqlite_embedded", .sqlite_embedded }, .{ "html", .html }, - .{ "bun.lock", .json }, }); pub const api_names = bun.ComptimeStringMap(Api.Loader, .{ @@ -796,7 +795,6 @@ pub const Loader = enum(u8) { .{ "sh", .file }, .{ "sqlite", .sqlite }, .{ "html", .html }, - .{ "bun.lock", .json }, }); pub fn fromString(slice_: string) ?Loader { @@ -913,7 +911,6 @@ const default_loaders_posix = .{ .{ ".text", .text }, .{ ".html", .html }, .{ ".jsonc", .json }, - .{ "bun.lock", .json }, }; const default_loaders_win32 = default_loaders_posix ++ .{ .{ ".sh", .bunsh }, @@ -1303,7 +1300,7 @@ const default_loader_ext = [_]string{ ".toml", ".wasm", ".txt", ".text", - "bun.lock", ".jsonc", + ".jsonc", }; // Only set it for browsers by default. @@ -1329,7 +1326,6 @@ const node_modules_default_loader_ext = [_]string{ ".wasm", ".text", ".html", - "bun.lock", }; pub const ResolveFileExtensions = struct { From 3101a27402f7e7405de931d32d61dc716931cf6f Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Fri, 10 Jan 2025 10:10:49 +0000 Subject: [PATCH 11/14] `bun run zig-format` --- src/options.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/options.zig b/src/options.zig index f8eb32e77071b3..3e965a81b9d0bc 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1289,16 +1289,16 @@ pub fn definesFromTransformOptions( const default_loader_ext_bun = [_]string{".node"}; const default_loader_ext = [_]string{ - ".jsx", ".json", - ".js", ".mjs", - ".cjs", ".css", + ".jsx", ".json", + ".js", ".mjs", + ".cjs", ".css", // https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#new-file-extensions - ".ts", ".tsx", - ".mts", ".cts", + ".ts", ".tsx", + ".mts", ".cts", - ".toml", ".wasm", - ".txt", ".text", + ".toml", ".wasm", + ".txt", ".text", ".jsonc", }; From 335faa84169097e56fa92a64ae0430d06ab8f785 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Fri, 10 Jan 2025 13:38:41 +0100 Subject: [PATCH 12/14] add tests --- test/js/bun/resolve/bun-lock.test.ts | 27 +++++++++++++++++++++++++++ test/js/bun/resolve/jsonc.test.ts | 16 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/js/bun/resolve/bun-lock.test.ts diff --git a/test/js/bun/resolve/bun-lock.test.ts b/test/js/bun/resolve/bun-lock.test.ts new file mode 100644 index 00000000000000..251783c00eefc4 --- /dev/null +++ b/test/js/bun/resolve/bun-lock.test.ts @@ -0,0 +1,27 @@ +import { expect, test } from "bun:test"; +import { tempDirWithFiles } from "harness"; +import { join } from "path"; + +const lockfile = `{ + "lockfileVersion": 0, + "workspaces": { + "": { + "name": "something", + "dependencies": { }, + }, + }, + "packages": { }, +}`; + +test("import bun.lock file as json", async () => { + const dir = tempDirWithFiles("bun-lock", { + "bun.lock": lockfile, + "index.ts": ` + import lockfile from './bun.lock'; + const _lockfile = ${lockfile} + if (!Bun.deepEquals(lockfile, _lockfile)) throw new Error('bun.lock wasnt imported as jsonc'); + `, + }); + + expect([join(dir, "index.ts")]).toRun(); +}); diff --git a/test/js/bun/resolve/jsonc.test.ts b/test/js/bun/resolve/jsonc.test.ts index d2571644c8d6da..bab3ba29ff3e0c 100644 --- a/test/js/bun/resolve/jsonc.test.ts +++ b/test/js/bun/resolve/jsonc.test.ts @@ -22,3 +22,19 @@ test("empty jsonc - tsconfig.json", async () => { }); expect([join(dir, "index.ts")]).toRun(); }); + +test("import anything.jsonc as json", async () => { + const jsoncFile = `{ + // comment + "trailingComma": 0, + }`; + const dir = tempDirWithFiles("jsonc", { + "anything.jsonc": jsoncFile, + "index.ts": ` + import file from './anything.jsonc'; + const _file = ${jsoncFile} + if (!Bun.deepEquals(file, _file)) throw new Error('anything.jsonc wasnt imported as jsonc'); + `, + }); + expect([join(dir, "index.ts")]).toRun(); +}); From c32b8d6a58ac729965d008c16c455c9226aabc59 Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Fri, 10 Jan 2025 14:00:32 +0100 Subject: [PATCH 13/14] simplify logic --- src/fs.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fs.zig b/src/fs.zig index 17c811cde271ca..fa20e43a5272aa 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -1713,6 +1713,7 @@ pub const Path = struct { pub fn isJSONCFile(this: *const Path) bool { const str = this.name.filename; + if (strings.eqlComptime(str, "package.json") or strings.eqlComptime(str, "bun.lock")) { return true; } @@ -1721,11 +1722,11 @@ pub const Path = struct { return true; } - if (!(strings.hasPrefixComptime(str, "tsconfig.") or strings.hasPrefixComptime(str, "jsconfig."))) { - return false; + if (strings.hasPrefixComptime(str, "tsconfig.") or strings.hasPrefixComptime(str, "jsconfig.")) { + return strings.hasSuffixComptime(str, ".json"); } - return strings.hasSuffixComptime(str, ".json"); + return false; } pub const PackageRelative = struct { From f93dfa249c761a3cb540eef0e0728d8fb041e5ad Mon Sep 17 00:00:00 2001 From: RiskyMH Date: Sat, 11 Jan 2025 07:09:30 +0100 Subject: [PATCH 14/14] abstrat types more --- packages/bun-types/bun.d.ts | 51 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index bb26aa5265a236..a9779ebb9b66bc 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -1233,13 +1233,13 @@ declare module "bun" { /** * Deletes the file. ( same as unlink ) - */ - delete(): Promise + */ + delete(): Promise; /** * Provides useful information about the file. - */ - stat(): Promise + */ + stat(): Promise; } interface NetworkSink extends FileSink { /** @@ -6438,15 +6438,7 @@ declare module "bun" { type BunLockFile = { lockfileVersion: 0; workspaces: { - [workspace: string]: { - name?: string; - version?: string; - dependencies?: Record; - devDependencies?: Record; - optionalDependencies?: Record; - peerDependencies?: Record; - optionalPeers?: string[] - }; + [workspace: string]: BunLockFileWorkspacePackage; }; overrides?: Record; patchedDependencies?: Record; @@ -6467,30 +6459,41 @@ declare module "bun" { * ``` * */ packages: { - [pkg: string]: /**/ - /** npm */ - | [pkg: string, registry: string, info: BunLockFilePackageInfo, integrity: string] - /** symlink, folder, tarball, workspace */ - | [pkg: string, info: BunLockFilePackageInfo] - /** git, github */ - | [pkg: string, info: BunLockFilePackageInfo, bunTag: string] - /** root */ - | [pkg: string, info: Pick]; + [pkg: string]: BunLockFilePackageArray; }; }; - type BunLockFilePackageInfo = { + type BunLockFileBasePackageInfo = { dependencies?: Record; - optionalDependencies?: Record; devDependencies?: Record; + optionalDependencies?: Record; peerDependencies?: Record; optionalPeers?: string[]; + }; + + type BunLockFileWorkspacePackage = BunLockFileBasePackageInfo & { + name?: string; + version?: string; + }; + + type BunLockFilePackageInfo = BunLockFileBasePackageInfo & { os?: string | string[]; cpu?: string | string[]; bin?: Record; binDir?: string; bundled?: true; }; + + /** @see {@link BunLockFile.packages} for more info */ + type BunLockFilePackageArray = + /** npm */ + | [pkg: string, registry: string, info: BunLockFilePackageInfo, integrity: string] + /** symlink, folder, tarball, workspace */ + | [pkg: string, info: BunLockFilePackageInfo] + /** git, github */ + | [pkg: string, info: BunLockFilePackageInfo, bunTag: string] + /** root */ + | [pkg: string, info: Pick]; } // extends lib.dom.d.ts